Skip to content

Commit afbe65a

Browse files
authored
Merge pull request #2793 from Nordix/lentzi90/topology-e2e
🌱 E2E: Add quick-start test using ClusterClass
2 parents 9128301 + deaa56e commit afbe65a

File tree

12 files changed

+224
-41
lines changed

12 files changed

+224
-41
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: 85 additions & 27 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,18 @@ spec:
211256
nodeRegistration:
212257
name: $${COREOS_OPENSTACK_HOSTNAME}
213258
kubeletExtraArgs:
214-
provider-id: openstack:///$${COREOS_OPENSTACK_INSTANCE_UUID}
259+
- name: cloud-provider
260+
value: external
261+
- name: provider-id
262+
value: openstack:///$${COREOS_OPENSTACK_INSTANCE_UUID}
215263
joinConfiguration:
216264
nodeRegistration:
217265
name: $${COREOS_OPENSTACK_HOSTNAME}
218266
kubeletExtraArgs:
219-
provider-id: openstack:///$${COREOS_OPENSTACK_INSTANCE_UUID}
267+
- name: cloud-provider
268+
value: external
269+
- name: provider-id
270+
value: openstack:///$${COREOS_OPENSTACK_INSTANCE_UUID}
220271
format: ignition
221272
ignition:
222273
containerLinuxConfig:
@@ -233,16 +284,16 @@ spec:
233284
mode: 0644
234285
contents:
235286
remote:
236-
url: https://github.com/flatcar/sysext-bakery/releases/download/latest/kubernetes-{{ $minor }}.conf
287+
url: https://extensions.flatcar.org/extensions/kubernetes/kubernetes-{{ $minor }}.conf
237288
- path: /etc/sysupdate.d/noop.conf
238289
mode: 0644
239290
contents:
240291
remote:
241-
url: https://github.com/flatcar/sysext-bakery/releases/download/latest/noop.conf
292+
url: https://extensions.flatcar.org/extensions/noop.conf
242293
- path: /opt/extensions/kubernetes/kubernetes-{{ .builtin.controlPlane.version }}-x86-64.raw
243294
contents:
244295
remote:
245-
url: https://github.com/flatcar/sysext-bakery/releases/download/latest/kubernetes-{{ .builtin.controlPlane.version }}-x86-64.raw
296+
url: https://extensions.flatcar.org/extensions/kubernetes-{{ .builtin.controlPlane.version }}-x86-64.raw
246297
systemd:
247298
units:
248299
- name: systemd-sysupdate.service
@@ -277,7 +328,7 @@ spec:
277328
[Service]
278329
EnvironmentFile=/run/metadata/flatcar
279330
- selector:
280-
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
331+
apiVersion: bootstrap.cluster.x-k8s.io/v1beta2
281332
kind: KubeadmConfigTemplate
282333
matchResources:
283334
machineDeploymentClass:
@@ -297,7 +348,10 @@ spec:
297348
nodeRegistration:
298349
name: $${COREOS_OPENSTACK_HOSTNAME}
299350
kubeletExtraArgs:
300-
provider-id: openstack:///$${COREOS_OPENSTACK_INSTANCE_UUID}
351+
- name: cloud-provider
352+
value: external
353+
- name: provider-id
354+
value: openstack:///$${COREOS_OPENSTACK_INSTANCE_UUID}
301355
format: ignition
302356
ignition:
303357
containerLinuxConfig:
@@ -314,16 +368,16 @@ spec:
314368
mode: 0644
315369
contents:
316370
remote:
317-
url: https://github.com/flatcar/sysext-bakery/releases/download/latest/kubernetes-{{ $minor }}.conf
371+
url: https://extensions.flatcar.org/extensions/kubernetes/kubernetes-{{ $minor }}.conf
318372
- path: /etc/sysupdate.d/noop.conf
319373
mode: 0644
320374
contents:
321375
remote:
322-
url: https://github.com/flatcar/sysext-bakery/releases/download/latest/noop.conf
376+
url: https://extensions.flatcar.org/extensions/noop.conf
323377
- path: /opt/extensions/kubernetes/kubernetes-{{ .builtin.machineDeployment.version }}-x86-64.raw
324378
contents:
325379
remote:
326-
url: https://github.com/flatcar/sysext-bakery/releases/download/latest/kubernetes-{{ .builtin.machineDeployment.version }}-x86-64.raw
380+
url: https://extensions.flatcar.org/extensions/kubernetes-{{ .builtin.machineDeployment.version }}-x86-64.raw
327381
systemd:
328382
units:
329383
- name: systemd-sysupdate.service
@@ -365,7 +419,6 @@ metadata:
365419
spec:
366420
template:
367421
spec:
368-
files: []
369422
joinConfiguration:
370423
nodeRegistration:
371424
kubeletExtraArgs:
@@ -382,6 +435,11 @@ metadata:
382435
spec:
383436
template:
384437
spec:
438+
rollout:
439+
strategy:
440+
type: RollingUpdate
441+
rollingUpdate:
442+
maxSurge: 1
385443
kubeadmConfigSpec:
386444
clusterConfiguration:
387445
controllerManager:
@@ -454,8 +512,8 @@ spec:
454512
spec:
455513
flavor: ${OPENSTACK_CONTROL_PLANE_MACHINE_FLAVOR:=m1.medium}
456514
image:
457-
filter:
458-
name: overridden-by-patch
515+
imageRef:
516+
name: node-image
459517
sshKeyName: ${OPENSTACK_SSH_KEY_NAME:=""}
460518
---
461519
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
@@ -467,6 +525,6 @@ spec:
467525
spec:
468526
flavor: ${OPENSTACK_NODE_MACHINE_FLAVOR:=m1.small}
469527
image:
470-
filter:
471-
name: overridden-by-patch
528+
imageRef:
529+
name: node-image
472530
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
@@ -247,6 +248,7 @@ variables:
247248
E2E_IMAGE_URL: "http://10.0.3.15/capo-e2e-image.tar"
248249
# The default user for SSH connections from bastion to machines
249250
SSH_USER_MACHINE: "ubuntu"
251+
CLUSTER_TOPOLOGY: "true"
250252
EXP_KUBEADM_BOOTSTRAP_FORMAT_IGNITION: "true"
251253
# The Flatcar image produced by the image-builder
252254
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:
File renamed without changes.
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:=""}

0 commit comments

Comments
 (0)