Skip to content

Commit ac66b97

Browse files
committed
add a e2e test for internal load balancer only
1 parent 32a907c commit ac66b97

File tree

3 files changed

+207
-1
lines changed

3 files changed

+207
-1
lines changed
Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
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+
subnets:
32+
- name: control-plane-subnet
33+
cidrBlock: "10.0.0.0/17"
34+
purpose: PRIVATE
35+
region: us-east4
36+
loadBalancer:
37+
loadBalancerType: InternalExternal
38+
---
39+
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
40+
kind: KubeadmControlPlane
41+
metadata:
42+
name: "${CLUSTER_NAME}-control-plane"
43+
spec:
44+
replicas: ${CONTROL_PLANE_MACHINE_COUNT}
45+
machineTemplate:
46+
infrastructureRef:
47+
kind: GCPMachineTemplate
48+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
49+
name: "${CLUSTER_NAME}-control-plane"
50+
kubeadmConfigSpec:
51+
initConfiguration:
52+
nodeRegistration:
53+
name: '{{ ds.meta_data.local_hostname.split(".")[0] }}'
54+
kubeletExtraArgs:
55+
cloud-provider: external
56+
clusterConfiguration:
57+
apiServer:
58+
timeoutForControlPlane: 20m
59+
controllerManager:
60+
extraArgs:
61+
cloud-provider: external
62+
allocate-node-cidrs: "false"
63+
kubernetesVersion: "${KUBERNETES_VERSION}"
64+
files:
65+
- content: |
66+
[Global]
67+
68+
project-id = "${GCP_PROJECT}"
69+
network-name = "${GCP_NETWORK_NAME}"
70+
multizone = true
71+
owner: root:root
72+
path: /etc/kubernetes/cloud.config
73+
permissions: "0744"
74+
joinConfiguration:
75+
nodeRegistration:
76+
name: '{{ ds.meta_data.local_hostname.split(".")[0] }}'
77+
kubeletExtraArgs:
78+
cloud-provider: external
79+
version: "${KUBERNETES_VERSION}"
80+
---
81+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
82+
kind: GCPMachineTemplate
83+
metadata:
84+
name: "${CLUSTER_NAME}-control-plane"
85+
spec:
86+
template:
87+
spec:
88+
instanceType: "${GCP_CONTROL_PLANE_MACHINE_TYPE}"
89+
image: "${IMAGE_ID}"
90+
---
91+
apiVersion: cluster.x-k8s.io/v1beta1
92+
kind: MachineDeployment
93+
metadata:
94+
name: "${CLUSTER_NAME}-md-0"
95+
spec:
96+
clusterName: "${CLUSTER_NAME}"
97+
replicas: ${WORKER_MACHINE_COUNT}
98+
selector:
99+
matchLabels:
100+
template:
101+
spec:
102+
clusterName: "${CLUSTER_NAME}"
103+
version: "${KUBERNETES_VERSION}"
104+
bootstrap:
105+
configRef:
106+
name: "${CLUSTER_NAME}-md-0"
107+
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
108+
kind: KubeadmConfigTemplate
109+
infrastructureRef:
110+
name: "${CLUSTER_NAME}-md-0"
111+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
112+
kind: GCPMachineTemplate
113+
---
114+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
115+
kind: GCPMachineTemplate
116+
metadata:
117+
name: "${CLUSTER_NAME}-md-0"
118+
spec:
119+
template:
120+
spec:
121+
instanceType: "${GCP_NODE_MACHINE_TYPE}"
122+
image: "${IMAGE_ID}"
123+
---
124+
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
125+
kind: KubeadmConfigTemplate
126+
metadata:
127+
name: "${CLUSTER_NAME}-md-0"
128+
spec:
129+
template:
130+
spec:
131+
joinConfiguration:
132+
nodeRegistration:
133+
name: '{{ ds.meta_data.local_hostname.split(".")[0] }}'
134+
kubeletExtraArgs:
135+
cloud-provider: external
136+
---
137+
apiVersion: v1
138+
kind: ConfigMap
139+
metadata:
140+
name: "${CLUSTER_NAME}-crs-cni"
141+
data: ${CNI_RESOURCES}
142+
---
143+
apiVersion: addons.cluster.x-k8s.io/v1beta1
144+
kind: ClusterResourceSet
145+
metadata:
146+
name: "${CLUSTER_NAME}-crs-cni"
147+
spec:
148+
strategy: ApplyOnce
149+
clusterSelector:
150+
matchLabels:
151+
cni: "${CLUSTER_NAME}-crs-cni"
152+
resources:
153+
- name: "${CLUSTER_NAME}-crs-cni"
154+
kind: ConfigMap
155+
---
156+
apiVersion: v1
157+
kind: ConfigMap
158+
metadata:
159+
name: "${CLUSTER_NAME}-crs-ccm"
160+
data: ${CCM_RESOURCES}
161+
---
162+
apiVersion: addons.cluster.x-k8s.io/v1beta1
163+
kind: ClusterResourceSet
164+
metadata:
165+
name: "${CLUSTER_NAME}-crs-ccm"
166+
spec:
167+
strategy: ApplyOnce
168+
clusterSelector:
169+
matchLabels:
170+
ccm: "${CLUSTER_NAME}-crs-ccm"
171+
resources:
172+
- name: "${CLUSTER_NAME}-crs-ccm"
173+
kind: ConfigMap

