Skip to content

Commit 8231d8c

Browse files
committed
test: add simple test for MachinePool
1 parent 87cedb8 commit 8231d8c

File tree

3 files changed

+213
-0
lines changed

3 files changed

+213
-0
lines changed

test/e2e/config/gcp-ci.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ providers:
7575
- sourcePath: "${PWD}/test/e2e/data/infrastructure-gcp/cluster-template-ci-gke-autopilot.yaml"
7676
- sourcePath: "${PWD}/test/e2e/data/infrastructure-gcp/cluster-template-ci-gke-custom-subnet.yaml"
7777
- sourcePath: "${PWD}/test/e2e/data/infrastructure-gcp/cluster-template-ci-with-internal-lb.yaml"
78+
- sourcePath: "${PWD}/test/e2e/data/infrastructure-gcp/cluster-template-ci-with-machinepool.yaml"
7879
- sourcePath: "${PWD}/test/e2e/data/infrastructure-gcp/withclusterclass/cluster-template-ci-gke-autopilot-topology.yaml"
7980

8081
variables:
@@ -120,6 +121,7 @@ intervals:
120121
default/wait-gpu-nodes: ["30m", "10s"]
121122
default/wait-delete-cluster: ["30m", "10s"]
122123
default/wait-machine-upgrade: ["60m", "10s"]
124+
default/wait-machine-pool-nodes: ["40m", "10s"]
123125
default/wait-machine-pool-upgrade: ["60m", "10s"]
124126
default/wait-machine-remediation: ["30m", "10s"]
125127
default/wait-deployment: ["15m", "10s"]
Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
---
2+
apiVersion: cluster.x-k8s.io/v1beta1
3+
kind: Cluster
4+
metadata:
5+
name: "${CLUSTER_NAME}"
6+
labels:
7+
cni: "${CLUSTER_NAME}-crs-cni"
8+
ccm: "${CLUSTER_NAME}-crs-ccm"
9+
spec:
10+
clusterNetwork:
11+
pods:
12+
cidrBlocks: ["192.168.0.0/16"]
13+
infrastructureRef:
14+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
15+
kind: GCPCluster
16+
name: "${CLUSTER_NAME}"
17+
controlPlaneRef:
18+
kind: KubeadmControlPlane
19+
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
20+
name: "${CLUSTER_NAME}-control-plane"
21+
---
22+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
23+
kind: GCPCluster
24+
metadata:
25+
name: "${CLUSTER_NAME}"
26+
spec:
27+
project: "${GCP_PROJECT}"
28+
region: "${GCP_REGION}"
29+
network:
30+
name: "${GCP_NETWORK_NAME}"
31+
---
32+
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
33+
kind: KubeadmControlPlane
34+
metadata:
35+
name: "${CLUSTER_NAME}-control-plane"
36+
spec:
37+
replicas: ${CONTROL_PLANE_MACHINE_COUNT}
38+
machineTemplate:
39+
infrastructureRef:
40+
kind: GCPMachineTemplate
41+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
42+
name: "${CLUSTER_NAME}-control-plane"
43+
kubeadmConfigSpec:
44+
initConfiguration:
45+
nodeRegistration:
46+
name: '{{ ds.meta_data.local_hostname.split(".")[0] }}'
47+
kubeletExtraArgs:
48+
cloud-provider: external
49+
clusterConfiguration:
50+
apiServer:
51+
timeoutForControlPlane: 20m
52+
controllerManager:
53+
extraArgs:
54+
cloud-provider: external
55+
allocate-node-cidrs: "false"
56+
kubernetesVersion: "${KUBERNETES_VERSION}"
57+
files:
58+
- content: |
59+
[Global]
60+
61+
project-id = "${GCP_PROJECT}"
62+
network-name = "${GCP_NETWORK_NAME}"
63+
multizone = true
64+
owner: root:root
65+
path: /etc/kubernetes/cloud.config
66+
permissions: "0744"
67+
joinConfiguration:
68+
nodeRegistration:
69+
name: '{{ ds.meta_data.local_hostname.split(".")[0] }}'
70+
kubeletExtraArgs:
71+
cloud-provider: external
72+
version: "${KUBERNETES_VERSION}"
73+
---
74+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
75+
kind: GCPMachineTemplate
76+
metadata:
77+
name: "${CLUSTER_NAME}-control-plane"
78+
spec:
79+
template:
80+
spec:
81+
instanceType: "${GCP_CONTROL_PLANE_MACHINE_TYPE}"
82+
image: "${IMAGE_ID}"
83+
---
84+
apiVersion: cluster.x-k8s.io/v1beta1
85+
kind: MachinePool
86+
metadata:
87+
name: "${CLUSTER_NAME}-md-0"
88+
spec:
89+
clusterName: "${CLUSTER_NAME}"
90+
replicas: ${WORKER_MACHINE_COUNT}
91+
failureDomains:
92+
# We currently only support a single zone (failure domain) per MachinePool,
93+
# when using GCPMachinePool.
94+
- ${GCP_REGION}-a
95+
template:
96+
spec:
97+
clusterName: "${CLUSTER_NAME}"
98+
version: "${KUBERNETES_VERSION}"
99+
bootstrap:
100+
configRef:
101+
name: "${CLUSTER_NAME}-md-0"
102+
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
103+
kind: KubeadmConfig
104+
infrastructureRef:
105+
name: "${CLUSTER_NAME}-md-0"
106+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
107+
kind: GCPMachinePool
108+
---
109+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
110+
kind: GCPMachinePool
111+
metadata:
112+
name: "${CLUSTER_NAME}-md-0"
113+
spec:
114+
instanceType: "${GCP_NODE_MACHINE_TYPE}"
115+
image: "${IMAGE_ID}"
116+
---
117+
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
118+
kind: KubeadmConfig
119+
metadata:
120+
name: "${CLUSTER_NAME}-md-0"
121+
spec:
122+
joinConfiguration:
123+
nodeRegistration:
124+
name: '{{ ds.meta_data.local_hostname.split(".")[0] }}'
125+
kubeletExtraArgs:
126+
cloud-provider: external
127+
---
128+
apiVersion: v1
129+
kind: ConfigMap
130+
metadata:
131+
name: "${CLUSTER_NAME}-crs-cni"
132+
data: ${CNI_RESOURCES}
133+
---
134+
apiVersion: addons.cluster.x-k8s.io/v1beta1
135+
kind: ClusterResourceSet
136+
metadata:
137+
name: "${CLUSTER_NAME}-crs-cni"
138+
spec:
139+
strategy: ApplyOnce
140+
clusterSelector:
141+
matchLabels:
142+
cni: "${CLUSTER_NAME}-crs-cni"
143+
resources:
144+
- name: "${CLUSTER_NAME}-crs-cni"
145+
kind: ConfigMap
146+
---
147+
apiVersion: v1
148+
kind: ConfigMap
149+
metadata:
150+
name: "${CLUSTER_NAME}-crs-ccm"
151+
data: ${CCM_RESOURCES}
152+
---
153+
apiVersion: addons.cluster.x-k8s.io/v1beta1
154+
kind: ClusterResourceSet
155+
metadata:
156+
name: "${CLUSTER_NAME}-crs-ccm"
157+
spec:
158+
strategy: ApplyOnce
159+
clusterSelector:
160+
matchLabels:
161+
ccm: "${CLUSTER_NAME}-crs-ccm"
162+
resources:
163+
- name: "${CLUSTER_NAME}-crs-ccm"
164+
kind: ConfigMap

