Skip to content

Commit c9c98eb

Browse files
authored
Merge pull request #1245 from bfournie/internal-lb-e2e-test
Add e2e test for internal load balancer
2 parents 4cb3460 + 32fe7ee commit c9c98eb

File tree

3 files changed

+171
-0
lines changed

3 files changed

+171
-0
lines changed

test/e2e/config/gcp-ci.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ providers:
7272
- sourcePath: "${PWD}/test/e2e/data/infrastructure-gcp/cluster-template-ci-gke.yaml"
7373
- sourcePath: "${PWD}/test/e2e/data/infrastructure-gcp/cluster-template-ci-gke-autopilot.yaml"
7474
- sourcePath: "${PWD}/test/e2e/data/infrastructure-gcp/cluster-template-ci-gke-custom-subnet.yaml"
75+
- sourcePath: "${PWD}/test/e2e/data/infrastructure-gcp/cluster-template-ci-with-internal-lb.yaml"
7576

7677
variables:
7778
KUBERNETES_VERSION: "${KUBERNETES_VERSION:-v1.29.0}"
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
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+
spec:
9+
clusterNetwork:
10+
pods:
11+
cidrBlocks: ["192.168.0.0/16"]
12+
infrastructureRef:
13+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
14+
kind: GCPCluster
15+
name: "${CLUSTER_NAME}"
16+
controlPlaneRef:
17+
kind: KubeadmControlPlane
18+
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
19+
name: "${CLUSTER_NAME}-control-plane"
20+
---
21+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
22+
kind: GCPCluster
23+
metadata:
24+
name: "${CLUSTER_NAME}"
25+
spec:
26+
project: "${GCP_PROJECT}"
27+
region: "${GCP_REGION}"
28+
network:
29+
name: "${GCP_NETWORK_NAME}"
30+
subnets:
31+
- name: control-plane-subnet
32+
cidrBlock: "10.0.0.0/17"
33+
purpose: PRIVATE
34+
region: us-east4
35+
loadBalancer:
36+
loadBalancerType: InternalExternal
37+
---
38+
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
39+
kind: KubeadmControlPlane
40+
metadata:
41+
name: "${CLUSTER_NAME}-control-plane"
42+
spec:
43+
replicas: ${CONTROL_PLANE_MACHINE_COUNT}
44+
machineTemplate:
45+
infrastructureRef:
46+
kind: GCPMachineTemplate
47+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
48+
name: "${CLUSTER_NAME}-control-plane"
49+
kubeadmConfigSpec:
50+
useExperimentalRetryJoin: true
51+
initConfiguration:
52+
nodeRegistration:
53+
name: '{{ ds.meta_data.local_hostname.split(".")[0] }}'
54+
kubeletExtraArgs:
55+
cloud-provider: gce
56+
clusterConfiguration:
57+
apiServer:
58+
timeoutForControlPlane: 20m
59+
extraArgs:
60+
cloud-provider: gce
61+
controllerManager:
62+
extraArgs:
63+
cloud-provider: gce
64+
allocate-node-cidrs: "false"
65+
kubernetesVersion: "${KUBERNETES_VERSION}"
66+
joinConfiguration:
67+
nodeRegistration:
68+
name: '{{ ds.meta_data.local_hostname.split(".")[0] }}'
69+
kubeletExtraArgs:
70+
cloud-provider: gce
71+
version: "${KUBERNETES_VERSION}"
72+
---
73+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
74+
kind: GCPMachineTemplate
75+
metadata:
76+
name: "${CLUSTER_NAME}-control-plane"
77+
spec:
78+
template:
79+
spec:
80+
instanceType: "${GCP_CONTROL_PLANE_MACHINE_TYPE}"
81+
image: "${IMAGE_ID}"
82+
---
83+
apiVersion: cluster.x-k8s.io/v1beta1
84+
kind: MachineDeployment
85+
metadata:
86+
name: "${CLUSTER_NAME}-md-0"
87+
spec:
88+
clusterName: "${CLUSTER_NAME}"
89+
replicas: ${WORKER_MACHINE_COUNT}
90+
selector:
91+
matchLabels:
92+
template:
93+
spec:
94+
clusterName: "${CLUSTER_NAME}"
95+
version: "${KUBERNETES_VERSION}"
96+
bootstrap:
97+
configRef:
98+
name: "${CLUSTER_NAME}-md-0"
99+
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
100+
kind: KubeadmConfigTemplate
101+
infrastructureRef:
102+
name: "${CLUSTER_NAME}-md-0"
103+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
104+
kind: GCPMachineTemplate
105+
---
106+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
107+
kind: GCPMachineTemplate
108+
metadata:
109+
name: "${CLUSTER_NAME}-md-0"
110+
spec:
111+
template:
112+
spec:
113+
instanceType: "${GCP_NODE_MACHINE_TYPE}"
114+
image: "${IMAGE_ID}"
115+
---
116+
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
117+
kind: KubeadmConfigTemplate
118+
metadata:
119+
name: "${CLUSTER_NAME}-md-0"
120+
spec:
121+
template:
122+
spec:
123+
joinConfiguration:
124+
nodeRegistration:
125+
name: '{{ ds.meta_data.local_hostname.split(".")[0] }}'
126+
kubeletExtraArgs:
127+
cloud-provider: gce
128+
---
129+
apiVersion: v1
130+
kind: ConfigMap
131+
metadata:
132+
name: "${CLUSTER_NAME}-crs-cni"
133+
data: ${CNI_RESOURCES}
134+
---
135+
apiVersion: addons.cluster.x-k8s.io/v1beta1
136+
kind: ClusterResourceSet
137+
metadata:
138+
name: "${CLUSTER_NAME}-crs-cni"
139+
spec:
140+
strategy: ApplyOnce
141+
clusterSelector:
142+
matchLabels:
143+
cni: "${CLUSTER_NAME}-crs-cni"
144+
resources:
145+
- name: "${CLUSTER_NAME}-crs-cni"
146+
kind: ConfigMap

