Skip to content

Commit 68213cf

Browse files
Add dualstack e2e test
Signed-off-by: killianmuldoon <[email protected]>
1 parent 7edbaf0 commit 68213cf

File tree

20 files changed

+342
-58
lines changed

20 files changed

+342
-58
lines changed

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,8 @@ generate-e2e-templates-main: $(KUSTOMIZE)
513513
$(KUSTOMIZE) build $(DOCKER_TEMPLATES)/main/cluster-template-upgrades-runtimesdk --load-restrictor LoadRestrictionsNone > $(DOCKER_TEMPLATES)/main/cluster-template-upgrades-runtimesdk.yaml
514514
$(KUSTOMIZE) build $(DOCKER_TEMPLATES)/main/cluster-template-kcp-scale-in --load-restrictor LoadRestrictionsNone > $(DOCKER_TEMPLATES)/main/cluster-template-kcp-scale-in.yaml
515515
$(KUSTOMIZE) build $(DOCKER_TEMPLATES)/main/cluster-template-ipv6 --load-restrictor LoadRestrictionsNone > $(DOCKER_TEMPLATES)/main/cluster-template-ipv6.yaml
516+
$(KUSTOMIZE) build $(DOCKER_TEMPLATES)/main/cluster-template-topology-dualstack-ipv6-primary --load-restrictor LoadRestrictionsNone > $(DOCKER_TEMPLATES)/main/cluster-template-topology-dualstack-ipv6-primary.yaml
517+
$(KUSTOMIZE) build $(DOCKER_TEMPLATES)/main/cluster-template-topology-dualstack-ipv4-primary --load-restrictor LoadRestrictionsNone > $(DOCKER_TEMPLATES)/main/cluster-template-topology-dualstack-ipv4-primary.yaml
516518
$(KUSTOMIZE) build $(DOCKER_TEMPLATES)/main/cluster-template-topology-single-node-cluster --load-restrictor LoadRestrictionsNone > $(DOCKER_TEMPLATES)/main/cluster-template-topology-single-node-cluster.yaml
517519
$(KUSTOMIZE) build $(DOCKER_TEMPLATES)/main/cluster-template-topology --load-restrictor LoadRestrictionsNone > $(DOCKER_TEMPLATES)/main/cluster-template-topology.yaml
518520
$(KUSTOMIZE) build $(DOCKER_TEMPLATES)/main/cluster-template-ignition --load-restrictor LoadRestrictionsNone > $(DOCKER_TEMPLATES)/main/cluster-template-ignition.yaml

