Skip to content

Commit 187e416

Browse files
committed
test/e2e: Add v1.0=>main clusterctl upgrade test
Signed-off-by: Stefan Büringer [email protected]
1 parent c9dec31 commit 187e416

File tree

11 files changed

+259
-8
lines changed

11 files changed

+259
-8
lines changed

.gitignore

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,7 @@ hack/tools/bin
1111
*.test
1212

1313
# E2E test templates
14-
test/e2e/data/infrastructure-docker/main/cluster-template*.yaml
15-
test/e2e/data/infrastructure-docker/v0.3/cluster-template*.yaml
16-
test/e2e/data/infrastructure-docker/v0.4/cluster-template*.yaml
17-
test/e2e/data/infrastructure-docker/v1.2/cluster-template*.yaml
18-
test/e2e/data/infrastructure-docker/v1.3/cluster-template*.yaml
14+
test/e2e/data/infrastructure-docker/**/cluster-template*.yaml
1915

2016
# E2e test extension deployment
2117
test/e2e/data/test-extension/deployment.yaml

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ generate-modules: ## Run go mod tidy to ensure modules are up to date
472472
cd $(TEST_DIR); go mod tidy
473473

474474
.PHONY: generate-e2e-templates
475-
generate-e2e-templates: $(KUSTOMIZE) $(addprefix generate-e2e-templates-, v0.3 v0.4 v1.2 v1.3 main) ## Generate cluster templates for all versions
475+
generate-e2e-templates: $(KUSTOMIZE) $(addprefix generate-e2e-templates-, v0.3 v0.4 v1.0 v1.2 v1.3 main) ## Generate cluster templates for all versions
476476

477477
DOCKER_TEMPLATES := test/e2e/data/infrastructure-docker
478478

@@ -484,6 +484,10 @@ generate-e2e-templates-v0.3: $(KUSTOMIZE)
484484
generate-e2e-templates-v0.4: $(KUSTOMIZE)
485485
$(KUSTOMIZE) build $(DOCKER_TEMPLATES)/v0.4/cluster-template --load-restrictor LoadRestrictionsNone > $(DOCKER_TEMPLATES)/v0.4/cluster-template.yaml
486486

487+
.PHONY: generate-e2e-templates-v1.0
488+
generate-e2e-templates-v1.0: $(KUSTOMIZE)
489+
$(KUSTOMIZE) build $(DOCKER_TEMPLATES)/v1.0/cluster-template --load-restrictor LoadRestrictionsNone > $(DOCKER_TEMPLATES)/v1.0/cluster-template.yaml
490+
487491
.PHONY: generate-e2e-templates-v1.2
488492
generate-e2e-templates-v1.2: $(KUSTOMIZE)
489493
$(KUSTOMIZE) build $(DOCKER_TEMPLATES)/v1.2/cluster-template --load-restrictor LoadRestrictionsNone > $(DOCKER_TEMPLATES)/v1.2/cluster-template.yaml

docs/release/release-tasks.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ This comes down to changing occurrences of the old version to the new version, e
9595
1. Goal is that we have clusterctl upgrade tests for the latest stable versions of each contract / for each supported branch. For `v1.4` this means:
9696
* v1alpha3: `v0.3`
9797
* v1alpha4: `v0.4`
98-
* v1beta1: `v1.2`, `v1.3` (will change with each new release)
98+
* v1beta1: `v1.0`, `v1.2`, `v1.3` (will change with each new release)
9999
2. Update providers in `docker.yaml`:
100100
1. Add a new `v1.3.0` entry.
101101
2. Remove providers that are not used anymore (for `v1.4` we don't have to remove any).

test/e2e/clusterctl_upgrade_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,30 @@ var _ = Describe("When testing clusterctl upgrades (v0.4=>current)", func() {
5858
})
5959
})
6060