test/e2e/data/infrastructure-gcp/cluster-template-ci-with-internal-lb.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ metadata:
88
ccm: "${CLUSTER_NAME}-crs-ccm"
99
spec:
1010
clusterNetwork:
11+
apiServerPort: 6443
1112
pods:
1213
cidrBlocks: ["192.168.0.0/16"]
1314
infrastructureRef:
@@ -33,8 +34,10 @@ spec:
3334
cidrBlock: "10.0.0.0/17"
3435
purpose: PRIVATE
3536
region: us-east4
37+
controlPlaneEndpoint:
38+
port: 6443
3639
loadBalancer:
37-
loadBalancerType: InternalExternal
40+
loadBalancerType: Internal
3841
---
3942
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
4043
kind: KubeadmControlPlane

test/e2e/e2e_test.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,38 @@ var _ = Describe("Workload cluster creation", func() {
188188
})
189189
})
190190

191+
Context("Creating a control-plane cluster with an external and an internal load balancer", func() {
192+
It("Should create a cluster with 1 control-plane and 1 worker node with an external and an internal load balancer", func() {
193+
clusterName := fmt.Sprintf("%s-internal-lb", clusterNamePrefix)
194+
By("Creating a cluster with an internal load balancer and an external load balancer")
195+
clusterctl.ApplyClusterTemplateAndWait(ctx, clusterctl.ApplyClusterTemplateAndWaitInput{
196+
ClusterProxy: bootstrapClusterProxy,
197+
ConfigCluster: clusterctl.ConfigClusterInput{
198+
LogFolder: clusterctlLogFolder,
199+
ClusterctlConfigPath: clusterctlConfigPath,
200+
KubeconfigPath: bootstrapClusterProxy.GetKubeconfigPath(),
201+
InfrastructureProvider: clusterctl.DefaultInfrastructureProvider,
202+
Flavor: "ci-with-external-and-internal-lb",
203+
Namespace: namespace.Name,
204+
ClusterName: clusterName,
205+
KubernetesVersion: e2eConfig.MustGetVariable(KubernetesVersion),
206+
ControlPlaneMachineCount: ptr.To[int64](1),
207+
WorkerMachineCount: ptr.To[int64](1),
208+
},
209+
WaitForClusterIntervals: e2eConfig.GetIntervals(specName, "wait-cluster"),
210+
WaitForControlPlaneIntervals: e2eConfig.GetIntervals(specName, "wait-control-plane"),
211+
WaitForMachineDeployments: e2eConfig.GetIntervals(specName, "wait-worker-nodes"),
212+
}, result)
213+
})
214+
})
215+
216+
// Skipping the test case for now. The internal load balancer test case requires the management cluster
217+
// to have access to network that the cluster being created is in.
218+
// An option to reach that is to use a GKE cluster as the management cluster.
191219
Context("Creating a control-plane cluster with an internal load balancer", func() {
192220
It("Should create a cluster with 1 control-plane and 1 worker node with an internal load balancer", func() {
221+
Skip("This test requires a bootstrap cluster that has access to the network where the cluster is being created.")
222+
193223
clusterName := fmt.Sprintf("%s-internal-lb", clusterNamePrefix)
194224
By("Creating a cluster with internal load balancer")
195225
clusterctl.ApplyClusterTemplateAndWait(ctx, clusterctl.ApplyClusterTemplateAndWaitInput{

0 commit comments

Comments
 (0)