bootstrap/kubeadm/internal/controllers/kubeadmconfig_controller.go

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ import (
5050
"sigs.k8s.io/cluster-api/controllers/remote"
5151
expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1"
5252
"sigs.k8s.io/cluster-api/feature"
53+
"sigs.k8s.io/cluster-api/internal/util/taints"
5354
"sigs.k8s.io/cluster-api/util"
5455
"sigs.k8s.io/cluster-api/util/annotations"
5556
"sigs.k8s.io/cluster-api/util/conditions"
@@ -555,7 +556,7 @@ func (r *KubeadmConfigReconciler) joinWorker(ctx context.Context, scope *Scope)
555556
// Do not modify the KubeadmConfig in etcd as this is a temporary taint that will be dropped after the node
556557
// is initialized by ClusterAPI.
557558
joinConfiguration := scope.Config.Spec.JoinConfiguration.DeepCopy()
558-
if !hasTaint(joinConfiguration.NodeRegistration.Taints, clusterv1.NodeUninitializedTaint) {
559+
if !taints.HasTaint(joinConfiguration.NodeRegistration.Taints, clusterv1.NodeUninitializedTaint) {
559560
joinConfiguration.NodeRegistration.Taints = append(joinConfiguration.NodeRegistration.Taints, clusterv1.NodeUninitializedTaint)
560561
}
561562

@@ -1074,12 +1075,3 @@ func (r *KubeadmConfigReconciler) ensureBootstrapSecretOwnersRef(ctx context.Con
10741075
}
10751076
return nil
10761077
}
1077-
1078-
func hasTaint(taints []corev1.Taint, targetTaint corev1.Taint) bool {
1079-
for _, taint := range taints {
1080-
if taint.MatchTaint(&targetTaint) {
1081-
return true
1082-
}
1083-
}
1084-
return false
1085-
}

internal/util/taints/taints.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,13 @@ func RemoveNodeTaint(node *corev1.Node, drop corev1.Taint) bool {
3636
node.Spec.Taints = taints
3737
return droppedTaint
3838
}
39+
40+
// HasTaint returns true if the targetTaint is in the list of taints.
41+
func HasTaint(taints []corev1.Taint, targetTaint corev1.Taint) bool {
42+
for _, taint := range taints {
43+
if taint.MatchTaint(&targetTaint) {
44+
return true
45+
}
46+
}
47+
return false
48+
}

test/e2e/config/docker.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,8 @@ providers:
273273
- sourcePath: "../data/infrastructure-docker/main/cluster-template-upgrades-runtimesdk.yaml"
274274
- sourcePath: "../data/infrastructure-docker/main/cluster-template-kcp-scale-in.yaml"
275275
- sourcePath: "../data/infrastructure-docker/main/cluster-template-ipv6.yaml"
276+
- sourcePath: "../data/infrastructure-docker/main/cluster-template-topology-dualstack-ipv6-primary.yaml"
277+
- sourcePath: "../data/infrastructure-docker/main/cluster-template-topology-dualstack-ipv4-primary.yaml"
276278
- sourcePath: "../data/infrastructure-docker/main/cluster-template-topology-single-node-cluster.yaml"
277279
- sourcePath: "../data/infrastructure-docker/main/cluster-template-topology.yaml"
278280
- sourcePath: "../data/infrastructure-docker/main/cluster-template-ignition.yaml"
@@ -300,7 +302,7 @@ variables:
300302
ETCD_VERSION_UPGRADE_TO: "3.5.7-0"
301303
COREDNS_VERSION_UPGRADE_TO: "v1.10.1"
302304
DOCKER_SERVICE_DOMAIN: "cluster.local"
303-
IP_FAMILY: "IPv4"
305+
IP_FAMILY: "dual"
304306
DOCKER_SERVICE_CIDRS: "10.128.0.0/12"
305307
DOCKER_POD_CIDRS: "192.168.0.0/16"
306308
DOCKER_SERVICE_IPV6_CIDRS: "fd00:100:64::/108"

test/e2e/data/cni/kindnet/kindnet.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,10 @@ spec:
7676
valueFrom:
7777
fieldRef:
7878
fieldPath: status.podIP
79+
# We're using the dualstack CIDRs here. The order doesn't matter for kindnet as the loops are run concurrently.
80+
# REF: https://github.com/kubernetes-sigs/kind/blob/3dbeb894e3092a336ab4278d3823e73a1d66aff7/images/kindnetd/cmd/kindnetd/main.go#L149-L175
7981
- name: POD_SUBNET
80-
value: '${DOCKER_POD_CIDRS}'
82+
value: '${DOCKER_POD_CIDRS},${DOCKER_POD_IPV6_CIDRS}'
8183
volumeMounts:
8284
- name: cni-cfg
8385
mountPath: /etc/cni/net.d
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
apiVersion: cluster.x-k8s.io/v1beta1
3+
kind: Cluster
4+
metadata:
5+
name: '${CLUSTER_NAME}'
6+
spec:
7+
topology:
8+
class: quick-start
9+
variables:
10+
- name: ipv6Primary
11+
value: false
12+
- name: externalCloudProvider
13+
value: true
14+
clusterNetwork:
15+
services:
16+
cidrBlocks:
17+
- '${DOCKER_SERVICE_CIDRS}'
18+
- '${DOCKER_SERVICE_IPV6_CIDRS}'
19+
pods:
20+
cidrBlocks:
21+
- '${DOCKER_POD_CIDRS}'
22+
- '${DOCKER_POD_IPV6_CIDRS}'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
bases:
2+
- ../bases/cluster-with-topology.yaml
3+
- ../bases/crs.yaml
4+
5+
patches:
6+
- cluster.yaml
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
apiVersion: cluster.x-k8s.io/v1beta1
3+
kind: Cluster
4+
metadata:
5+
name: '${CLUSTER_NAME}'
6+
spec:
7+
topology:
8+
class: quick-start
9+
variables:
10+
- name: ipv6Primary
11+
value: true
12+
- name: externalCloudProvider
13+
value: true
14+
clusterNetwork:
15+
services:
16+
cidrBlocks:
17+
- '${DOCKER_SERVICE_IPV6_CIDRS}'
18+
- '${DOCKER_SERVICE_CIDRS}'
19+
pods:
20+
cidrBlocks:
21+
- '${DOCKER_POD_IPV6_CIDRS}'
22+
- '${DOCKER_POD_CIDRS}'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
bases:
2+
- ../bases/cluster-with-topology.yaml
3+
- ../bases/crs.yaml
4+
5+
patches:
6+
- cluster.yaml

test/e2e/data/infrastructure-docker/main/clusterclass-quick-start.yaml

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,18 @@ spec:
100100
openAPIV3Schema:
101101
type: boolean
102102
default: true
103+
- name: externalCloudProvider
104+
required: false
105+
schema:
106+
openAPIV3Schema:
107+
type: boolean
108+
default: false
109+
- name: ipv6Primary
110+
required: false
111+
schema:
112+
openAPIV3Schema:
113+
type: boolean
114+
default: false
103115
patches:
104116
- name: lbImageRepository
105117
definitions:
@@ -256,6 +268,54 @@ spec:
256268
- op: add
257269
path: "/spec/template/spec/kubeadmConfigSpec/joinConfiguration/nodeRegistration/taints"
258270
value: []
271+
- name: controlPlaneExternalCloudProvider
272+
enabledIf: "{{ .externalCloudProvider }}"
273+
description: "Configures kubelet to run with an external cloud provider for control plane nodes."
274+
definitions:
275+
- selector:
276+
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
277+
kind: KubeadmControlPlaneTemplate
278+
matchResources:
279+
controlPlane: true
280+
jsonPatches:
281+
- op: add
282+
path: "/spec/template/spec/kubeadmConfigSpec/joinConfiguration/nodeRegistration/kubeletExtraArgs"
283+
value:
284+
cloud-provider: "external"
285+
- op: add
286+
path: "/spec/template/spec/kubeadmConfigSpec/initConfiguration/nodeRegistration/kubeletExtraArgs"
287+
value:
288+
cloud-provider: "external"
289+
- name: machineDeploymentExternalCloudProvider
290+
enabledIf: "{{ .externalCloudProvider }}"
291+
description: "Configures kubelet to run with an external cloud provider for machineDeployment nodes."
292+
definitions:
293+
- selector:
294+
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
295+
kind: KubeadmConfigTemplate
296+
matchResources:
297+
machineDeploymentClass:
298+
names:
299+
- '*-worker'
300+
jsonPatches:
301+
- op: add
302+
path: "/spec/template/spec/joinConfiguration/nodeRegistration/kubeletExtraArgs"
303+
value:
304+
cloud-provider: "external"
305+
- name: localEndpointIPv6
306+
enabledIf: "{{ .ipv6Primary }}"
307+
description: "Configures KCP to use IPv6 for its localAPIEndpoint."
308+
definitions:
309+
- selector:
310+
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
311+
kind: KubeadmControlPlaneTemplate
312+
matchResources:
313+
controlPlane: true
314+
jsonPatches:
315+
- op: add
316+
path: "/spec/template/spec/kubeadmConfigSpec/initConfiguration/localAPIEndpoint"
317+
value:
318+
advertiseAddress: '::'
259319
- name: podSecurityStandard
260320
description: "Adds an admission configuration for PodSecurity to the kube-apiserver."
261321
definitions:
@@ -368,7 +428,7 @@ spec:
368428
extraArgs: { enable-hostpath-provisioner: 'true' }
369429
apiServer:
370430
# host.docker.internal is required by kubetest when running on MacOS because of the way ports are proxied.
371-
certSANs: [localhost, 127.0.0.1, 0.0.0.0, host.docker.internal]
431+
certSANs: [localhost, host.docker.internal, "::", "::1", "127.0.0.1", "0.0.0.0"]
372432
initConfiguration:
373433
nodeRegistration:
374434
# We have to set the criSocket to containerd as kubeadm defaults to docker runtime if both containerd and docker sockets are found

0 commit comments

Comments
 (0)