Skip to content

Commit 08da022

Browse files
authored
Merge pull request #1355 from salasberryfin/test-e2e-cover-clusterclass
test: e2e cover clusterclass provisioning
2 parents 548fa54 + 213b32f commit 08da022

File tree

4 files changed

+239
-48
lines changed

4 files changed

+239
-48
lines changed

test/e2e/config/gcp-ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ providers:
6666
- sourcePath: "${PWD}/test/e2e/data/infrastructure-gcp/cluster-template-upgrades.yaml"
6767
- sourcePath: "${PWD}/test/e2e/data/infrastructure-gcp/cluster-template-md-remediation.yaml"
6868
- sourcePath: "${PWD}/test/e2e/data/infrastructure-gcp/cluster-template-kcp-remediation.yaml"
69-
- sourcePath: "${PWD}/test/e2e/data/infrastructure-gcp/cluster-template-topology.yaml"
69+
- sourcePath: "${PWD}/test/e2e/data/infrastructure-gcp/withclusterclass/cluster-template-ci-topology.yaml"
7070
- sourcePath: "${PWD}/test/e2e/data/infrastructure-gcp/clusterclass-quick-start.yaml"
7171
- sourcePath: "${PWD}/test/e2e/data/infrastructure-gcp/cluster-template-ci-with-creds.yaml"
7272
- sourcePath: "${PWD}/test/e2e/data/infrastructure-gcp/cluster-template-ci-gke.yaml"

test/e2e/data/infrastructure-gcp/cluster-template-topology.yaml

Lines changed: 0 additions & 47 deletions
This file was deleted.
Lines changed: 214 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,214 @@
1+
---
2+
apiVersion: cluster.x-k8s.io/v1beta1
3+
kind: ClusterClass
4+
metadata:
5+
name: quick-start
6+
spec:
7+
controlPlane:
8+
ref:
9+
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
10+
kind: KubeadmControlPlaneTemplate
11+
name: quick-start-control-plane
12+
machineInfrastructure:
13+
ref:
14+
kind: GCPMachineTemplate
15+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
16+
name: quick-start-control-plane
17+
infrastructure:
18+
ref:
19+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
20+
kind: GCPClusterTemplate
21+
name: quick-start
22+
workers:
23+
machineDeployments:
24+
- class: default-worker
25+
template:
26+
bootstrap:
27+
ref:
28+
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
29+
kind: KubeadmConfigTemplate
30+
name: quick-start-worker-bootstraptemplate
31+
infrastructure:
32+
ref:
33+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
34+
kind: GCPMachineTemplate
35+
name: quick-start-worker-machinetemplate
36+
variables:
37+
- name: region
38+
required: true
39+
schema:
40+
openAPIV3Schema:
41+
type: string
42+
default: us-west1
43+
- name: controlPlaneMachineType
44+
required: true
45+
schema:
46+
openAPIV3Schema:
47+
type: string
48+
default: n1-standard-2
49+
- name: workerMachineType
50+
required: true
51+
schema:
52+
openAPIV3Schema:
53+
type: string
54+
default: n1-standard-2
55+
patches:
56+
- name: region
57+
definitions:
58+
- selector:
59+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
60+
kind: GCPClusterTemplate
61+
matchResources:
62+
infrastructureCluster: true
63+
jsonPatches:
64+
- op: add
65+
path: /spec/template/spec/region
66+
valueFrom:
67+
variable: region
68+
- name: controlPlaneMachineType
69+
definitions:
70+
- selector:
71+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
72+
kind: GCPMachineTemplate
73+
matchResources:
74+
controlPlane: true
75+
jsonPatches:
76+
- op: replace
77+
path: /spec/template/spec/instanceType
78+
valueFrom:
79+
variable: controlPlaneMachineType
80+
- name: workerMachineType
81+
definitions:
82+
- selector:
83+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
84+
kind: GCPMachineTemplate
85+
matchResources:
86+
machineDeploymentClass:
87+
names:
88+
- default-worker
89+
jsonPatches:
90+
- op: replace
91+
path: /spec/template/spec/instanceType
92+
valueFrom:
93+
variable: workerMachineType
94+
---
95+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
96+
kind: GCPClusterTemplate
97+
metadata:
98+
name: quick-start
99+
spec:
100+
template:
101+
spec:
102+
project: "${GCP_PROJECT}"
103+
region: "${GCP_REGION}"
104+
network:
105+
name: "${GCP_NETWORK_NAME}"
106+
---
107+
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
108+
kind: KubeadmControlPlaneTemplate
109+
metadata:
110+
name: quick-start-control-plane
111+
spec:
112+
template:
113+
spec:
114+
kubeadmConfigSpec:
115+
useExperimentalRetryJoin: true
116+
initConfiguration:
117+
nodeRegistration:
118+
name: '{{ ds.meta_data.local_hostname.split(".")[0] }}'
119+
kubeletExtraArgs:
120+
cloud-provider: gce
121+
clusterConfiguration:
122+
apiServer:
123+
timeoutForControlPlane: 20m
124+
extraArgs:
125+
cloud-provider: gce
126+
controllerManager:
127+
extraArgs:
128+
cloud-provider: gce
129+
allocate-node-cidrs: "false"
130+
joinConfiguration:
131+
nodeRegistration:
132+
name: '{{ ds.meta_data.local_hostname.split(".")[0] }}'
133+
kubeletExtraArgs:
134+
cloud-provider: gce
135+
---
136+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
137+
kind: GCPMachineTemplate
138+
metadata:
139+
name: quick-start-control-plane
140+
spec:
141+
template:
142+
spec:
143+
instanceType: REPLACEME
144+
image: "${IMAGE_ID}"
145+
---
146+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
147+
kind: GCPMachineTemplate
148+
metadata:
149+
name: quick-start-worker-machinetemplate
150+
spec:
151+
template:
152+
spec:
153+
instanceType: REPLACEME
154+
image: "${IMAGE_ID}"
155+
---
156+
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
157+
kind: KubeadmConfigTemplate
158+
metadata:
159+
name: quick-start-worker-bootstraptemplate
160+
spec:
161+
template:
162+
spec:
163+
joinConfiguration:
164+
nodeRegistration:
165+
name: '{{ ds.meta_data.local_hostname.split(".")[0] }}'
166+
kubeletExtraArgs:
167+
cloud-provider: gce
168+
---
169+
apiVersion: cluster.x-k8s.io/v1beta1
170+
kind: Cluster
171+
metadata:
172+
name: "${CLUSTER_NAME}"
173+
labels:
174+
cni: "${CLUSTER_NAME}-crs-cni"
175+
spec:
176+
clusterNetwork:
177+
pods:
178+
cidrBlocks: ["192.168.0.0/16"]
179+
topology:
180+
class: quick-start
181+
version: "${KUBERNETES_VERSION}"
182+
controlPlane:
183+
replicas: ${CONTROL_PLANE_MACHINE_COUNT}
184+
workers:
185+
machineDeployments:
186+
- class: "default-worker"
187+
name: "md-0"
188+
replicas: ${WORKER_MACHINE_COUNT}
189+
variables:
190+
- name: region
191+
value: ${GCP_REGION}
192+
- name: controlPlaneMachineType
193+
value: ${GCP_CONTROL_PLANE_MACHINE_TYPE}
194+
- name: workerMachineType
195+
value: ${GCP_NODE_MACHINE_TYPE}
196+
---
197+
apiVersion: v1
198+
kind: ConfigMap
199+
metadata:
200+
name: "${CLUSTER_NAME}-crs-cni"
201+
data: ${CNI_RESOURCES}
202+
---
203+
apiVersion: addons.cluster.x-k8s.io/v1beta1
204+
kind: ClusterResourceSet
205+
metadata:
206+
name: "${CLUSTER_NAME}-crs-cni"
207+
spec:
208+
strategy: ApplyOnce
209+
clusterSelector:
210+
matchLabels:
211+
cni: "${CLUSTER_NAME}-crs-cni"
212+
resources:
213+
- name: "${CLUSTER_NAME}-crs-cni"
214+
kind: ConfigMap