test/e2e/e2e_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,4 +182,28 @@ var _ = Describe("Workload cluster creation", func() {
182182
}, result)
183183
})
184184
})
185+
186+
Context("Creating a control-plane cluster with an internal load balancer", func() {
187+
It("Should create a cluster with 1 control-plane and 1 worker node with an internal load balancer", func() {
188+
By("Creating a cluster with internal load balancer")
189+
clusterctl.ApplyClusterTemplateAndWait(ctx, clusterctl.ApplyClusterTemplateAndWaitInput{
190+
ClusterProxy: bootstrapClusterProxy,
191+
ConfigCluster: clusterctl.ConfigClusterInput{
192+
LogFolder: clusterctlLogFolder,
193+
ClusterctlConfigPath: clusterctlConfigPath,
194+
KubeconfigPath: bootstrapClusterProxy.GetKubeconfigPath(),
195+
InfrastructureProvider: clusterctl.DefaultInfrastructureProvider,
196+
Flavor: "ci-with-internal-lb",
197+
Namespace: namespace.Name,
198+
ClusterName: clusterName,
199+
KubernetesVersion: e2eConfig.GetVariable(KubernetesVersion),
200+
ControlPlaneMachineCount: ptr.To[int64](1),
201+
WorkerMachineCount: ptr.To[int64](1),
202+
},
203+
WaitForClusterIntervals: e2eConfig.GetIntervals(specName, "wait-cluster"),
204+
WaitForControlPlaneIntervals: e2eConfig.GetIntervals(specName, "wait-control-plane"),
205+
WaitForMachineDeployments: e2eConfig.GetIntervals(specName, "wait-worker-nodes"),
206+
}, result)
207+
})
208+
})
185209
})

0 commit comments

Comments
 (0)