Skip to content

Commit 6c3219c

Browse files
Switch CAPD+RKE2 e2e template to clusterclass
Signed-off-by: Alexandr Demicev <[email protected]>
1 parent fed6159 commit 6c3219c

File tree

5 files changed

+147
-104
lines changed

5 files changed

+147
-104
lines changed

test/e2e/config/operator.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ variables:
4242
KUBERNETES_VERSION: "v1.31.4"
4343
KUBERNETES_MANAGEMENT_VERSION: "v1.31.4"
4444
RKE2_VERSION: "v1.31.4+rke2r1"
45+
RKE2_CNI: "none"
4546

4647
# AWS Configuration
4748
AWS_REGION: "eu-west-2"

test/e2e/data/cluster-templates/aws-ec2-kubeadm.yaml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ spec:
1313
cidrBlocks:
1414
- 192.168.0.0/16
1515
topology:
16-
class: turtles
16+
class: ${CLUSTER_NAME}
1717
controlPlane:
1818
replicas: ${CONTROL_PLANE_MACHINE_COUNT}
1919
variables:
@@ -35,24 +35,24 @@ spec:
3535
apiVersion: cluster.x-k8s.io/v1beta1
3636
kind: ClusterClass
3737
metadata:
38-
name: turtles
38+
name: ${CLUSTER_NAME}
3939
namespace: ${NAMESPACE}
4040
spec:
4141
controlPlane:
4242
ref:
4343
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
4444
kind: KubeadmControlPlaneTemplate
45-
name: turtles-control-plane
45+
name: ${CLUSTER_NAME}-control-plane
4646
machineInfrastructure:
4747
ref:
4848
kind: AWSMachineTemplate
4949
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
50-
name: turtles-control-plane
50+
name: ${CLUSTER_NAME}-control-plane
5151
infrastructure:
5252
ref:
5353
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
5454
kind: AWSClusterTemplate
55-
name: turtles
55+
name: ${CLUSTER_NAME}
5656
workers:
5757
machineDeployments:
5858
- class: default-worker
@@ -61,12 +61,12 @@ spec:
6161
ref:
6262
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
6363
kind: KubeadmConfigTemplate
64-
name: turtles-worker-bootstraptemplate
64+
name: ${CLUSTER_NAME}-worker-bootstraptemplate
6565
infrastructure:
6666
ref:
6767
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
6868
kind: AWSMachineTemplate
69-
name: turtles-worker-machinetemplate
69+
name: ${CLUSTER_NAME}-worker-machinetemplate
7070
variables:
7171
- name: region
7272
required: true
@@ -160,7 +160,7 @@ spec:
160160
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
161161
kind: AWSClusterTemplate
162162
metadata:
163-
name: turtles
163+
name: ${CLUSTER_NAME}
164164
namespace: ${NAMESPACE}
165165
spec:
166166
template:
@@ -172,7 +172,7 @@ spec:
172172
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
173173
kind: KubeadmControlPlaneTemplate
174174
metadata:
175-
name: turtles-control-plane
175+
name: ${CLUSTER_NAME}-control-plane
176176
namespace: ${NAMESPACE}
177177
spec:
178178
template:
@@ -199,7 +199,7 @@ spec:
199199
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
200200
kind: AWSMachineTemplate
201201
metadata:
202-
name: turtles-control-plane
202+
name: ${CLUSTER_NAME}-control-plane
203203
namespace: ${NAMESPACE}
204204
spec:
205205
template:
@@ -213,7 +213,7 @@ spec:
213213
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
214214
kind: AWSMachineTemplate
215215
metadata:
216-
name: turtles-worker-machinetemplate
216+
name: ${CLUSTER_NAME}-worker-machinetemplate
217217
namespace: ${NAMESPACE}
218218
spec:
219219
template:
@@ -227,7 +227,7 @@ spec:
227227
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
228228
kind: KubeadmConfigTemplate
229229
metadata:
230-
name: "turtles-worker-bootstraptemplate"
230+
name: "${CLUSTER_NAME}-worker-bootstraptemplate"
231231
namespace: ${NAMESPACE}
232232
spec:
233233
template:

test/e2e/data/cluster-templates/docker-rke2.yaml