61+
var _ = Describe("When testing clusterctl upgrades (v1.0=>current)", func() {
62+
ClusterctlUpgradeSpec(ctx, func() ClusterctlUpgradeSpecInput {
63+
return ClusterctlUpgradeSpecInput{
64+
E2EConfig: e2eConfig,
65+
ClusterctlConfigPath: clusterctlConfigPath,
66+
BootstrapClusterProxy: bootstrapClusterProxy,
67+
ArtifactFolder: artifactFolder,
68+
SkipCleanup: skipCleanup,
69+
InitWithBinary: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.0.5/clusterctl-{OS}-{ARCH}",
70+
// We have to pin the providers because with `InitWithProvidersContract` the test would
71+
// use the latest version for the contract (which is v1.3.0 for v1beta1).
72+
InitWithCoreProvider: "cluster-api:v1.0.5",
73+
InitWithBootstrapProviders: []string{"kubeadm:v1.0.5"},
74+
InitWithControlPlaneProviders: []string{"kubeadm:v1.0.5"},
75+
InitWithInfrastructureProviders: []string{"docker:v1.0.5"},
76+
// We have to set this to an empty array as clusterctl v1.0 doesn't support
77+
// runtime extension providers. If we don't do this the test will automatically
78+
// try to deploy the latest version of our test-extension from docker.yaml.
79+
InitWithRuntimeExtensionProviders: []string{},
80+
InitWithKubernetesVersion: "v1.23.13",
81+
}
82+
})
83+
})
84+
6185
var _ = Describe("When testing clusterctl upgrades (v1.2=>current)", func() {
6286
ClusterctlUpgradeSpec(ctx, func() ClusterctlUpgradeSpecInput {
6387
return ClusterctlUpgradeSpecInput{

test/e2e/config/docker.yaml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,15 @@ providers:
4949
new: --metrics-addr=:8080
5050
files:
5151
- sourcePath: "../data/shared/v0.4/metadata.yaml"
52+
- name: v1.0.5 # supported release in the v1beta1 series; this is used for v1beta1 --> main clusterctl upgrades test only.
53+
value: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.0.5/core-components.yaml"
54+
type: "url"
55+
contract: v1beta1
56+
replacements:
57+
- old: --metrics-addr=127.0.0.1:8080
58+
new: --metrics-addr=:8080
59+
files:
60+
- sourcePath: "../data/shared/v1.0/metadata.yaml"
5261
- name: v1.2.8 # supported release in the v1beta1 series; this is used for v1beta1 --> main clusterctl upgrades test only.
5362
value: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.2.8/core-components.yaml"
5463
type: "url"
@@ -96,6 +105,15 @@ providers:
96105
new: --metrics-addr=:8080
97106
files:
98107
- sourcePath: "../data/shared/v0.4/metadata.yaml"
108+
- name: v1.0.5 # supported release in the v1beta1 series; this is used for v1beta1 --> main clusterctl upgrades test only.
109+
value: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.0.5/bootstrap-components.yaml"
110+
type: "url"
111+
contract: v1beta1
112+
replacements:
113+
- old: --metrics-addr=127.0.0.1:8080
114+
new: --metrics-addr=:8080
115+
files:
116+
- sourcePath: "../data/shared/v1.0/metadata.yaml"
99117
- name: v1.2.8 # supported release in the v1beta1 series; this is used for v1beta1 --> main clusterctl upgrades test only.
100118
value: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.2.8/bootstrap-components.yaml"
101119
type: "url"
@@ -143,6 +161,15 @@ providers:
143161
new: --metrics-addr=:8080
144162
files:
145163
- sourcePath: "../data/shared/v0.4/metadata.yaml"
164+
- name: v1.0.5 # supported release in the v1beta1 series; this is used for v1beta1 --> main clusterctl upgrades test only.
165+
value: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.0.5/control-plane-components.yaml"
166+
type: "url"
167+
contract: v1beta1
168+
replacements:
169+
- old: --metrics-addr=127.0.0.1:8080
170+
new: --metrics-addr=:8080
171+
files:
172+
- sourcePath: "../data/shared/v1.0/metadata.yaml"
146173
- name: v1.2.8 # supported release in the v1beta1 series; this is used for v1beta1 --> main clusterctl upgrades test only.
147174
value: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.2.8/control-plane-components.yaml"
148175
type: "url"
@@ -192,6 +219,16 @@ providers:
192219
files:
193220
- sourcePath: "../data/shared/v0.4/metadata.yaml"
194221
- sourcePath: "../data/infrastructure-docker/v0.4/cluster-template.yaml"
222+
- name: v1.0.5 # supported release in the v1beta1 series; this is used for v1beta1 --> main clusterctl upgrades test only.
223+
value: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.0.5/infrastructure-components-development.yaml"
224+
type: "url"
225+
contract: v1beta1
226+
replacements:
227+
- old: --metrics-addr=127.0.0.1:8080
228+
new: --metrics-addr=:8080
229+
files:
230+
- sourcePath: "../data/shared/v1.0/metadata.yaml"
231+
- sourcePath: "../data/infrastructure-docker/v1.0/cluster-template.yaml"
195232
- name: v1.2.8 # supported release in the v1beta1 series; this is used for v1beta1 --> main clusterctl upgrades test only.
196233
value: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.2.8/infrastructure-components-development.yaml"
197234
type: "url"

test/e2e/data/infrastructure-docker/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ to the version from the current branch (and check that the workload cluster stil
1010
As of today we have clusterctl upgrade tests for the latest stable versions of each contract / for each supported branch, i.e.:
1111
* v1alpha3: v0.3
1212
* v1alpha4: v0.4
13-
* v1beta1: v1.2, v1.3 (will change with each new release)
13+
* v1beta1: v1.0, v1.2, v1.3 (will change with each new release)
1414

1515
We cannot use the same cluster templates for all Cluster API versions as not each Cluster API version supports
1616
the same API fields. For example `KubeadmControlPlane.spec.rolloutBefore.certificatesExpiryDays` was introduced
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
---
2+
# DockerCluster object referenced by the Cluster object
3+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
4+
kind: DockerCluster
5+
metadata:
6+
name: '${CLUSTER_NAME}'
7+
spec:
8+
failureDomains:
9+
fd1:
10+
controlPlane: true
11+
fd2:
12+
controlPlane: true
13+
fd3:
14+
controlPlane: true
15+
fd4:
16+
controlPlane: false
17+
fd5:
18+
controlPlane: false
19+
fd6:
20+
controlPlane: false
21+
fd7:
22+
controlPlane: false
23+
fd8:
24+
controlPlane: false
25+
---
26+
# Cluster object with
27+
# - Reference to the KubeadmControlPlane object
28+
# - the label cni=${CLUSTER_NAME}-crs-0, so the cluster can be selected by the ClusterResourceSet.
29+
apiVersion: cluster.x-k8s.io/v1beta1
30+
kind: Cluster
31+
metadata:
32+
name: '${CLUSTER_NAME}'
33+
labels:
34+
cni: "${CLUSTER_NAME}-crs-0"
35+
spec:
36+
clusterNetwork:
37+
services:
38+
cidrBlocks: ['${DOCKER_SERVICE_CIDRS}']
39+
pods:
40+
cidrBlocks: ['${DOCKER_POD_CIDRS}']
41+
serviceDomain: '${DOCKER_SERVICE_DOMAIN}'
42+
infrastructureRef:
43+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
44+
kind: DockerCluster
45+
name: '${CLUSTER_NAME}'
46+
controlPlaneRef:
47+
kind: KubeadmControlPlane
48+
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
49+
name: "${CLUSTER_NAME}-control-plane"
50+
---
51+
# DockerMachineTemplate object referenced by the KubeadmControlPlane object
52+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
53+
kind: DockerMachineTemplate
54+
metadata:
55+
name: "${CLUSTER_NAME}-control-plane"
56+
spec:
57+
template:
58+
spec:
59+
extraMounts:
60+
- containerPath: "/var/run/docker.sock"
61+
hostPath: "/var/run/docker.sock"
62+
---
63+
# KubeadmControlPlane referenced by the Cluster object with
64+
# - the label kcp-adoption.step2, because it should be created in the second step of the kcp-adoption test.
65+
kind: KubeadmControlPlane
66+
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
67+
metadata:
68+
name: "${CLUSTER_NAME}-control-plane"
69+
labels:
70+
kcp-adoption.step2: ""
71+
spec:
72+
replicas: ${CONTROL_PLANE_MACHINE_COUNT}
73+
machineTemplate:
74+
infrastructureRef:
75+
kind: DockerMachineTemplate
76+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
77+
name: "${CLUSTER_NAME}-control-plane"
78+
kubeadmConfigSpec:
79+
clusterConfiguration:
80+
controllerManager:
81+
extraArgs: {enable-hostpath-provisioner: 'true'}
82+
apiServer:
83+
# host.docker.internal is required by kubetest when running on MacOS because of the way ports are proxied.
84+
certSANs: [localhost, 127.0.0.1, 0.0.0.0, host.docker.internal]
85+
initConfiguration:
86+
nodeRegistration:
87+
criSocket: unix:///var/run/containerd/containerd.sock
88+
kubeletExtraArgs:
89+
eviction-hard: 'nodefs.available<0%,nodefs.inodesFree<0%,imagefs.available<0%'
90+
joinConfiguration:
91+
nodeRegistration:
92+
criSocket: unix:///var/run/containerd/containerd.sock
93+
kubeletExtraArgs:
94+
eviction-hard: 'nodefs.available<0%,nodefs.inodesFree<0%,imagefs.available<0%'
95+
version: "${KUBERNETES_VERSION}"
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
# ConfigMap object referenced by the ClusterResourceSet object and with
3+
# the CNI resource defined in the test config file
4+
apiVersion: v1
5+
kind: ConfigMap
6+
metadata:
7+
name: "cni-${CLUSTER_NAME}-crs-0"
8+
data: ${CNI_RESOURCES}
9+
binaryData:
10+
---
11+
# ClusterResourceSet object with
12+
# a selector that targets all the Cluster with label cni=${CLUSTER_NAME}-crs-0
13+
apiVersion: addons.cluster.x-k8s.io/v1beta1
14+
kind: ClusterResourceSet
15+
metadata:
16+
name: "${CLUSTER_NAME}-crs-0"
17+
spec:
18+
strategy: ApplyOnce
19+
clusterSelector:
20+
matchLabels:
21+
cni: "${CLUSTER_NAME}-crs-0"
22+
resources:
23+
- name: "cni-${CLUSTER_NAME}-crs-0"
24+
kind: ConfigMap
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
# DockerMachineTemplate referenced by the MachineDeployment and with
3+
# - extraMounts for the docker sock, thus allowing self-hosting test
4+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
5+
kind: DockerMachineTemplate
6+
metadata:
7+
name: "${CLUSTER_NAME}-md-0"
8+
spec:
9+
template:
10+
spec:
11+
extraMounts:
12+
- containerPath: "/var/run/docker.sock"
13+
hostPath: "/var/run/docker.sock"
14+
---
15+
# KubeadmConfigTemplate referenced by the MachineDeployment
16+
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
17+
kind: KubeadmConfigTemplate
18+
metadata:
19+
name: "${CLUSTER_NAME}-md-0"
20+
spec:
21+
template:
22+
spec:
23+
joinConfiguration:
24+
nodeRegistration:
25+
criSocket: unix:///var/run/containerd/containerd.sock
26+
kubeletExtraArgs:
27+
eviction-hard: 'nodefs.available<0%,nodefs.inodesFree<0%,imagefs.available<0%'
28+
---
29+
# MachineDeployment object
30+
apiVersion: cluster.x-k8s.io/v1beta1
31+
kind: MachineDeployment
32+
metadata:
33+
name: "${CLUSTER_NAME}-md-0"
34+
spec:
35+
clusterName: "${CLUSTER_NAME}"
36+
replicas: ${WORKER_MACHINE_COUNT}
37+
selector:
38+
matchLabels:
39+
template:
40+
spec:
41+
clusterName: "${CLUSTER_NAME}"
42+
version: "${KUBERNETES_VERSION}"
43+
bootstrap:
44+
configRef:
45+
name: "${CLUSTER_NAME}-md-0"
46+
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
47+
kind: KubeadmConfigTemplate
48+
infrastructureRef:
49+
name: "${CLUSTER_NAME}-md-0"
50+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
51+
kind: DockerMachineTemplate
52+
failureDomain: fd4
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
bases:
2+
- ../bases/cluster-with-kcp.yaml
3+
- ../bases/md.yaml
4+
- ../bases/crs.yaml

0 commit comments

Comments
 (0)