test/e2e/e2e_test.go

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,53 @@ var _ = Describe("Workload cluster creation", func() {
125125
})
126126
})
127127

128+
Context("Creating a single control-plane cluster with MachinePool", func() {
129+
It("Should create a cluster with 1 worker node and can be scaled", func() {
130+
clusterName := fmt.Sprintf("%s-single", clusterNamePrefix)
131+
By("Initializes with 1 worker node")
132+
clusterctl.ApplyClusterTemplateAndWait(ctx, clusterctl.ApplyClusterTemplateAndWaitInput{
133+
ClusterProxy: bootstrapClusterProxy,
134+
ConfigCluster: clusterctl.ConfigClusterInput{
135+
LogFolder: clusterctlLogFolder,
136+
ClusterctlConfigPath: clusterctlConfigPath,
137+
KubeconfigPath: bootstrapClusterProxy.GetKubeconfigPath(),
138+
InfrastructureProvider: clusterctl.DefaultInfrastructureProvider,
139+
Flavor: "ci-with-machinepool",
140+
Namespace: namespace.Name,
141+
ClusterName: clusterName,
142+
KubernetesVersion: e2eConfig.MustGetVariable(KubernetesVersion),
143+
ControlPlaneMachineCount: ptr.To[int64](1),
144+
WorkerMachineCount: ptr.To[int64](1),
145+
},
146+
WaitForClusterIntervals: e2eConfig.GetIntervals(specName, "wait-cluster"),
147+
WaitForControlPlaneIntervals: e2eConfig.GetIntervals(specName, "wait-control-plane"),
148+
WaitForMachineDeployments: e2eConfig.GetIntervals(specName, "wait-worker-nodes"),
149+
WaitForMachinePools: e2eConfig.GetIntervals(specName, "wait-machine-pool-nodes"),
150+
}, result)
151+
152+
By("Scaling worker node to 3")
153+
clusterctl.ApplyClusterTemplateAndWait(ctx, clusterctl.ApplyClusterTemplateAndWaitInput{
154+
ClusterProxy: bootstrapClusterProxy,
155+
ConfigCluster: clusterctl.ConfigClusterInput{
156+
LogFolder: clusterctlLogFolder,
157+
ClusterctlConfigPath: clusterctlConfigPath,
158+
KubeconfigPath: bootstrapClusterProxy.GetKubeconfigPath(),
159+
InfrastructureProvider: clusterctl.DefaultInfrastructureProvider,
160+
Flavor: "ci-with-machinepool",
161+
Namespace: namespace.Name,
162+
ClusterName: clusterName,
163+
KubernetesVersion: e2eConfig.MustGetVariable(KubernetesVersion),
164+
ControlPlaneMachineCount: ptr.To[int64](1),
165+
WorkerMachineCount: ptr.To[int64](3),
166+
},
167+
WaitForClusterIntervals: e2eConfig.GetIntervals(specName, "wait-cluster"),
168+
WaitForControlPlaneIntervals: e2eConfig.GetIntervals(specName, "wait-control-plane"),
169+
WaitForMachineDeployments: e2eConfig.GetIntervals(specName, "wait-worker-nodes"),
170+
WaitForMachinePools: e2eConfig.GetIntervals(specName, "wait-machine-pool-nodes"),
171+
}, result)
172+
})
173+
})
174+
128175
Context("Creating a highly available control-plane cluster", func() {
129176
It("Should create a cluster with 3 control-plane and 2 worker nodes", func() {
130177
clusterName := fmt.Sprintf("%s-ha", clusterNamePrefix)

0 commit comments

Comments
 (0)