From 29a72684425e1ede7394fe2e6c110f5c9026f4c5 Mon Sep 17 00:00:00 2001 From: Ole Markus With Date: Fri, 19 Aug 2022 18:07:44 +0200 Subject: [PATCH] Add more create_cluster integration tests --- cmd/kops/create_cluster_integration_test.go | 8 ++ .../different-amis/expected-v1alpha2.yaml | 135 ++++++++++++++++++ .../different-amis/options.yaml | 11 ++ .../minimal-1.24/expected-v1alpha2.yaml | 103 +++++++++++++ .../create_cluster/minimal-1.24/options.yaml | 6 + .../minimal-1.25/expected-v1alpha2.yaml | 103 +++++++++++++ .../create_cluster/minimal-1.25/options.yaml | 6 + .../minimal-1.26/expected-v1alpha2.yaml | 103 +++++++++++++ .../create_cluster/minimal-1.26/options.yaml | 6 + 9 files changed, 481 insertions(+) create mode 100644 tests/integration/create_cluster/different-amis/expected-v1alpha2.yaml create mode 100644 tests/integration/create_cluster/different-amis/options.yaml create mode 100644 tests/integration/create_cluster/minimal-1.24/expected-v1alpha2.yaml create mode 100644 tests/integration/create_cluster/minimal-1.24/options.yaml create mode 100644 tests/integration/create_cluster/minimal-1.25/expected-v1alpha2.yaml create mode 100644 tests/integration/create_cluster/minimal-1.25/options.yaml create mode 100644 tests/integration/create_cluster/minimal-1.26/expected-v1alpha2.yaml create mode 100644 tests/integration/create_cluster/minimal-1.26/options.yaml diff --git a/cmd/kops/create_cluster_integration_test.go b/cmd/kops/create_cluster_integration_test.go index bb671ff646..094c1c40bc 100644 --- a/cmd/kops/create_cluster_integration_test.go +++ b/cmd/kops/create_cluster_integration_test.go @@ -50,6 +50,9 @@ func TestCreateClusterMinimal(t *testing.T) { runCreateClusterIntegrationTest(t, "../../tests/integration/create_cluster/minimal-1.21", "v1alpha2") runCreateClusterIntegrationTest(t, "../../tests/integration/create_cluster/minimal-1.22", "v1alpha2") runCreateClusterIntegrationTest(t, "../../tests/integration/create_cluster/minimal-1.23", "v1alpha2") + runCreateClusterIntegrationTest(t, "../../tests/integration/create_cluster/minimal-1.24", "v1alpha2") + runCreateClusterIntegrationTest(t, "../../tests/integration/create_cluster/minimal-1.25", "v1alpha2") + runCreateClusterIntegrationTest(t, "../../tests/integration/create_cluster/minimal-1.26", "v1alpha2") } // TestCreateClusterOverride tests the override flag @@ -133,6 +136,11 @@ func TestCreateClusterIPv6(t *testing.T) { runCreateClusterIntegrationTest(t, "../../tests/integration/create_cluster/ipv6", "v1alpha2") } +// TestCreateClusterDifferentAMIs runs kops create cluster with different AMI inputs +func TestCreateClusterDifferentAMIs(t *testing.T) { + runCreateClusterIntegrationTest(t, "../../tests/integration/create_cluster/different-amis", "v1alpha2") +} + // TestCreateClusterKarpenter runs kops create cluster --instance-manager=karpenter func TestCreateClusterKarpenter(t *testing.T) { featureflag.ParseFlags("+Karpenter") diff --git a/tests/integration/create_cluster/different-amis/expected-v1alpha2.yaml b/tests/integration/create_cluster/different-amis/expected-v1alpha2.yaml new file mode 100644 index 0000000000..3b471640ca --- /dev/null +++ b/tests/integration/create_cluster/different-amis/expected-v1alpha2.yaml @@ -0,0 +1,135 @@ +apiVersion: kops.k8s.io/v1alpha2 +kind: Cluster +metadata: + creationTimestamp: "2017-01-01T00:00:00Z" + name: amis.example.com +spec: + api: + loadBalancer: + class: Classic + type: Public + authorization: + rbac: {} + channel: stable + cloudProvider: aws + configBase: memfs://tests/amis.example.com + etcdClusters: + - cpuRequest: 200m + etcdMembers: + - encryptedVolume: true + instanceGroup: master-us-test-1a + name: a + memoryRequest: 100Mi + name: main + - cpuRequest: 100m + etcdMembers: + - encryptedVolume: true + instanceGroup: master-us-test-1a + name: a + memoryRequest: 100Mi + name: events + iam: + allowContainerRegistry: true + legacy: false + kubelet: + anonymousAuth: false + kubernetesApiAccess: + - 0.0.0.0/0 + - ::/0 + kubernetesVersion: v1.24.0 + masterPublicName: api.amis.example.com + networkCIDR: 172.20.0.0/16 + networking: + cni: {} + nonMasqueradeCIDR: 100.64.0.0/10 + sshAccess: + - 0.0.0.0/0 + - ::/0 + subnets: + - cidr: 172.20.32.0/19 + name: us-test-1a + type: Private + zone: us-test-1a + - cidr: 172.20.0.0/22 + name: utility-us-test-1a + type: Utility + zone: us-test-1a + topology: + bastion: + bastionPublicName: bastion.amis.example.com + dns: + type: Public + masters: private + nodes: private + +--- + +apiVersion: kops.k8s.io/v1alpha2 +kind: InstanceGroup +metadata: + creationTimestamp: "2017-01-01T00:00:00Z" + labels: + kops.k8s.io/cluster: amis.example.com + name: bastions +spec: + image: ami-image + instanceMetadata: + httpPutResponseHopLimit: 1 + httpTokens: required + machineType: t2.micro + manager: CloudGroup + maxSize: 1 + minSize: 1 + nodeLabels: + kops.k8s.io/instancegroup: bastions + role: Bastion + subnets: + - us-test-1a + +--- + +apiVersion: kops.k8s.io/v1alpha2 +kind: InstanceGroup +metadata: + creationTimestamp: "2017-01-01T00:00:00Z" + labels: + kops.k8s.io/cluster: amis.example.com + name: master-us-test-1a +spec: + image: ami-control-plane + instanceMetadata: + httpPutResponseHopLimit: 3 + httpTokens: required + machineType: m3.medium + manager: CloudGroup + maxSize: 1 + minSize: 1 + nodeLabels: + kops.k8s.io/instancegroup: master-us-test-1a + role: Master + subnets: + - us-test-1a + +--- + +apiVersion: kops.k8s.io/v1alpha2 +kind: InstanceGroup +metadata: + creationTimestamp: "2017-01-01T00:00:00Z" + labels: + kops.k8s.io/cluster: amis.example.com + name: nodes-us-test-1a +spec: + image: ami-worker-image + instanceMetadata: + httpPutResponseHopLimit: 1 + httpTokens: required + machineType: t2.medium + manager: CloudGroup + maxSize: 1 + minSize: 1 + nodeLabels: + kops.k8s.io/instancegroup: nodes-us-test-1a + role: Node + subnets: + - us-test-1a diff --git a/tests/integration/create_cluster/different-amis/options.yaml b/tests/integration/create_cluster/different-amis/options.yaml new file mode 100644 index 0000000000..e3099b0cc7 --- /dev/null +++ b/tests/integration/create_cluster/different-amis/options.yaml @@ -0,0 +1,11 @@ +ClusterName: amis.example.com +Zones: +- us-test-1a +CloudProvider: aws +Networking: cni +KubernetesVersion: v1.24.0 +Image: ami-image +MasterImage: ami-control-plane +NodeImage: ami-worker-image +Bastion: true +Topology: private \ No newline at end of file diff --git a/tests/integration/create_cluster/minimal-1.24/expected-v1alpha2.yaml b/tests/integration/create_cluster/minimal-1.24/expected-v1alpha2.yaml new file mode 100644 index 0000000000..2144870ffe --- /dev/null +++ b/tests/integration/create_cluster/minimal-1.24/expected-v1alpha2.yaml @@ -0,0 +1,103 @@ +apiVersion: kops.k8s.io/v1alpha2 +kind: Cluster +metadata: + creationTimestamp: "2017-01-01T00:00:00Z" + name: minimal.example.com +spec: + api: + dns: {} + authorization: + rbac: {} + channel: stable + cloudProvider: aws + configBase: memfs://tests/minimal.example.com + etcdClusters: + - cpuRequest: 200m + etcdMembers: + - encryptedVolume: true + instanceGroup: master-us-test-1a + name: a + memoryRequest: 100Mi + name: main + - cpuRequest: 100m + etcdMembers: + - encryptedVolume: true + instanceGroup: master-us-test-1a + name: a + memoryRequest: 100Mi + name: events + iam: + allowContainerRegistry: true + legacy: false + kubelet: + anonymousAuth: false + kubernetesApiAccess: + - 0.0.0.0/0 + - ::/0 + kubernetesVersion: v1.24.0 + masterPublicName: api.minimal.example.com + networkCIDR: 172.20.0.0/16 + networking: + cni: {} + nonMasqueradeCIDR: 100.64.0.0/10 + sshAccess: + - 0.0.0.0/0 + - ::/0 + subnets: + - cidr: 172.20.32.0/19 + name: us-test-1a + type: Public + zone: us-test-1a + topology: + dns: + type: Public + masters: public + nodes: public + +--- + +apiVersion: kops.k8s.io/v1alpha2 +kind: InstanceGroup +metadata: + creationTimestamp: "2017-01-01T00:00:00Z" + labels: + kops.k8s.io/cluster: minimal.example.com + name: master-us-test-1a +spec: + image: 099720109477/ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-20220615 + instanceMetadata: + httpPutResponseHopLimit: 3 + httpTokens: required + machineType: m3.medium + manager: CloudGroup + maxSize: 1 + minSize: 1 + nodeLabels: + kops.k8s.io/instancegroup: master-us-test-1a + role: Master + subnets: + - us-test-1a + +--- + +apiVersion: kops.k8s.io/v1alpha2 +kind: InstanceGroup +metadata: + creationTimestamp: "2017-01-01T00:00:00Z" + labels: + kops.k8s.io/cluster: minimal.example.com + name: nodes-us-test-1a +spec: + image: 099720109477/ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-20220615 + instanceMetadata: + httpPutResponseHopLimit: 1 + httpTokens: required + machineType: t2.medium + manager: CloudGroup + maxSize: 1 + minSize: 1 + nodeLabels: + kops.k8s.io/instancegroup: nodes-us-test-1a + role: Node + subnets: + - us-test-1a diff --git a/tests/integration/create_cluster/minimal-1.24/options.yaml b/tests/integration/create_cluster/minimal-1.24/options.yaml new file mode 100644 index 0000000000..b0adddad12 --- /dev/null +++ b/tests/integration/create_cluster/minimal-1.24/options.yaml @@ -0,0 +1,6 @@ +ClusterName: minimal.example.com +Zones: +- us-test-1a +CloudProvider: aws +Networking: cni +KubernetesVersion: v1.24.0 diff --git a/tests/integration/create_cluster/minimal-1.25/expected-v1alpha2.yaml b/tests/integration/create_cluster/minimal-1.25/expected-v1alpha2.yaml new file mode 100644 index 0000000000..f6a9e3cf70 --- /dev/null +++ b/tests/integration/create_cluster/minimal-1.25/expected-v1alpha2.yaml @@ -0,0 +1,103 @@ +apiVersion: kops.k8s.io/v1alpha2 +kind: Cluster +metadata: + creationTimestamp: "2017-01-01T00:00:00Z" + name: minimal.example.com +spec: + api: + dns: {} + authorization: + rbac: {} + channel: stable + cloudProvider: aws + configBase: memfs://tests/minimal.example.com + etcdClusters: + - cpuRequest: 200m + etcdMembers: + - encryptedVolume: true + instanceGroup: master-us-test-1a + name: a + memoryRequest: 100Mi + name: main + - cpuRequest: 100m + etcdMembers: + - encryptedVolume: true + instanceGroup: master-us-test-1a + name: a + memoryRequest: 100Mi + name: events + iam: + allowContainerRegistry: true + legacy: false + kubelet: + anonymousAuth: false + kubernetesApiAccess: + - 0.0.0.0/0 + - ::/0 + kubernetesVersion: v1.25.0 + masterPublicName: api.minimal.example.com + networkCIDR: 172.20.0.0/16 + networking: + cni: {} + nonMasqueradeCIDR: 100.64.0.0/10 + sshAccess: + - 0.0.0.0/0 + - ::/0 + subnets: + - cidr: 172.20.32.0/19 + name: us-test-1a + type: Public + zone: us-test-1a + topology: + dns: + type: Public + masters: public + nodes: public + +--- + +apiVersion: kops.k8s.io/v1alpha2 +kind: InstanceGroup +metadata: + creationTimestamp: "2017-01-01T00:00:00Z" + labels: + kops.k8s.io/cluster: minimal.example.com + name: master-us-test-1a +spec: + image: 099720109477/ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-20220615 + instanceMetadata: + httpPutResponseHopLimit: 3 + httpTokens: required + machineType: m3.medium + manager: CloudGroup + maxSize: 1 + minSize: 1 + nodeLabels: + kops.k8s.io/instancegroup: master-us-test-1a + role: Master + subnets: + - us-test-1a + +--- + +apiVersion: kops.k8s.io/v1alpha2 +kind: InstanceGroup +metadata: + creationTimestamp: "2017-01-01T00:00:00Z" + labels: + kops.k8s.io/cluster: minimal.example.com + name: nodes-us-test-1a +spec: + image: 099720109477/ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-20220615 + instanceMetadata: + httpPutResponseHopLimit: 1 + httpTokens: required + machineType: t2.medium + manager: CloudGroup + maxSize: 1 + minSize: 1 + nodeLabels: + kops.k8s.io/instancegroup: nodes-us-test-1a + role: Node + subnets: + - us-test-1a diff --git a/tests/integration/create_cluster/minimal-1.25/options.yaml b/tests/integration/create_cluster/minimal-1.25/options.yaml new file mode 100644 index 0000000000..8ce23c28fe --- /dev/null +++ b/tests/integration/create_cluster/minimal-1.25/options.yaml @@ -0,0 +1,6 @@ +ClusterName: minimal.example.com +Zones: +- us-test-1a +CloudProvider: aws +Networking: cni +KubernetesVersion: v1.25.0 diff --git a/tests/integration/create_cluster/minimal-1.26/expected-v1alpha2.yaml b/tests/integration/create_cluster/minimal-1.26/expected-v1alpha2.yaml new file mode 100644 index 0000000000..ce037e5f9e --- /dev/null +++ b/tests/integration/create_cluster/minimal-1.26/expected-v1alpha2.yaml @@ -0,0 +1,103 @@ +apiVersion: kops.k8s.io/v1alpha2 +kind: Cluster +metadata: + creationTimestamp: "2017-01-01T00:00:00Z" + name: minimal.example.com +spec: + api: + dns: {} + authorization: + rbac: {} + channel: stable + cloudProvider: aws + configBase: memfs://tests/minimal.example.com + etcdClusters: + - cpuRequest: 200m + etcdMembers: + - encryptedVolume: true + instanceGroup: master-us-test-1a + name: a + memoryRequest: 100Mi + name: main + - cpuRequest: 100m + etcdMembers: + - encryptedVolume: true + instanceGroup: master-us-test-1a + name: a + memoryRequest: 100Mi + name: events + iam: + allowContainerRegistry: true + legacy: false + kubelet: + anonymousAuth: false + kubernetesApiAccess: + - 0.0.0.0/0 + - ::/0 + kubernetesVersion: v1.26.0 + masterPublicName: api.minimal.example.com + networkCIDR: 172.20.0.0/16 + networking: + cni: {} + nonMasqueradeCIDR: 100.64.0.0/10 + sshAccess: + - 0.0.0.0/0 + - ::/0 + subnets: + - cidr: 172.20.32.0/19 + name: us-test-1a + type: Public + zone: us-test-1a + topology: + dns: + type: Public + masters: public + nodes: public + +--- + +apiVersion: kops.k8s.io/v1alpha2 +kind: InstanceGroup +metadata: + creationTimestamp: "2017-01-01T00:00:00Z" + labels: + kops.k8s.io/cluster: minimal.example.com + name: master-us-test-1a +spec: + image: 099720109477/ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-20220615 + instanceMetadata: + httpPutResponseHopLimit: 3 + httpTokens: required + machineType: m3.medium + manager: CloudGroup + maxSize: 1 + minSize: 1 + nodeLabels: + kops.k8s.io/instancegroup: master-us-test-1a + role: Master + subnets: + - us-test-1a + +--- + +apiVersion: kops.k8s.io/v1alpha2 +kind: InstanceGroup +metadata: + creationTimestamp: "2017-01-01T00:00:00Z" + labels: + kops.k8s.io/cluster: minimal.example.com + name: nodes-us-test-1a +spec: + image: 099720109477/ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-20220615 + instanceMetadata: + httpPutResponseHopLimit: 1 + httpTokens: required + machineType: t2.medium + manager: CloudGroup + maxSize: 1 + minSize: 1 + nodeLabels: + kops.k8s.io/instancegroup: nodes-us-test-1a + role: Node + subnets: + - us-test-1a diff --git a/tests/integration/create_cluster/minimal-1.26/options.yaml b/tests/integration/create_cluster/minimal-1.26/options.yaml new file mode 100644 index 0000000000..898b627d38 --- /dev/null +++ b/tests/integration/create_cluster/minimal-1.26/options.yaml @@ -0,0 +1,6 @@ +ClusterName: minimal.example.com +Zones: +- us-test-1a +CloudProvider: aws +Networking: cni +KubernetesVersion: v1.26.0