Skip to content

Commit af7a224

Browse files
authored
Merge pull request #11986 from chrischdi/pr-preload-kindnetd-everywhere
🌱 e2e: ensure to always preload kindnetd to not hit ImagePullBackoff
2 parents 074533a + e3cab1b commit af7a224

16 files changed

+93
-51
lines changed

scripts/ci-e2e-lib.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,11 @@ kind:prepullAdditionalImages () {
259259
kind::prepullImage "quay.io/jetstack/cert-manager-cainjector:v1.16.3"
260260
kind::prepullImage "quay.io/jetstack/cert-manager-webhook:v1.16.3"
261261
kind::prepullImage "quay.io/jetstack/cert-manager-controller:v1.16.3"
262+
263+
# Pull all images defined in DOCKER_PRELOAD_IMAGES.
264+
for IMAGE in $(grep DOCKER_PRELOAD_IMAGES: < "$E2E_CONF_FILE" | sed -E 's/.*\[(.*)\].*/\1/' | tr ',' ' '); do
265+
kind::prepullImage "${IMAGE}"
266+
done
262267
}
263268

264269
# kind:prepullImage pre-pull a docker image if no already present locally.

test/e2e/config/docker.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,8 @@ variables:
380380
DOCKER_POD_CIDRS: "192.168.0.0/16"
381381
DOCKER_SERVICE_IPV6_CIDRS: "fd00:100:64::/108"
382382
DOCKER_POD_IPV6_CIDRS: "fd00:100:96::/48"
383+
# Needs to be kept in sync the CNI file referenced below for caching purposes.
384+
DOCKER_PRELOAD_IMAGES: "[kindest/kindnetd:v20250214-acbabc1a]"
383385
CNI: "./data/cni/kindnet/kindnet.yaml"
384386
KUBETEST_CONFIGURATION: "./data/kubetest/conformance.yaml"
385387
AUTOSCALER_WORKLOAD: "./data/autoscaler/autoscaler-to-workload-workload.yaml"

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

Lines changed: 57 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,34 @@
1-
# kindnetd networking manifest
1+
# source: https://github.com/kubernetes-sigs/kind/blob/v0.27.0/pkg/build/nodeimage/const_cni.go#L28
22
---
33
kind: ClusterRole
44
apiVersion: rbac.authorization.k8s.io/v1
55
metadata:
66
name: kindnet
77
rules:
8+
- apiGroups:
9+
- policy
10+
resources:
11+
- podsecuritypolicies
12+
verbs:
13+
- use
14+
resourceNames:
15+
- kindnet
816
- apiGroups:
917
- ""
1018
resources:
1119
- nodes
20+
- pods
21+
- namespaces
1222
verbs:
1323
- list
1424
- watch
15-
- patch
1625
- apiGroups:
17-
- ""
26+
- "networking.k8s.io"
1827
resources:
19-
- configmaps
28+
- networkpolicies
2029
verbs:
21-
- get
30+
- list
31+
- watch
2232
---
2333
kind: ClusterRoleBinding
2434
apiVersion: rbac.authorization.k8s.io/v1
@@ -29,9 +39,9 @@ roleRef:
2939
kind: ClusterRole
3040
name: kindnet
3141
subjects:
32-
- kind: ServiceAccount
33-
name: kindnet
34-
namespace: kube-system
42+
- kind: ServiceAccount
43+
name: kindnet
44+
namespace: kube-system
3545
---
3646
apiVersion: v1
3747
kind: ServiceAccount
@@ -60,55 +70,52 @@ spec:
6070
k8s-app: kindnet
6171
spec:
6272
hostNetwork: true
73+
nodeSelector:
74+
kubernetes.io/os: linux
6375
tolerations:
64-
- operator: Exists
65-
effect: NoSchedule
76+
- operator: Exists
6677
serviceAccountName: kindnet
6778
containers:
68-
- name: kindnet-cni
69-
image: kindest/kindnetd:v20230511-dc714da8
70-
env:
71-
- name: HOST_IP
72-
valueFrom:
73-
fieldRef:
74-
fieldPath: status.hostIP
75-
- name: POD_IP
76-
valueFrom:
77-
fieldRef:
78-
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
81-
- name: POD_SUBNET
82-
value: '${DOCKER_POD_CIDRS},${DOCKER_POD_IPV6_CIDRS}'
83-
volumeMounts:
84-
- name: cni-cfg
85-
mountPath: /etc/cni/net.d
86-
- name: xtables-lock
87-
mountPath: /run/xtables.lock
88-
readOnly: false
89-
- name: lib-modules
90-
mountPath: /lib/modules
91-
readOnly: true
92-
resources:
93-
requests:
94-
cpu: "100m"
95-
memory: "50Mi"
96-
limits:
97-
cpu: "100m"
98-
memory: "50Mi"
99-
securityContext:
100-
privileged: false
101-
capabilities:
102-
add: ["NET_RAW", "NET_ADMIN"]
79+
- name: kindnet-cni
80+
# Needs to be kept in sync with DOCKER_PRELOAD_IMAGES in test/e2e/config/docker.yaml for caching purposes.
81+
image: kindest/kindnetd:v20250214-acbabc1a
82+
env:
83+
- name: HOST_IP
84+
valueFrom:
85+
fieldRef:
86+
fieldPath: status.hostIP
87+
- name: POD_IP
88+
valueFrom:
89+
fieldRef:
90+
fieldPath: status.podIP
91+
# We're using the dualstack CIDRs here. The order doesn't matter for kindnet as the loops are run concurrently.
92+
# REF: https://github.com/kubernetes-sigs/kind/blob/3dbeb894e3092a336ab4278d3823e73a1d66aff7/images/kindnetd/cmd/kindnetd/main.go#L149-L175
93+
- name: POD_SUBNET
94+
value: '${DOCKER_POD_CIDRS},${DOCKER_POD_IPV6_CIDRS}'
95+
volumeMounts:
96+
- name: cni-cfg
97+
mountPath: /etc/cni/net.d
98+
- name: xtables-lock
99+
mountPath: /run/xtables.lock
100+
readOnly: false
101+
- name: lib-modules
102+
mountPath: /lib/modules
103+
readOnly: true
104+
resources:
105+
requests:
106+
cpu: "100m"
107+
memory: "50Mi"
108+
limits:
109+
cpu: "100m"
110+
memory: "50Mi"
111+
securityContext:
112+
privileged: false
113+
capabilities:
114+
add: ["NET_RAW", "NET_ADMIN"]
103115
volumes:
104-
- name: cni-bin
105-
hostPath:
106-
path: /opt/cni/bin
107-
type: DirectoryOrCreate
108116
- name: cni-cfg
109117
hostPath:
110118
path: /etc/cni/net.d
111-
type: DirectoryOrCreate
112119
- name: xtables-lock
113120
hostPath:
114121
path: /run/xtables.lock