test/e2e/e2e_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,4 +206,28 @@ var _ = Describe("Workload cluster creation", func() {
206206
}, result)
207207
})
208208
})
209+
210+
Context("Creating a cluster using a cluster class", func() {
211+
It("Should create a cluster class and then a cluster based on it", func() {
212+
By("Creating a cluster from a topology")
213+
clusterctl.ApplyClusterTemplateAndWait(ctx, clusterctl.ApplyClusterTemplateAndWaitInput{
214+
ClusterProxy: bootstrapClusterProxy,
215+
ConfigCluster: clusterctl.ConfigClusterInput{
216+
LogFolder: clusterctlLogFolder,
217+
ClusterctlConfigPath: clusterctlConfigPath,
218+
KubeconfigPath: bootstrapClusterProxy.GetKubeconfigPath(),
219+
InfrastructureProvider: clusterctl.DefaultInfrastructureProvider,
220+
Flavor: "ci-topology",
221+
Namespace: namespace.Name,
222+
ClusterName: clusterName,
223+
KubernetesVersion: e2eConfig.GetVariable(KubernetesVersion),
224+
ControlPlaneMachineCount: ptr.To[int64](1),
225+
WorkerMachineCount: ptr.To[int64](1),
226+
},
227+
WaitForClusterIntervals: e2eConfig.GetIntervals(specName, "wait-cluster"),
228+
WaitForControlPlaneIntervals: e2eConfig.GetIntervals(specName, "wait-control-plane"),
229+
WaitForMachineDeployments: e2eConfig.GetIntervals(specName, "wait-worker-nodes"),
230+
}, result)
231+
})
232+
})
209233
})

0 commit comments

Comments
 (0)