Skip to content

Commit 04253cb

Browse files
committed
add support for openshift actuator
1 parent 2f4a03b commit 04253cb

7 files changed

+122
-134
lines changed

cmd/main.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -131,14 +131,14 @@ func deployMachineSet() {
131131

132132
for {
133133
glog.Info("Trying to deploy Cluster object")
134-
if _, err := v1alphaClient.Clusters("test").Create(cluster); err != nil {
134+
if _, err := v1alphaClient.Clusters("default").Create(cluster); err != nil {
135135
glog.Infof("Cannot create cluster, retrying in 5 secs: %v", err)
136136
} else {
137137
glog.Info("Created Cluster object")
138138
}
139139

140140
glog.Info("Trying to deploy MachineSet object")
141-
_, err = v1alphaClient.MachineSets("test").Create(machineSet)
141+
_, err = v1alphaClient.MachineSets("default").Create(machineSet)
142142
if err != nil {
143143
glog.Infof("Cannot create MachineSet, retrying in 5 secs: %v", err)
144144
} else {

machines/cluster.yaml

+6-30
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,15 @@
1+
---
12
apiVersion: "cluster.k8s.io/v1alpha1"
23
kind: Cluster
34
metadata:
4-
name: test
5-
namespace: test
5+
name: {{.ClusterName}}
6+
namespace: default
67
spec:
78
clusterNetwork:
89
services:
910
cidrBlocks:
10-
- "10.0.0.1/24"
11+
- "10.0.0.1/24"
1112
pods:
1213
cidrBlocks:
13-
- "10.0.0.2/24"
14-
serviceDomain: example.com
15-
providerConfig:
16-
value:
17-
apiVersion: awsproviderconfig/v1alpha1
18-
kind: AWSClusterProviderConfig
19-
clusterId: {{.VpcName}}
20-
clusterVersionRef:
21-
namespace: test
22-
name: test
23-
hardware:
24-
aws:
25-
region: {{.Region}}
26-
keyPairName: {{.SshKey}}
27-
defaultHardwareSpec:
28-
aws:
29-
instanceType: m4.large
30-
machineSets:
31-
- nodeType: Master
32-
size: 1
33-
- shortName: infra
34-
nodeType: Compute
35-
infra: true
36-
size: 1
37-
- shortName: compute
38-
nodeType: Compute
39-
size: 1
14+
- "10.0.0.2/24"
15+
serviceDomain: unused

machines/machine-set.yaml

+40-24
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,56 @@
1+
---
12
apiVersion: cluster.k8s.io/v1alpha1
23
kind: MachineSet
34
metadata:
45
name: worker
5-
namespace: test
6+
namespace: default
67
labels:
7-
machineapioperator.openshift.io/cluster: test
8+
sigs.k8s.io/cluster-api-cluster: {{.ClusterName}}
9+
sigs.k8s.io/cluster-api-machine-role: worker
10+
sigs.k8s.io/cluster-api-machine-type: worker
811
spec:
9-
replicas: 3
12+
replicas: {{.Replicas}}
1013
selector:
1114
matchLabels:
12-
machineapioperator.openshift.io/machineset: worker
13-
machineapioperator.openshift.io/cluster: test
15+
sigs.k8s.io/cluster-api-machineset: worker
16+
sigs.k8s.io/cluster-api-cluster: {{.ClusterName}}
1417
template:
1518
metadata:
1619
labels:
17-
machineapioperator.openshift.io/machineset: worker
18-
machineapioperator.openshift.io/cluster: test
20+
sigs.k8s.io/cluster-api-machineset: worker
21+
sigs.k8s.io/cluster-api-cluster: {{.ClusterName}}
22+
sigs.k8s.io/cluster-api-machine-role: worker
23+
sigs.k8s.io/cluster-api-machine-type: worker
1924
spec:
2025
providerConfig:
2126
value:
22-
apiVersion: awsproviderconfig/v1alpha1
27+
apiVersion: aws.cluster.k8s.io/v1alpha1
2328
kind: AWSMachineProviderConfig
24-
clusterId: {{.VpcName}}
25-
clusterHardware:
26-
aws:
27-
keyPairName: {{.SshKey}}
28-
region: {{.Region}}
29-
hardware:
30-
aws:
31-
instanceType: m4.large
32-
infra: false
33-
vmImage:
34-
awsImage: {{.Image}}
29+
ami:
30+
id: {{.Image}}
31+
instanceType: m4.large
32+
placement:
33+
region: {{.Region}}
34+
availabilityZone: {{.AvailabilityZone}}
35+
subnet:
36+
filters:
37+
- name: "tag:Name"
38+
values:
39+
- {{.ClusterName}}-worker-{{.AvailabilityZone}}
40+
publicIp: true
41+
iamInstanceProfile:
42+
id: {{.ClusterName}}-master-profile
43+
keyName: tectonic
44+
tags:
45+
- name: tectonicClusterID
46+
value: {{.ClusterID}}
47+
securityGroups:
48+
- filters:
49+
- name: "tag:Name"
50+
values:
51+
- {{.ClusterName}}_worker_sg
52+
userDataSecret:
53+
name: ignition-worker
3554
versions:
36-
kubelet: 0.0.0
37-
controlPlane: 0.0.0
38-
roles:
39-
- Master
40-
55+
kubelet: ""
56+
controlPlane: ""

manifests/clusterapi-controller.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ spec:
4545
cpu: 100m
4646
memory: 30Mi
4747
- name: aws-machine-controller
48-
image: quay.io/alberto_lamela/aws-machine-controller:mvp # TODO: move this to openshift org
48+
image: quay.io/alberto_lamela/aws-machine-controller:dev # TODO: move this to openshift org
4949
env:
5050
- name: NODE_NAME
5151
valueFrom:
5252
fieldRef:
5353
fieldPath: spec.nodeName
5454
command:
55-
- /opt/services/aws-machine-controller
55+
- /machine-controller
5656
args:
5757
- --log-level=debug
5858
resources:

pkg/render/config.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ const (
1111

1212
// OperatorConfig contains configuration for KAO managed add-ons
1313
type OperatorConfig struct {
14-
metav1.TypeMeta `json:",inline"`
15-
VpcName string `json:"vpcName"`
16-
SshKey string `json:"sshKey"`
17-
ClusterName string `json:"clusterName"`
18-
ClusterDomain string `json:"clusterDomain"`
19-
Region string `json:"region"`
20-
Image string `json:"image"`
14+
metav1.TypeMeta `json:",inline"`
15+
ClusterName string `json:"clusterName"`
16+
ClusterID string `json:"clusterID"`
17+
Region string `json:"region"`
18+
AvailabilityZone string `json:"availabilityZone"`
19+
Image string `json:"image"`
20+
Replicas string `json:"replicas"`
2121
}
+6-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
apiVersion: v1
22
kind: machineAPIOperatorConfig
3-
vpcName: "test"
4-
sshKey: "test"
5-
clusterName: "test"
6-
clusterDomain: "test"
3+
clusterName: meh
4+
clusterID: b302cf66-f5ff-4d5d-1cc1-0ab2755d2065
5+
image: ami-0e502f54daeb8686e
6+
region: eu-west-1
7+
availabilityZone: eu-west-1a
8+
replicas: 1

pkg/render/render_test.go

+59-65
Original file line numberDiff line numberDiff line change
@@ -35,104 +35,98 @@ func testRenderManifest(t *testing.T, filename string, config *OperatorConfig, e
3535

3636
func TestClusterManifest(t *testing.T) {
3737
config := OperatorConfig{
38-
VpcName: "TestClusterManifest-VpcName",
39-
SshKey: "TestClusterManifest-SshKey",
40-
ClusterName: "TestClusterManifest-ClusterName",
41-
ClusterDomain: "TestClusterManifest.ClusterDomain", // TODO(frobware) - currently not a template value
42-
Region: "TestClusterManifest-Region",
43-
Image: "TestClusterManifest-Image",
38+
ClusterName: "TestClusterManifest-ClusterName",
39+
ClusterID: "TestClusterManifest-ClusterID",
40+
Region: "TestClusterManifest-Region",
41+
AvailabilityZone: "TestClusterManifest-AvailabilityZone",
42+
Image: "TestClusterManifest-Image",
43+
Replicas: "TestClusterManifest-Replicas",
4444
}
4545

4646
testRenderManifest(t, "../../machines/cluster.yaml", &config, `
47+
---
4748
apiVersion: "cluster.k8s.io/v1alpha1"
4849
kind: Cluster
4950
metadata:
50-
name: test
51-
namespace: test
51+
name: TestClusterManifest-ClusterName
52+
namespace: default
5253
spec:
5354
clusterNetwork:
5455
services:
5556
cidrBlocks:
56-
- "10.0.0.1/24"
57+
- "10.0.0.1/24"
5758
pods:
5859
cidrBlocks:
59-
- "10.0.0.2/24"
60-
serviceDomain: example.com
61-
providerConfig:
62-
value:
63-
apiVersion: awsproviderconfig/v1alpha1
64-
kind: AWSClusterProviderConfig
65-
clusterId: TestClusterManifest-VpcName
66-
clusterVersionRef:
67-
namespace: test
68-
name: test
69-
hardware:
70-
aws:
71-
region: TestClusterManifest-Region
72-
keyPairName: TestClusterManifest-SshKey
73-
defaultHardwareSpec:
74-
aws:
75-
instanceType: m4.large
76-
machineSets:
77-
- nodeType: Master
78-
size: 1
79-
- shortName: infra
80-
nodeType: Compute
81-
infra: true
82-
size: 1
83-
- shortName: compute
84-
nodeType: Compute
85-
size: 1`)
60+
- "10.0.0.2/24"
61+
serviceDomain: unused
62+
`)
8663
}
8764

8865
func TestMachineSetManifest(t *testing.T) {
8966
config := OperatorConfig{
90-
VpcName: "TestMachineSetManifest-VpcName",
91-
SshKey: "TestMachineSetManifest-SshKey",
92-
ClusterName: "TestMachineSetManifest-ClusterName",
93-
ClusterDomain: "TestMachineSetManifest.ClusterDomain", // TODO(frobware) - currently not a template value
94-
Region: "TestMachineSetManifest-Region",
95-
Image: "TestMachineSetManifest-Image",
67+
ClusterName: "TestClusterManifest-ClusterName",
68+
ClusterID: "TestClusterManifest-ClusterID",
69+
Region: "TestClusterManifest-Region",
70+
AvailabilityZone: "TestClusterManifest-AvailabilityZone",
71+
Image: "TestClusterManifest-Image",
72+
Replicas: "TestClusterManifest-Replicas",
9673
}
9774

9875
testRenderManifest(t, "../../machines/machine-set.yaml", &config, `
76+
---
9977
apiVersion: cluster.k8s.io/v1alpha1
10078
kind: MachineSet
10179
metadata:
10280
name: worker
103-
namespace: test
81+
namespace: default
10482
labels:
105-
machineapioperator.openshift.io/cluster: test
83+
sigs.k8s.io/cluster-api-cluster: TestClusterManifest-ClusterName
84+
sigs.k8s.io/cluster-api-machine-role: worker
85+
sigs.k8s.io/cluster-api-machine-type: worker
10686
spec:
107-
replicas: 3
87+
replicas: TestClusterManifest-Replicas
10888
selector:
10989
matchLabels:
110-
machineapioperator.openshift.io/machineset: worker
111-
machineapioperator.openshift.io/cluster: test
90+
sigs.k8s.io/cluster-api-machineset: worker
91+
sigs.k8s.io/cluster-api-cluster: TestClusterManifest-ClusterName
11292
template:
11393
metadata:
11494
labels:
115-
machineapioperator.openshift.io/machineset: worker
116-
machineapioperator.openshift.io/cluster: test
95+
sigs.k8s.io/cluster-api-machineset: worker
96+
sigs.k8s.io/cluster-api-cluster: TestClusterManifest-ClusterName
97+
sigs.k8s.io/cluster-api-machine-role: worker
98+
sigs.k8s.io/cluster-api-machine-type: worker
11799
spec:
118100
providerConfig:
119101
value:
120-
apiVersion: awsproviderconfig/v1alpha1
102+
apiVersion: aws.cluster.k8s.io/v1alpha1
121103
kind: AWSMachineProviderConfig
122-
clusterId: TestMachineSetManifest-VpcName
123-
clusterHardware:
124-
aws:
125-
keyPairName: TestMachineSetManifest-SshKey
126-
region: TestMachineSetManifest-Region
127-
hardware:
128-
aws:
129-
instanceType: m4.large
130-
infra: false
131-
vmImage:
132-
awsImage: TestMachineSetManifest-Image
104+
ami:
105+
id: TestClusterManifest-Image
106+
instanceType: m4.large
107+
placement:
108+
region: TestClusterManifest-Region
109+
availabilityZone: TestClusterManifest-AvailabilityZone
110+
subnet:
111+
filters:
112+
- name: "tag:Name"
113+
values:
114+
- TestClusterManifest-ClusterName-worker-TestClusterManifest-AvailabilityZone
115+
publicIp: true
116+
iamInstanceProfile:
117+
id: TestClusterManifest-ClusterName-master-profile
118+
keyName: tectonic
119+
tags:
120+
- name: tectonicClusterID
121+
value: TestClusterManifest-ClusterID
122+
securityGroups:
123+
- filters:
124+
- name: "tag:Name"
125+
values:
126+
- TestClusterManifest-ClusterName_worker_sg
127+
userDataSecret:
128+
name: ignition-worker
133129
versions:
134-
kubelet: 0.0.0
135-
controlPlane: 0.0.0
136-
roles:
137-
- Master`)
130+
kubelet: ""
131+
controlPlane: ""`)
138132
}

0 commit comments

Comments
 (0)