test/e2e/data/infrastructure-docker/main/cluster-template-kcp-remediation/cluster-with-kcp.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ metadata:
3737
name: "${CLUSTER_NAME}-control-plane"
3838
spec:
3939
template:
40-
spec: {}
40+
spec:
41+
preLoadImages: ${DOCKER_PRELOAD_IMAGES:-[]}
4142
---
4243
# KubeadmControlPlane referenced by the Cluster
4344
kind: KubeadmControlPlane

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ spec:
114114
extraMounts:
115115
- containerPath: "/var/run/docker.sock"
116116
hostPath: "/var/run/docker.sock"
117+
preLoadImages: ${DOCKER_PRELOAD_IMAGES:-[]}
117118
---
118119
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
119120
kind: DockerMachineTemplate
@@ -125,6 +126,7 @@ spec:
125126
extraMounts:
126127
- containerPath: "/var/run/docker.sock"
127128
hostPath: "/var/run/docker.sock"
129+
preLoadImages: ${DOCKER_PRELOAD_IMAGES:-[]}
128130
---
129131
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
130132
kind: DockerMachinePoolTemplate
@@ -137,6 +139,7 @@ spec:
137139
extraMounts:
138140
- containerPath: "/var/run/docker.sock"
139141
hostPath: "/var/run/docker.sock"
142+
preLoadImages: ${DOCKER_PRELOAD_IMAGES:-[]}
140143
---
141144
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
142145
kind: KubeadmConfigTemplate

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,7 @@ spec:
582582
extraMounts:
583583
- containerPath: "/var/run/docker.sock"
584584
hostPath: "/var/run/docker.sock"
585+
preLoadImages: ${DOCKER_PRELOAD_IMAGES:-[]}
585586
---
586587
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
587588
kind: DockerMachineTemplate
@@ -602,6 +603,7 @@ spec:
602603
extraMounts:
603604
- containerPath: "/var/run/docker.sock"
604605
hostPath: "/var/run/docker.sock"
606+
preLoadImages: ${DOCKER_PRELOAD_IMAGES:-[]}
605607
---
606608
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
607609
kind: DockerMachinePoolTemplate
@@ -623,6 +625,7 @@ spec:
623625
extraMounts:
624626
- containerPath: "/var/run/docker.sock"
625627
hostPath: "/var/run/docker.sock"
628+
preLoadImages: ${DOCKER_PRELOAD_IMAGES:-[]}
626629
---
627630
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
628631
kind: KubeadmConfigTemplate

test/e2e/data/infrastructure-docker/v0.3/bases/cluster-with-kcp.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ spec:
4343
extraMounts:
4444
- containerPath: "/var/run/docker.sock"
4545
hostPath: "/var/run/docker.sock"
46+
preLoadImages: ${DOCKER_PRELOAD_IMAGES:-[]}
4647
---
4748
# KubeadmControlPlane referenced by the Cluster object with
4849
# - the label kcp-adoption.step2, because it should be created in the second step of the kcp-adoption test.

test/e2e/data/infrastructure-docker/v0.3/bases/md.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ spec:
1313
extraMounts:
1414
- containerPath: "/var/run/docker.sock"
1515
hostPath: "/var/run/docker.sock"
16+
preLoadImages: ${DOCKER_PRELOAD_IMAGES:-[]}
1617
---
1718
# KubeadmConfigTemplate referenced by the MachineDeployment
1819
apiVersion: bootstrap.cluster.x-k8s.io/v1alpha3

test/e2e/data/infrastructure-docker/v0.4/bases/cluster-with-kcp.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ spec:
4343
extraMounts:
4444
- containerPath: "/var/run/docker.sock"
4545
hostPath: "/var/run/docker.sock"
46+
preLoadImages: ${DOCKER_PRELOAD_IMAGES:-[]}
4647
---
4748
# KubeadmControlPlane referenced by the Cluster object with
4849
# - the label kcp-adoption.step2, because it should be created in the second step of the kcp-adoption test.

test/e2e/data/infrastructure-docker/v0.4/bases/md.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ spec:
1313
extraMounts:
1414
- containerPath: "/var/run/docker.sock"
1515
hostPath: "/var/run/docker.sock"
16+
preLoadImages: ${DOCKER_PRELOAD_IMAGES:-[]}
1617
---
1718
# KubeadmConfigTemplate referenced by the MachineDeployment
1819
apiVersion: bootstrap.cluster.x-k8s.io/v1alpha4

0 commit comments

Comments
 (0)