diff --git a/cmd/main.go b/cmd/main.go index 8fc309f03a..dd26a71ae0 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -131,14 +131,14 @@ func deployMachineSet() { for { glog.Info("Trying to deploy Cluster object") - if _, err := v1alphaClient.Clusters("test").Create(cluster); err != nil { + if _, err := v1alphaClient.Clusters("default").Create(cluster); err != nil { glog.Infof("Cannot create cluster, retrying in 5 secs: %v", err) } else { glog.Info("Created Cluster object") } glog.Info("Trying to deploy MachineSet object") - _, err = v1alphaClient.MachineSets("test").Create(machineSet) + _, err = v1alphaClient.MachineSets("default").Create(machineSet) if err != nil { glog.Infof("Cannot create MachineSet, retrying in 5 secs: %v", err) } else { diff --git a/machines/cluster.yaml b/machines/cluster.yaml index 3044bc1ef5..2b957ce0d2 100644 --- a/machines/cluster.yaml +++ b/machines/cluster.yaml @@ -1,39 +1,15 @@ +--- apiVersion: "cluster.k8s.io/v1alpha1" kind: Cluster metadata: - name: test - namespace: test + name: {{.ClusterName}} + namespace: default spec: clusterNetwork: services: cidrBlocks: - - "10.0.0.1/24" + - "10.0.0.1/24" pods: cidrBlocks: - - "10.0.0.2/24" - serviceDomain: example.com - providerConfig: - value: - apiVersion: awsproviderconfig/v1alpha1 - kind: AWSClusterProviderConfig - clusterId: {{.VpcName}} - clusterVersionRef: - namespace: test - name: test - hardware: - aws: - region: {{.Region}} - keyPairName: {{.SshKey}} - defaultHardwareSpec: - aws: - instanceType: m4.large - machineSets: - - nodeType: Master - size: 1 - - shortName: infra - nodeType: Compute - infra: true - size: 1 - - shortName: compute - nodeType: Compute - size: 1 + - "10.0.0.2/24" + serviceDomain: unused diff --git a/machines/machine-set.yaml b/machines/machine-set.yaml index 7ed7359ca8..74efc270fa 100644 --- a/machines/machine-set.yaml +++ b/machines/machine-set.yaml @@ -1,40 +1,56 @@ +--- apiVersion: cluster.k8s.io/v1alpha1 kind: MachineSet metadata: name: worker - namespace: test + namespace: default labels: - machineapioperator.openshift.io/cluster: test + sigs.k8s.io/cluster-api-cluster: {{.ClusterName}} + sigs.k8s.io/cluster-api-machine-role: worker + sigs.k8s.io/cluster-api-machine-type: worker spec: - replicas: 3 + replicas: {{.Replicas}} selector: matchLabels: - machineapioperator.openshift.io/machineset: worker - machineapioperator.openshift.io/cluster: test + sigs.k8s.io/cluster-api-machineset: worker + sigs.k8s.io/cluster-api-cluster: {{.ClusterName}} template: metadata: labels: - machineapioperator.openshift.io/machineset: worker - machineapioperator.openshift.io/cluster: test + sigs.k8s.io/cluster-api-machineset: worker + sigs.k8s.io/cluster-api-cluster: {{.ClusterName}} + sigs.k8s.io/cluster-api-machine-role: worker + sigs.k8s.io/cluster-api-machine-type: worker spec: providerConfig: value: - apiVersion: awsproviderconfig/v1alpha1 + apiVersion: aws.cluster.k8s.io/v1alpha1 kind: AWSMachineProviderConfig - clusterId: {{.VpcName}} - clusterHardware: - aws: - keyPairName: {{.SshKey}} - region: {{.Region}} - hardware: - aws: - instanceType: m4.large - infra: false - vmImage: - awsImage: {{.Image}} + ami: + id: {{.Image}} + instanceType: m4.large + placement: + region: {{.Region}} + availabilityZone: {{.AvailabilityZone}} + subnet: + filters: + - name: "tag:Name" + values: + - {{.ClusterName}}-worker-{{.AvailabilityZone}} + publicIp: true + iamInstanceProfile: + id: {{.ClusterName}}-master-profile + keyName: tectonic + tags: + - name: tectonicClusterID + value: {{.ClusterID}} + securityGroups: + - filters: + - name: "tag:Name" + values: + - {{.ClusterName}}_worker_sg + userDataSecret: + name: ignition-worker versions: - kubelet: 0.0.0 - controlPlane: 0.0.0 - roles: - - Master - + kubelet: "" + controlPlane: "" diff --git a/manifests/clusterapi-controller.yaml b/manifests/clusterapi-controller.yaml index a804120d4c..e088146e49 100644 --- a/manifests/clusterapi-controller.yaml +++ b/manifests/clusterapi-controller.yaml @@ -45,14 +45,14 @@ spec: cpu: 100m memory: 30Mi - name: aws-machine-controller - image: quay.io/alberto_lamela/aws-machine-controller:mvp # TODO: move this to openshift org + image: quay.io/alberto_lamela/aws-machine-controller:dev # TODO: move this to openshift org env: - name: NODE_NAME valueFrom: fieldRef: fieldPath: spec.nodeName command: - - /opt/services/aws-machine-controller + - /machine-controller args: - --log-level=debug resources: diff --git a/pkg/render/config.go b/pkg/render/config.go index 78ecd2a88f..0678351705 100644 --- a/pkg/render/config.go +++ b/pkg/render/config.go @@ -11,11 +11,11 @@ const ( // OperatorConfig contains configuration for KAO managed add-ons type OperatorConfig struct { - metav1.TypeMeta `json:",inline"` - VpcName string `json:"vpcName"` - SshKey string `json:"sshKey"` - ClusterName string `json:"clusterName"` - ClusterDomain string `json:"clusterDomain"` - Region string `json:"region"` - Image string `json:"image"` + metav1.TypeMeta `json:",inline"` + ClusterName string `json:"clusterName"` + ClusterID string `json:"clusterID"` + Region string `json:"region"` + AvailabilityZone string `json:"availabilityZone"` + Image string `json:"image"` + Replicas string `json:"replicas"` } diff --git a/pkg/render/machine-api-operator-config.yaml b/pkg/render/machine-api-operator-config.yaml index 783cb8f17e..7ca6b88d24 100644 --- a/pkg/render/machine-api-operator-config.yaml +++ b/pkg/render/machine-api-operator-config.yaml @@ -1,6 +1,8 @@ apiVersion: v1 kind: machineAPIOperatorConfig -vpcName: "test" -sshKey: "test" -clusterName: "test" -clusterDomain: "test" +clusterName: meh +clusterID: b302cf66-f5ff-4d5d-1cc1-0ab2755d2065 +image: ami-0e502f54daeb8686e +region: eu-west-1 +availabilityZone: eu-west-1a +replicas: 1 diff --git a/pkg/render/render_test.go b/pkg/render/render_test.go index 58d5de782a..044da5be13 100644 --- a/pkg/render/render_test.go +++ b/pkg/render/render_test.go @@ -35,104 +35,98 @@ func testRenderManifest(t *testing.T, filename string, config *OperatorConfig, e func TestClusterManifest(t *testing.T) { config := OperatorConfig{ - VpcName: "TestClusterManifest-VpcName", - SshKey: "TestClusterManifest-SshKey", - ClusterName: "TestClusterManifest-ClusterName", - ClusterDomain: "TestClusterManifest.ClusterDomain", // TODO(frobware) - currently not a template value - Region: "TestClusterManifest-Region", - Image: "TestClusterManifest-Image", + ClusterName: "TestClusterManifest-ClusterName", + ClusterID: "TestClusterManifest-ClusterID", + Region: "TestClusterManifest-Region", + AvailabilityZone: "TestClusterManifest-AvailabilityZone", + Image: "TestClusterManifest-Image", + Replicas: "TestClusterManifest-Replicas", } testRenderManifest(t, "../../machines/cluster.yaml", &config, ` +--- apiVersion: "cluster.k8s.io/v1alpha1" kind: Cluster metadata: - name: test - namespace: test + name: TestClusterManifest-ClusterName + namespace: default spec: clusterNetwork: services: cidrBlocks: - - "10.0.0.1/24" + - "10.0.0.1/24" pods: cidrBlocks: - - "10.0.0.2/24" - serviceDomain: example.com - providerConfig: - value: - apiVersion: awsproviderconfig/v1alpha1 - kind: AWSClusterProviderConfig - clusterId: TestClusterManifest-VpcName - clusterVersionRef: - namespace: test - name: test - hardware: - aws: - region: TestClusterManifest-Region - keyPairName: TestClusterManifest-SshKey - defaultHardwareSpec: - aws: - instanceType: m4.large - machineSets: - - nodeType: Master - size: 1 - - shortName: infra - nodeType: Compute - infra: true - size: 1 - - shortName: compute - nodeType: Compute - size: 1`) + - "10.0.0.2/24" + serviceDomain: unused +`) } func TestMachineSetManifest(t *testing.T) { config := OperatorConfig{ - VpcName: "TestMachineSetManifest-VpcName", - SshKey: "TestMachineSetManifest-SshKey", - ClusterName: "TestMachineSetManifest-ClusterName", - ClusterDomain: "TestMachineSetManifest.ClusterDomain", // TODO(frobware) - currently not a template value - Region: "TestMachineSetManifest-Region", - Image: "TestMachineSetManifest-Image", + ClusterName: "TestClusterManifest-ClusterName", + ClusterID: "TestClusterManifest-ClusterID", + Region: "TestClusterManifest-Region", + AvailabilityZone: "TestClusterManifest-AvailabilityZone", + Image: "TestClusterManifest-Image", + Replicas: "TestClusterManifest-Replicas", } testRenderManifest(t, "../../machines/machine-set.yaml", &config, ` +--- apiVersion: cluster.k8s.io/v1alpha1 kind: MachineSet metadata: name: worker - namespace: test + namespace: default labels: - machineapioperator.openshift.io/cluster: test + sigs.k8s.io/cluster-api-cluster: TestClusterManifest-ClusterName + sigs.k8s.io/cluster-api-machine-role: worker + sigs.k8s.io/cluster-api-machine-type: worker spec: - replicas: 3 + replicas: TestClusterManifest-Replicas selector: matchLabels: - machineapioperator.openshift.io/machineset: worker - machineapioperator.openshift.io/cluster: test + sigs.k8s.io/cluster-api-machineset: worker + sigs.k8s.io/cluster-api-cluster: TestClusterManifest-ClusterName template: metadata: labels: - machineapioperator.openshift.io/machineset: worker - machineapioperator.openshift.io/cluster: test + sigs.k8s.io/cluster-api-machineset: worker + sigs.k8s.io/cluster-api-cluster: TestClusterManifest-ClusterName + sigs.k8s.io/cluster-api-machine-role: worker + sigs.k8s.io/cluster-api-machine-type: worker spec: providerConfig: value: - apiVersion: awsproviderconfig/v1alpha1 + apiVersion: aws.cluster.k8s.io/v1alpha1 kind: AWSMachineProviderConfig - clusterId: TestMachineSetManifest-VpcName - clusterHardware: - aws: - keyPairName: TestMachineSetManifest-SshKey - region: TestMachineSetManifest-Region - hardware: - aws: - instanceType: m4.large - infra: false - vmImage: - awsImage: TestMachineSetManifest-Image + ami: + id: TestClusterManifest-Image + instanceType: m4.large + placement: + region: TestClusterManifest-Region + availabilityZone: TestClusterManifest-AvailabilityZone + subnet: + filters: + - name: "tag:Name" + values: + - TestClusterManifest-ClusterName-worker-TestClusterManifest-AvailabilityZone + publicIp: true + iamInstanceProfile: + id: TestClusterManifest-ClusterName-master-profile + keyName: tectonic + tags: + - name: tectonicClusterID + value: TestClusterManifest-ClusterID + securityGroups: + - filters: + - name: "tag:Name" + values: + - TestClusterManifest-ClusterName_worker_sg + userDataSecret: + name: ignition-worker versions: - kubelet: 0.0.0 - controlPlane: 0.0.0 - roles: - - Master`) + kubelet: "" + controlPlane: ""`) }