From afbb6475fe23eae995d863c9a8866cc6640600ba Mon Sep 17 00:00:00 2001 From: Ciprian Hacman Date: Fri, 4 Dec 2020 20:15:45 +0200 Subject: [PATCH] Add integration test for creating an HA cluster in shared zone --- cmd/kops/create_cluster_integration_test.go | 5 + .../ha_shared_zone/expected-v1alpha2.yaml | 140 ++++++++++++++++++ .../ha_shared_zone/options.yaml | 6 + 3 files changed, 151 insertions(+) create mode 100644 tests/integration/create_cluster/ha_shared_zone/expected-v1alpha2.yaml create mode 100644 tests/integration/create_cluster/ha_shared_zone/options.yaml diff --git a/cmd/kops/create_cluster_integration_test.go b/cmd/kops/create_cluster_integration_test.go index 1af10ccfc2..568ce79c68 100644 --- a/cmd/kops/create_cluster_integration_test.go +++ b/cmd/kops/create_cluster_integration_test.go @@ -73,6 +73,11 @@ func TestCreateClusterGCE(t *testing.T) { runCreateClusterIntegrationTest(t, "../../tests/integration/create_cluster/gce_byo_sa", "v1alpha2") } +// TestCreateClusterHASharedZone tests kops create cluster when the master count is bigger than the number of zones +func TestCreateClusterHASharedZone(t *testing.T) { + runCreateClusterIntegrationTest(t, "../../tests/integration/create_cluster/ha_shared_zone", "v1alpha2") +} + // TestCreateClusterHASharedZones tests kops create cluster when the master count is bigger than the number of zones func TestCreateClusterHASharedZones(t *testing.T) { runCreateClusterIntegrationTest(t, "../../tests/integration/create_cluster/ha_shared_zones", "v1alpha2") diff --git a/tests/integration/create_cluster/ha_shared_zone/expected-v1alpha2.yaml b/tests/integration/create_cluster/ha_shared_zone/expected-v1alpha2.yaml new file mode 100644 index 0000000000..a3031c4084 --- /dev/null +++ b/tests/integration/create_cluster/ha_shared_zone/expected-v1alpha2.yaml @@ -0,0 +1,140 @@ +apiVersion: kops.k8s.io/v1alpha2 +kind: Cluster +metadata: + creationTimestamp: "2017-01-01T00:00:00Z" + name: ha.example.com +spec: + api: + dns: {} + authorization: + rbac: {} + channel: stable + cloudProvider: aws + configBase: memfs://tests/ha.example.com + containerRuntime: docker + etcdClusters: + - cpuRequest: 200m + etcdMembers: + - instanceGroup: master-us-test-1a-1 + name: "1" + - instanceGroup: master-us-test-1a-2 + name: "2" + - instanceGroup: master-us-test-1a-3 + name: "3" + memoryRequest: 100Mi + name: main + - cpuRequest: 100m + etcdMembers: + - instanceGroup: master-us-test-1a-1 + name: "1" + - instanceGroup: master-us-test-1a-2 + name: "2" + - instanceGroup: master-us-test-1a-3 + name: "3" + memoryRequest: 100Mi + name: events + iam: + allowContainerRegistry: true + legacy: false + kubelet: + anonymousAuth: false + kubernetesApiAccess: + - 0.0.0.0/0 + kubernetesVersion: v1.15.6 + masterPublicName: api.ha.example.com + networkCIDR: 172.20.0.0/16 + networking: + kubenet: {} + nonMasqueradeCIDR: 100.64.0.0/10 + sshAccess: + - 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: ha.example.com + name: master-us-test-1a-1 +spec: + image: kope.io/k8s-1.15-debian-stretch-amd64-hvm-ebs-2020-11-19 + machineType: m3.medium + maxSize: 1 + minSize: 1 + nodeLabels: + kops.k8s.io/instancegroup: master-us-test-1a-1 + 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: ha.example.com + name: master-us-test-1a-2 +spec: + image: kope.io/k8s-1.15-debian-stretch-amd64-hvm-ebs-2020-11-19 + machineType: m3.medium + maxSize: 1 + minSize: 1 + nodeLabels: + kops.k8s.io/instancegroup: master-us-test-1a-2 + 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: ha.example.com + name: master-us-test-1a-3 +spec: + image: kope.io/k8s-1.15-debian-stretch-amd64-hvm-ebs-2020-11-19 + machineType: m3.medium + maxSize: 1 + minSize: 1 + nodeLabels: + kops.k8s.io/instancegroup: master-us-test-1a-3 + 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: ha.example.com + name: nodes-us-test-1a +spec: + image: kope.io/k8s-1.15-debian-stretch-amd64-hvm-ebs-2020-11-19 + machineType: t2.medium + 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/ha_shared_zone/options.yaml b/tests/integration/create_cluster/ha_shared_zone/options.yaml new file mode 100644 index 0000000000..ac96c88291 --- /dev/null +++ b/tests/integration/create_cluster/ha_shared_zone/options.yaml @@ -0,0 +1,6 @@ +ClusterName: ha.example.com +Zones: +- us-test-1a +MasterCount: 3 +CloudProvider: aws +KubernetesVersion: v1.15.6