Lines changed: 133 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,3 @@
1-
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
2-
kind: DockerCluster
3-
metadata:
4-
name: ${CLUSTER_NAME}
5-
namespace: ${NAMESPACE}
6-
annotations:
7-
"helm.sh/resource-policy": keep
8-
spec:
9-
loadBalancer:
10-
customHAProxyConfigTemplateRef:
11-
name: ${CLUSTER_NAME}-lb-config
12-
---
131
apiVersion: cluster.x-k8s.io/v1beta1
142
kind: Cluster
153
metadata:
@@ -18,7 +6,7 @@ metadata:
186
annotations:
197
cluster-api.cattle.io/upstream-system-agent: "true"
208
labels:
21-
cni: ${CLUSTER_NAME}-crs-0
9+
cni: kindnet
2210
spec:
2311
clusterNetwork:
2412
pods:
@@ -28,72 +16,152 @@ spec:
2816
cidrBlocks:
2917
- 10.10.0.0/16
3018
serviceDomain: cluster.local
31-
controlPlaneRef:
32-
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
33-
kind: RKE2ControlPlane
34-
name: ${CLUSTER_NAME}-control-plane
35-
infrastructureRef:
36-
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
37-
kind: DockerCluster
38-
name: ${CLUSTER_NAME}
19+
topology:
20+
class: ${CLUSTER_NAME}
21+
controlPlane:
22+
replicas: ${CONTROL_PLANE_MACHINE_COUNT}
23+
variables:
24+
- name: rke2CNI
25+
value: ${RKE2_CNI}
26+
- name: dockerImage
27+
value: kindest/node:${KUBERNETES_VERSION}
28+
version: ${RKE2_VERSION}
29+
workers:
30+
machineDeployments:
31+
- class: default-worker
32+
name: md-0
33+
replicas: ${WORKER_MACHINE_COUNT}
34+
---
35+
apiVersion: cluster.x-k8s.io/v1beta1
36+
kind: ClusterClass
37+
metadata:
38+
name: ${CLUSTER_NAME}
39+
namespace: ${NAMESPACE}
40+
spec:
41+
infrastructure:
42+
ref:
43+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
44+
kind: DockerClusterTemplate
45+
name: ${CLUSTER_NAME}
46+
controlPlane:
47+
ref:
48+
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
49+
kind: RKE2ControlPlaneTemplate
50+
name: ${CLUSTER_NAME}-control-plane
51+
machineInfrastructure:
52+
ref:
53+
kind: DockerMachineTemplate
54+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
55+
name: ${CLUSTER_NAME}-control-plane
56+
workers:
57+
machineDeployments:
58+
- class: default-worker
59+
template:
60+
bootstrap:
61+
ref:
62+
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
63+
kind: RKE2ConfigTemplate
64+
name: ${CLUSTER_NAME}-worker-bootstraptemplate
65+
infrastructure:
66+
ref:
67+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
68+
kind: DockerMachineTemplate
69+
name: ${CLUSTER_NAME}-worker-machinetemplate
70+
variables:
71+
- name: rke2CNI
72+
required: true
73+
schema:
74+
openAPIV3Schema:
75+
type: string
76+
- name: dockerImage
77+
required: true
78+
schema:
79+
openAPIV3Schema:
80+
type: string
81+
patches:
82+
- name: rke2CNI
83+
definitions:
84+
- selector:
85+
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
86+
kind: RKE2ControlPlaneTemplate
87+
matchResources:
88+
controlPlane: true
89+
jsonPatches:
90+
- op: add
91+
path: /spec/template/spec/serverConfig/cni
92+
valueFrom:
93+
variable: rke2CNI
94+
- name: dockerImage
95+
definitions:
96+
- selector:
97+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
98+
kind: DockerMachineTemplate
99+
matchResources:
100+
controlPlane: true
101+
machineDeploymentClass:
102+
names:
103+
- default-worker
104+
jsonPatches:
105+
- op: add
106+
path: /spec/template/spec/customImage
107+
valueFrom:
108+
variable: dockerImage
39109
---
40110
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
41-
kind: DockerMachineTemplate
111+
kind: DockerClusterTemplate
42112
metadata:
43-
name: ${CLUSTER_NAME}-control-plane
113+
name: ${CLUSTER_NAME}
44114
namespace: ${NAMESPACE}
45115
spec:
46-
template:
47-
spec:
48-
customImage: kindest/node:${KUBERNETES_VERSION}
49-
bootstrapTimeout: 15m
116+
loadBalancer:
117+
customHAProxyConfigTemplateRef:
118+
name: ${CLUSTER_NAME}-lb-config
50119
---
51120
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
52-
kind: RKE2ControlPlane
121+
kind: RKE2ControlPlaneTemplate
53122
metadata:
54123
name: ${CLUSTER_NAME}-control-plane
55124
namespace: ${NAMESPACE}
56125
spec:
57-
replicas: ${CONTROL_PLANE_MACHINE_COUNT}
58-
version: ${RKE2_VERSION}
59-
rolloutStrategy:
60-
rollingUpdate:
61-
maxSurge: 1
62-
type: RollingUpdate
63-
serverConfig:
64-
cloudProviderName: external
65-
cni: ${RKE2_CNI}
66-
kubeAPIServer:
67-
extraArgs:
68-
- --anonymous-auth=true
69-
disableComponents:
70-
pluginComponents:
71-
- rke2-ingress-nginx
72-
kubernetesComponents:
73-
- cloudController
74-
etcd:
75-
backupConfig:
76-
scheduleCron: '*/5 * * * *'
77-
retention: "1"
78-
agentConfig:
79-
nodeAnnotations:
80-
test: "true"
81-
machineTemplate:
82-
infrastructureRef:
83-
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
84-
kind: DockerMachineTemplate
85-
name: ${CLUSTER_NAME}-control-plane
86-
nodeDrainTimeout: 30s
87-
infrastructureRef:
88-
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
89-
kind: DockerMachineTemplate
90-
name: ${CLUSTER_NAME}-control-plane
91-
nodeDrainTimeout: 30s
126+
template:
127+
spec:
128+
rolloutStrategy:
129+
rollingUpdate:
130+
maxSurge: 1
131+
type: RollingUpdate
132+
serverConfig:
133+
cloudProviderName: external
134+
kubeAPIServer:
135+
extraArgs:
136+
- --anonymous-auth=true
137+
disableComponents:
138+
pluginComponents:
139+
- rke2-ingress-nginx
140+
kubernetesComponents:
141+
- cloudController
142+
etcd:
143+
backupConfig:
144+
scheduleCron: '*/30 * * * *'
145+
retention: "1"
146+
agentConfig:
147+
nodeAnnotations:
148+
test: "true"
149+
nodeDrainTimeout: 30s
92150
---
93151
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
94152
kind: DockerMachineTemplate
95153
metadata:
96-
name: ${CLUSTER_NAME}-md-0
154+
name: ${CLUSTER_NAME}-control-plane
155+
namespace: ${NAMESPACE}
156+
spec:
157+
template:
158+
spec:
159+
bootstrapTimeout: 15m
160+
---
161+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
162+
kind: DockerMachineTemplate
163+
metadata:
164+
name: ${CLUSTER_NAME}-worker-machinetemplate
97165
namespace: ${NAMESPACE}
98166
spec:
99167
template:
@@ -104,35 +172,10 @@ spec:
104172
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
105173
kind: RKE2ConfigTemplate
106174
metadata:
107-
name: ${CLUSTER_NAME}-md-0
175+
name: ${CLUSTER_NAME}-worker-bootstraptemplate
108176
namespace: ${NAMESPACE}
109177
spec: {}
110178
---
111-
apiVersion: cluster.x-k8s.io/v1beta1
112-
kind: MachineDeployment
113-
metadata:
114-
name: ${CLUSTER_NAME}-md-0
115-
namespace: ${NAMESPACE}
116-
spec:
117-
clusterName: ${CLUSTER_NAME}
118-
replicas: ${WORKER_MACHINE_COUNT}
119-
selector:
120-
matchLabels:
121-
cluster.x-k8s.io/cluster-name: ${CLUSTER_NAME}
122-
template:
123-
spec:
124-
version: ${RKE2_VERSION}
125-
clusterName: ${CLUSTER_NAME}
126-
bootstrap:
127-
configRef:
128-
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
129-
kind: RKE2ConfigTemplate
130-
name: ${CLUSTER_NAME}-md-0
131-
infrastructureRef:
132-
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
133-
kind: DockerMachineTemplate
134-
name: ${CLUSTER_NAME}-md-0
135-
---
136179
apiVersion: v1
137180
data:
138181
value: |-

test/e2e/data/cni/kindnet.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,4 +127,4 @@ spec:
127127
targets:
128128
- clusterSelector:
129129
matchLabels:
130-
cni: ${CLUSTER_NAME}-crs-0
130+
cni: kindnet

test/e2e/specs/import_gitops_mgmtv3.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,6 @@ func CreateMgmtV3UsingGitOpsSpec(ctx context.Context, inputGetter func() CreateM
244244
"CLUSTER_CLASS_NAME": fmt.Sprintf("%s-class", input.ClusterName),
245245
"WORKER_MACHINE_COUNT": strconv.Itoa(workerMachineCount),
246246
"CONTROL_PLANE_MACHINE_COUNT": strconv.Itoa(controlPlaneMachineCount),
247-
"RKE2_CNI": "none",
248247
}
249248

250249
for k, v := range input.AdditionalTemplateVariables {

0 commit comments

Comments
 (0)