Skip to content

Commit ce60a04

Browse files
committed
E2E: Add quick-start test using ClusterClass
This commit also fixes a few remaining v1beta1 references in the ClusterClass and adds support for setting images through imageRef. Signed-off-by: Lennart Jern <[email protected]>
1 parent b9fa78b commit ce60a04

File tree

12 files changed

+212
-35
lines changed

12 files changed

+212
-35
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ e2e-templates: $(addprefix $(E2E_NO_ARTIFACT_TEMPLATES_DIR)/, \
188188
cluster-template-multi-network.yaml \
189189
cluster-template-without-lb.yaml \
190190
cluster-template.yaml \
191+
cluster-template-topology.yaml \
191192
cluster-template-flatcar.yaml \
192193
cluster-template-k8s-upgrade.yaml \
193194
cluster-template-flatcar-sysext.yaml \
Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,20 @@
1-
apiVersion: cluster.x-k8s.io/v1beta1
1+
apiVersion: cluster.x-k8s.io/v1beta2
22
kind: Cluster
33
metadata:
44
name: ${CLUSTER_NAME}
55
spec:
66
topology:
7-
class: dev-test
8-
version: ${KUBERNETES_VERSION}
7+
classRef:
8+
name: dev-test
99
controlPlane:
1010
replicas: ${CONTROL_PLANE_MACHINE_COUNT}
11-
workers:
12-
machineDeployments:
13-
- class: default-worker
14-
name: md-0
15-
replicas: ${WORKER_MACHINE_COUNT}
1611
variables:
1712
- name: identityRef
1813
value:
19-
name: ${CLOUD_CONFIG_SECRET:=dev-test-cloud-config}
2014
cloudName: ${OPENSTACK_CLOUD:=capo-e2e}
21-
- name: imageName
22-
value: ${IMAGE_NAME:=flatcar_production}
15+
name: ${CLOUD_CONFIG_SECRET:=dev-test-cloud-config}
16+
- name: imageRef
17+
value: ${IMAGE_REF:=node-image}
2318
- name: addImageVersion
2419
value: ${ADD_IMAGE_VERSION:=false}
2520
- name: injectIgnitionSysext
@@ -32,6 +27,12 @@ spec:
3227
spec:
3328
flavor: ${OPENSTACK_BASTION_FLAVOR:=m1.small}
3429
image:
35-
filter:
30+
imageRef:
3631
name: ${OPENSTACK_BASTION_IMAGE_NAME:=ubuntu-24.04}
3732
sshKeyName: ${OPENSTACK_SSH_KEY_NAME:=""}
33+
version: ${KUBERNETES_VERSION}
34+
workers:
35+
machineDeployments:
36+
- class: default-worker
37+
name: md-0
38+
replicas: ${WORKER_MACHINE_COUNT}

templates/clusterclass-dev-test.yaml

Lines changed: 73 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ metadata:
55
spec:
66
controlPlane:
77
templateRef:
8-
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
8+
apiVersion: controlplane.cluster.x-k8s.io/v1beta2
99
kind: KubeadmControlPlaneTemplate
1010
name: dev-test-control-plane
1111
machineInfrastructure:
@@ -23,7 +23,7 @@ spec:
2323
- class: default-worker
2424
bootstrap:
2525
templateRef:
26-
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
26+
apiVersion: bootstrap.cluster.x-k8s.io/v1beta2
2727
kind: KubeadmConfigTemplate
2828
name: dev-test-default-worker-bootstraptemplate
2929
infrastructure:
@@ -53,16 +53,22 @@ spec:
5353
type: string
5454
description: |
5555
The base name of the OpenStack image that is used for creating the servers.
56-
This will be combined with the k8s version to create the full name. E.g. imageName-v1.31.2.
57-
default: "ubuntu-2404-kube"
5856
- name: addImageVersion
5957
required: false
6058
schema:
6159
openAPIV3Schema:
6260
type: boolean
6361
description: |
64-
Add a suffix with the Kubernetes version to the imageName. E.g. imageName-v1.32.2.
62+
Add a suffix with the Kubernetes version to the imageName or imageRef. E.g. imageName-v1.32.2.
6563
default: true
64+
- name: imageRef
65+
required: false
66+
schema:
67+
openAPIV3Schema:
68+
type: string
69+
description: |
70+
The name of the ORC Image object that is used for creating the servers.
71+
default: "node-image"
6672
- name: injectIgnitionSysext
6773
required: false
6874
schema:
@@ -109,6 +115,12 @@ spec:
109115
name:
110116
type: string
111117
description: "Name of the image to use for bastion"
118+
imageRef:
119+
type: object
120+
properties:
121+
name:
122+
type: string
123+
description: "Name of the ORC Image to use for bastion"
112124
sshKeyName:
113125
type: string
114126
description: "SSH key pair name for bastion access"
@@ -120,20 +132,23 @@ spec:
120132
type: string
121133
description: "Availability zone for the bastion host"
122134
patches:
123-
- name: image
124-
description: "Sets the OpenStack image that is used for creating the servers."
135+
- name: imageName
136+
description: "Sets the OpenStack image that is used for creating the servers using a name filter."
137+
enabledIf: "{{ if .imageName }}true{{ end }}"
125138
definitions:
126139
- selector:
127140
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
128141
kind: OpenStackMachineTemplate
129142
matchResources:
130143
controlPlane: true
131144
jsonPatches:
145+
- op: remove
146+
path: /spec/template/spec/image/imageRef
132147
- op: add
133-
path: /spec/template/spec/image/filter/name
148+
path: /spec/template/spec/image/filter
134149
valueFrom:
135150
template: |
136-
{{ .imageName }}{{ if .addImageVersion }}-{{ .builtin.controlPlane.version }}{{ end }}
151+
name: {{ .imageName }}{{ if .addImageVersion }}-{{ .builtin.controlPlane.version }}{{ end }}
137152
- selector:
138153
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
139154
kind: OpenStackMachineTemplate
@@ -142,11 +157,41 @@ spec:
142157
names:
143158
- default-worker
144159
jsonPatches:
160+
- op: remove
161+
path: /spec/template/spec/image/imageRef
145162
- op: add
146-
path: /spec/template/spec/image/filter/name
163+
path: /spec/template/spec/image/filter
147164
valueFrom:
148165
template: |
149-
{{ .imageName }}{{ if .addImageVersion }}-{{ .builtin.machineDeployment.version }}{{ end }}
166+
name: {{ .imageName }}{{ if .addImageVersion }}-{{ .builtin.machineDeployment.version }}{{ end }}
167+
- name: imageRef
168+
description: "Sets the OpenStack image that is used for creating the servers using an ORC Image reference."
169+
enabledIf: "{{ if .imageRef }}true{{ end }}"
170+
definitions:
171+
- selector:
172+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
173+
kind: OpenStackMachineTemplate
174+
matchResources:
175+
controlPlane: true
176+
jsonPatches:
177+
- op: replace
178+
path: /spec/template/spec/image/imageRef/name
179+
valueFrom:
180+
template: |
181+
{{ .imageRef }}{{ if .addImageVersion }}-{{ .builtin.controlPlane.version }}{{ end }}
182+
- selector:
183+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
184+
kind: OpenStackMachineTemplate
185+
matchResources:
186+
machineDeploymentClass:
187+
names:
188+
- default-worker
189+
jsonPatches:
190+
- op: replace
191+
path: /spec/template/spec/image/imageRef/name
192+
valueFrom:
193+
template: |
194+
{{ .imageRef }}{{ if .addImageVersion }}-{{ .builtin.controlPlane.version }}{{ end }}
150195
- name: identityRef
151196
description: "Sets the OpenStack identity reference."
152197
definitions:
@@ -193,7 +238,7 @@ spec:
193238
enabledIf: "{{ .injectIgnitionSysext }}"
194239
definitions:
195240
- selector:
196-
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
241+
apiVersion: controlplane.cluster.x-k8s.io/v1beta2
197242
kind: KubeadmControlPlaneTemplate
198243
matchResources:
199244
controlPlane: true
@@ -211,12 +256,14 @@ spec:
211256
nodeRegistration:
212257
name: $${COREOS_OPENSTACK_HOSTNAME}
213258
kubeletExtraArgs:
214-
provider-id: openstack:///$${COREOS_OPENSTACK_INSTANCE_UUID}
259+
- name: provider-id
260+
value: openstack:///$${COREOS_OPENSTACK_INSTANCE_UUID}
215261
joinConfiguration:
216262
nodeRegistration:
217263
name: $${COREOS_OPENSTACK_HOSTNAME}
218264
kubeletExtraArgs:
219-
provider-id: openstack:///$${COREOS_OPENSTACK_INSTANCE_UUID}
265+
- name: provider-id
266+
value: openstack:///$${COREOS_OPENSTACK_INSTANCE_UUID}
220267
format: ignition
221268
ignition:
222269
containerLinuxConfig:
@@ -277,7 +324,7 @@ spec:
277324
[Service]
278325
EnvironmentFile=/run/metadata/flatcar
279326
- selector:
280-
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
327+
apiVersion: bootstrap.cluster.x-k8s.io/v1beta2
281328
kind: KubeadmConfigTemplate
282329
matchResources:
283330
machineDeploymentClass:
@@ -297,7 +344,8 @@ spec:
297344
nodeRegistration:
298345
name: $${COREOS_OPENSTACK_HOSTNAME}
299346
kubeletExtraArgs:
300-
provider-id: openstack:///$${COREOS_OPENSTACK_INSTANCE_UUID}
347+
- name: provider-id
348+
value: openstack:///$${COREOS_OPENSTACK_INSTANCE_UUID}
301349
format: ignition
302350
ignition:
303351
containerLinuxConfig:
@@ -365,7 +413,6 @@ metadata:
365413
spec:
366414
template:
367415
spec:
368-
files: []
369416
joinConfiguration:
370417
nodeRegistration:
371418
kubeletExtraArgs:
@@ -382,6 +429,11 @@ metadata:
382429
spec:
383430
template:
384431
spec:
432+
rollout:
433+
strategy:
434+
type: RollingUpdate
435+
rollingUpdate:
436+
maxSurge: 1
385437
kubeadmConfigSpec:
386438
clusterConfiguration:
387439
controllerManager:
@@ -454,8 +506,8 @@ spec:
454506
spec:
455507
flavor: ${OPENSTACK_CONTROL_PLANE_MACHINE_FLAVOR:=m1.medium}
456508
image:
457-
filter:
458-
name: overridden-by-patch
509+
imageRef:
510+
name: node-image
459511
sshKeyName: ${OPENSTACK_SSH_KEY_NAME:=""}
460512
---
461513
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
@@ -467,6 +519,6 @@ spec:
467519
spec:
468520
flavor: ${OPENSTACK_NODE_MACHINE_FLAVOR:=m1.small}
469521
image:
470-
filter:
471-
name: overridden-by-patch
522+
imageRef:
523+
name: node-image
472524
sshKeyName: ${OPENSTACK_SSH_KEY_NAME:=""}

test/e2e/data/e2e_conf.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ providers:
171171
- sourcePath: "./infrastructure-openstack-no-artifact/cluster-template.yaml"
172172
- sourcePath: "./infrastructure-openstack-no-artifact/cluster-template-without-lb.yaml"
173173
- sourcePath: "./infrastructure-openstack-no-artifact/cluster-template-cluster-identity.yaml"
174+
- sourcePath: "../../../templates/clusterclass-dev-test.yaml"
174175
replacements:
175176
- old: gcr.io/k8s-staging-capi-openstack/capi-openstack-controller:dev
176177
new: gcr.io/k8s-staging-capi-openstack/capi-openstack-controller:e2e
@@ -246,6 +247,7 @@ variables:
246247
E2E_IMAGE_URL: "http://10.0.3.15/capo-e2e-image.tar"
247248
# The default user for SSH connections from bastion to machines
248249
SSH_USER_MACHINE: "ubuntu"
250+
CLUSTER_TOPOLOGY: "true"
249251
EXP_KUBEADM_BOOTSTRAP_FORMAT_IGNITION: "true"
250252
# The Flatcar image produced by the image-builder
251253
OPENSTACK_FLATCAR_IMAGE_NAME: "flatcar-stable-4152.2.3-kube-v1.33.1"

test/e2e/data/kustomize/components/common/kustomization.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
apiVersion: kustomize.config.k8s.io/v1alpha1
22
kind: Component
3-
resources:
4-
- images.yaml
3+
components:
4+
- ../images
55
patches:
66
# Set AZ and enable bastion
77
- target:
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
apiVersion: kustomize.config.k8s.io/v1alpha1
2+
kind: Component
3+
resources:
4+
- images.yaml
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Rather than editing the cluster-template, which include already variables,
2+
# we simply create a new cluster-template with the correct variables for e2e.
3+
apiVersion: cluster.x-k8s.io/v1beta2
4+
kind: Cluster
5+
metadata:
6+
name: ${CLUSTER_NAME}
7+
spec:
8+
topology:
9+
classRef:
10+
name: dev-test
11+
version: ${KUBERNETES_VERSION}
12+
controlPlane:
13+
replicas: ${CONTROL_PLANE_MACHINE_COUNT}
14+
workers:
15+
machineDeployments:
16+
- class: default-worker
17+
name: md-0
18+
replicas: ${WORKER_MACHINE_COUNT}
19+
variables:
20+
- name: identityRef
21+
value:
22+
name: ${CLUSTER_NAME}-cloud-config
23+
cloudName: ${OPENSTACK_CLOUD}
24+
- name: imageRef
25+
value: node-image
26+
- name: addImageVersion
27+
value: false
28+
- name: injectIgnitionSysext
29+
value: true
30+
- name: allowedCIDRs
31+
value: ${OPENSTACK_API_SERVER_ALLOWED_CIDRS:=[]}
32+
- name: bastion
33+
value:
34+
enabled: ${OPENSTACK_BASTION_ENABLED:=false}
35+
spec:
36+
flavor: ${OPENSTACK_BASTION_FLAVOR:=m1.small}
37+
image:
38+
imageRef:
39+
name: bastion-image
40+
sshKeyName: ${OPENSTACK_SSH_KEY_NAME:=""}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
apiVersion: kustomize.config.k8s.io/v1beta1
2+
kind: Kustomization
3+
4+
resources:
5+
- cluster.yaml
6+
- secret.yaml
7+
8+
components:
9+
- ../components/images
10+
- ../components/cluster-resource-sets
11+
12+
patches:
13+
- target:
14+
group: openstack.k-orc.cloud
15+
version: v1alpha1
16+
kind: Image
17+
name: node-image
18+
patch: |-
19+
- op: replace
20+
path: /spec/resource/name
21+
value: ${FLATCAR_IMAGE_NAME}
22+
- op: replace
23+
path: /spec/resource/content/download/url
24+
value: ${FLATCAR_IMAGE_URL}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
apiVersion: v1
2+
data:
3+
cacert: ${OPENSTACK_CLOUD_CACERT_B64}
4+
clouds.yaml: ${OPENSTACK_CLOUD_YAML_B64}
5+
kind: Secret
6+
metadata:
7+
labels:
8+
clusterctl.cluster.x-k8s.io/move: "true"
9+
name: ${CLUSTER_NAME}-cloud-config

0 commit comments

Comments
 (0)