Skip to content

Commit 4f180b8

Browse files
authored
e2e: Add kubernetes version upgrade test (#141)
1 parent c00943a commit 4f180b8

File tree

11 files changed

+412
-15
lines changed

11 files changed

+412
-15
lines changed

test/e2e/common.go

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,20 @@ import (
4646

4747
// Test suite constants for e2e config variables.
4848
const (
49-
KubernetesVersionManagement = "KUBERNETES_VERSION_MANAGEMENT"
50-
KubernetesVersion = "KUBERNETES_VERSION"
51-
CNIPath = "CNI"
52-
CNIResources = "CNI_RESOURCES"
53-
IPFamily = "IP_FAMILY"
54-
InvalidZoneName = "CLOUDSTACK_INVALID_ZONE_NAME"
55-
InvalidDiskOfferingName = "CLOUDSTACK_INVALID_DISK_OFFERING_NAME"
56-
InvalidNetworkName = "CLOUDSTACK_INVALID_NETWORK_NAME"
57-
InvalidAccountName = "CLOUDSTACK_INVALID_ACCOUNT_NAME"
58-
InvalidDomainName = "CLOUDSTACK_INVALID_DOMAIN_NAME"
59-
InvalidTemplateName = "CLOUDSTACK_INVALID_TEMPLATE_NAME"
60-
InvalidCPOfferingName = "CLOUDSTACK_INVALID_CONTROL_PLANE_MACHINE_OFFERING"
49+
KubernetesVersionManagement = "KUBERNETES_VERSION_MANAGEMENT"
50+
KubernetesVersion = "KUBERNETES_VERSION"
51+
KubernetesVersionUpgradeFrom = "KUBERNETES_VERSION_UPGRADE_FROM"
52+
KubernetesVersionUpgradeTo = "KUBERNETES_VERSION_UPGRADE_TO"
53+
CNIPath = "CNI"
54+
CNIResources = "CNI_RESOURCES"
55+
IPFamily = "IP_FAMILY"
56+
InvalidZoneName = "CLOUDSTACK_INVALID_ZONE_NAME"
57+
InvalidDiskOfferingName = "CLOUDSTACK_INVALID_DISK_OFFERING_NAME"
58+
InvalidNetworkName = "CLOUDSTACK_INVALID_NETWORK_NAME"
59+
InvalidAccountName = "CLOUDSTACK_INVALID_ACCOUNT_NAME"
60+
InvalidDomainName = "CLOUDSTACK_INVALID_DOMAIN_NAME"
61+
InvalidTemplateName = "CLOUDSTACK_INVALID_TEMPLATE_NAME"
62+
InvalidCPOfferingName = "CLOUDSTACK_INVALID_CONTROL_PLANE_MACHINE_OFFERING"
6163
)
6264

6365
const (

test/e2e/config/cloudstack.yaml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ providers:
9595
- sourcePath: "../data/infrastructure-cloudstack/v1beta2/cluster-template-custom-disk-offering.yaml"
9696
- sourcePath: "../data/infrastructure-cloudstack/v1beta2/cluster-template-subdomain.yaml"
9797
- sourcePath: "../data/infrastructure-cloudstack/v1beta2/cluster-template-invalid-ip.yaml"
98+
- sourcePath: "../data/infrastructure-cloudstack/v1beta2/cluster-template-kubernetes-version-upgrade-before.yaml"
99+
- sourcePath: "../data/infrastructure-cloudstack/v1beta2/cluster-template-kubernetes-version-upgrade-after.yaml"
98100
- sourcePath: "../data/shared/v1beta1_provider/metadata.yaml"
99101
versions:
100102
- name: v1.0.0
@@ -107,8 +109,10 @@ providers:
107109
new: "--leader-elect\n - --metrics-bind-addr=:8080"
108110

109111
variables:
110-
KUBERNETES_VERSION_MANAGEMENT: "v1.20.10"
111-
KUBERNETES_VERSION: "v1.20.10"
112+
KUBERNETES_VERSION_MANAGEMENT: "v1.25.3"
113+
KUBERNETES_VERSION: "v1.22.6"
114+
KUBERNETES_VERSION_UPGRADE_FROM: "v1.22.6"
115+
KUBERNETES_VERSION_UPGRADE_TO: "v1.23.3"
112116
CNI: "./data/cni/kindnet.yaml"
113117
IP_FAMILY: "IPv4"
114118
NODE_DRAIN_TIMEOUT: "60s"
@@ -134,7 +138,9 @@ variables:
134138
CLOUDSTACK_IMPOSSIBLE_CONTROL_PLANE_MACHINE_OFFERING: "Impossible Instance"
135139
CLOUDSTACK_WORKER_MACHINE_OFFERING: "Medium Instance"
136140
CLOUDSTACK_IMPOSSIBLE_WORKER_MACHINE_OFFERING: "Impossible Instance"
137-
CLOUDSTACK_TEMPLATE_NAME: kube-v1.20.10/ubuntu-2004
141+
CLOUDSTACK_TEMPLATE_NAME: ubuntu-2004-kube-v1.22.6-kvm
142+
CLOUDSTACK_UPGRADE_FROM_TEMPLATE_NAME: ubuntu-2004-kube-v1.22.6-kvm
143+
CLOUDSTACK_UPGRADE_TO_TEMPLATE_NAME: ubuntu-2004-kube-v1.23.3-kvm
138144
CLOUDSTACK_INVALID_TEMPLATE_NAME: templateXXXX
139145
CLOUDSTACK_SSH_KEY_NAME: CAPCKeyPair6
140146

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
apiVersion: cluster.x-k8s.io/v1beta1
2+
kind: Cluster
3+
metadata:
4+
name: ${CLUSTER_NAME}
5+
spec:
6+
clusterNetwork:
7+
pods:
8+
cidrBlocks:
9+
- 192.168.0.0/16
10+
serviceDomain: "cluster.local"
11+
infrastructureRef:
12+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
13+
kind: CloudStackCluster
14+
name: ${CLUSTER_NAME}
15+
controlPlaneRef:
16+
kind: KubeadmControlPlane
17+
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
18+
name: ${CLUSTER_NAME}-control-plane
19+
---
20+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
21+
kind: CloudStackCluster
22+
metadata:
23+
name: ${CLUSTER_NAME}
24+
spec:
25+
failureDomains:
26+
- name: ${CLOUDSTACK_FD1_NAME}
27+
acsEndpoint:
28+
name: ${CLOUDSTACK_FD1_SECRET_NAME}
29+
namespace: default
30+
zone:
31+
name: ${CLOUDSTACK_ZONE_NAME}
32+
network:
33+
name: ${CLOUDSTACK_NETWORK_NAME}
34+
controlPlaneEndpoint:
35+
host: ${CLUSTER_ENDPOINT_IP}
36+
port: 6443
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
bases:
2+
- ./cluster.yaml
3+
- ./upgrade-md.yaml
4+
- ./upgrade-cp.yaml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
kind: KubeadmControlPlane
2+
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
3+
metadata:
4+
name: ${CLUSTER_NAME}-control-plane
5+
spec:
6+
kubeadmConfigSpec:
7+
initConfiguration:
8+
nodeRegistration:
9+
name: '{{ local_hostname }}'
10+
kubeletExtraArgs:
11+
provider-id: cloudstack:///'{{ ds.meta_data.instance_id }}'
12+
clusterConfiguration:
13+
imageRepository: k8s.gcr.io
14+
joinConfiguration:
15+
nodeRegistration:
16+
name: '{{ local_hostname }}'
17+
kubeletExtraArgs:
18+
provider-id: cloudstack:///'{{ ds.meta_data.instance_id }}'
19+
preKubeadmCommands:
20+
- swapoff -a
21+
machineTemplate:
22+
infrastructureRef:
23+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
24+
kind: CloudStackMachineTemplate
25+
name: ${CLUSTER_NAME}-control-plane-upgraded
26+
replicas: ${CONTROL_PLANE_MACHINE_COUNT}
27+
version: ${KUBERNETES_VERSION_UPGRADE_TO}
28+
---
29+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
30+
kind: CloudStackMachineTemplate
31+
metadata:
32+
name: ${CLUSTER_NAME}-control-plane-upgraded
33+
spec:
34+
template:
35+
spec:
36+
offering:
37+
name: ${CLOUDSTACK_CONTROL_PLANE_MACHINE_OFFERING}
38+
template:
39+
name: ${CLOUDSTACK_UPGRADE_TO_TEMPLATE_NAME}
40+
sshKey: ${CLOUDSTACK_SSH_KEY_NAME}
41+
---
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
apiVersion: cluster.x-k8s.io/v1beta1
2+
kind: MachineDeployment
3+
metadata:
4+
name: "${CLUSTER_NAME}-md-0"
5+
spec:
6+
clusterName: "${CLUSTER_NAME}"
7+
replicas: ${WORKER_MACHINE_COUNT}
8+
selector:
9+
matchLabels: null
10+
template:
11+
spec:
12+
clusterName: "${CLUSTER_NAME}"
13+
version: ${KUBERNETES_VERSION_UPGRADE_TO}
14+
bootstrap:
15+
configRef:
16+
name: "${CLUSTER_NAME}-md-0"
17+
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
18+
kind: KubeadmConfigTemplate
19+
infrastructureRef:
20+
name: "${CLUSTER_NAME}-md-1"
21+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
22+
kind: CloudStackMachineTemplate
23+
---
24+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
25+
kind: CloudStackMachineTemplate
26+
metadata:
27+
name: ${CLUSTER_NAME}-md-1
28+
spec:
29+
template:
30+
spec:
31+
offering:
32+
name: ${CLOUDSTACK_WORKER_MACHINE_OFFERING}
33+
template:
34+
name: ${CLOUDSTACK_UPGRADE_TO_TEMPLATE_NAME}
35+
sshKey: ${CLOUDSTACK_SSH_KEY_NAME}
36+
---
37+
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
38+
kind: KubeadmConfigTemplate
39+
metadata:
40+
name: ${CLUSTER_NAME}-md-0
41+
spec:
42+
template:
43+
spec:
44+
joinConfiguration:
45+
nodeRegistration:
46+
name: '{{ local_hostname }}'
47+
kubeletExtraArgs:
48+
provider-id: "cloudstack:///'{{ ds.meta_data.instance_id }}'"
49+
preKubeadmCommands:
50+
- swapoff -a
51+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
kind: KubeadmControlPlane
2+
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
3+
metadata:
4+
name: ${CLUSTER_NAME}-control-plane
5+
spec:
6+
kubeadmConfigSpec:
7+
initConfiguration:
8+
nodeRegistration:
9+
name: '{{ local_hostname }}'
10+
kubeletExtraArgs:
11+
provider-id: cloudstack:///'{{ ds.meta_data.instance_id }}'
12+
clusterConfiguration:
13+
imageRepository: k8s.gcr.io
14+
joinConfiguration:
15+
nodeRegistration:
16+
name: '{{ local_hostname }}'
17+
kubeletExtraArgs:
18+
provider-id: cloudstack:///'{{ ds.meta_data.instance_id }}'
19+
preKubeadmCommands:
20+
- swapoff -a
21+
machineTemplate:
22+
infrastructureRef:
23+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
24+
kind: CloudStackMachineTemplate
25+
name: ${CLUSTER_NAME}-control-plane
26+
replicas: ${CONTROL_PLANE_MACHINE_COUNT}
27+
version: ${KUBERNETES_VERSION_UPGRADE_FROM}
28+
---
29+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
30+
kind: CloudStackMachineTemplate
31+
metadata:
32+
name: ${CLUSTER_NAME}-control-plane
33+
spec:
34+
template:
35+
spec:
36+
offering:
37+
name: ${CLOUDSTACK_CONTROL_PLANE_MACHINE_OFFERING}
38+
template:
39+
name: ${CLOUDSTACK_UPGRADE_FROM_TEMPLATE_NAME}
40+
sshKey: ${CLOUDSTACK_SSH_KEY_NAME}
41+
---
42+
apiVersion: cluster.x-k8s.io/v1beta1
43+
kind: MachineDeployment
44+
metadata:
45+
name: "${CLUSTER_NAME}-md-0"
46+
spec:
47+
clusterName: "${CLUSTER_NAME}"
48+
replicas: ${WORKER_MACHINE_COUNT}
49+
selector:
50+
matchLabels: null
51+
template:
52+
spec:
53+
clusterName: "${CLUSTER_NAME}"
54+
version: ${KUBERNETES_VERSION_UPGRADE_FROM}
55+
bootstrap:
56+
configRef:
57+
name: "${CLUSTER_NAME}-md-0"
58+
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
59+
kind: KubeadmConfigTemplate
60+
infrastructureRef:
61+
name: "${CLUSTER_NAME}-md-0"
62+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
63+
kind: CloudStackMachineTemplate
64+
---
65+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
66+
kind: CloudStackMachineTemplate
67+
metadata:
68+
name: ${CLUSTER_NAME}-md-0
69+
spec:
70+
template:
71+
spec:
72+
offering:
73+
name: ${CLOUDSTACK_WORKER_MACHINE_OFFERING}
74+
template:
75+
name: ${CLOUDSTACK_UPGRADE_FROM_TEMPLATE_NAME}
76+
sshKey: ${CLOUDSTACK_SSH_KEY_NAME}
77+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
2+
kind: CloudStackCluster
3+
metadata:
4+
name: ${CLUSTER_NAME}
5+
spec:
6+
failureDomains:
7+
- name: ${CLOUDSTACK_FD1_NAME}
8+
acsEndpoint:
9+
name: ${CLOUDSTACK_FD1_SECRET_NAME}
10+
namespace: default
11+
zone:
12+
name: ${CLOUDSTACK_ZONE_NAME}
13+
network:
14+
name: ${CLOUDSTACK_NETWORK_NAME}
15+
controlPlaneEndpoint:
16+
host: ${CLUSTER_ENDPOINT_IP}
17+
port: 6443
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
bases:
3+
- ../bases/cluster-with-kcp.yaml
4+
- ../bases/md.yaml
5+
6+
patchesStrategicMerge:
7+
- ./cloudstack-cluster.yaml
8+
- ./before.yaml

0 commit comments

Comments
 (0)