Skip to content

Commit 70e0eea

Browse files
committed
add NodeLocalCRISocket beta stage tests
1 parent 85c05b5 commit 70e0eea

File tree

2 files changed

+162
-84
lines changed

2 files changed

+162
-84
lines changed

kinder/ci/tools/update-workflows/templates/workflows/instance-config-tasks.yaml

Lines changed: 81 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ tasks:
5959
- --name={{ .vars.clusterName }}
6060
- --loglevel=debug
6161
- --kubeadm-verbosity={{ .vars.kubeadmVerbosity }}
62-
- --kubeadm-feature-gate="NodeLocalCRISocket=true"
62+
- --kubeadm-feature-gate="NodeLocalCRISocket=false"
6363
- --copy-certs=auto
6464
timeout: 5m
6565
- name: join
@@ -84,16 +84,16 @@ tasks:
8484
set -x
8585
8686
docker exec {{ .vars.clusterName }}-control-plane-1 bash -c '
87-
nodes=$(KUBECONFIG=/etc/kubernetes/admin.conf kubectl get nodes -o jsonpath='{.items[*].metadata.name}')
87+
nodes=$(KUBECONFIG=/etc/kubernetes/admin.conf kubectl get nodes -o jsonpath="{.items[*].metadata.name}")
8888
8989
for node in $nodes; do
90-
annotation=$(KUBECONFIG=/etc/kubernetes/admin.conf kubectl get node "$node" -o jsonpath="{.metadata.annotations['kubeadm\.alpha\.kubernetes\.io/cri-socket']}")
90+
annotation=$(KUBECONFIG=/etc/kubernetes/admin.conf kubectl get node "$node" -o jsonpath="{.metadata.annotations.kubeadm\.alpha\.kubernetes\.io\/cri-socket}")
9191
9292
if [ -z "$annotation" ]; then
9393
echo "Annotation not found on node $node"
94+
exit 1
9495
else
9596
echo "Annotation found on node $node: $annotation"
96-
exit 1
9797
fi
9898
done
9999
' || {
@@ -118,8 +118,35 @@ tasks:
118118
${CMD} bash -c '
119119
if [[ -f "/var/lib/kubelet/instance-config.yaml" ]] && grep -q "containerRuntimeEndpoint:" /var/lib/kubelet/instance-config.yaml; then
120120
echo "File exists and contains 'containerRuntimeEndpoint:' field."
121+
exit 1
121122
else
122123
echo "File does not exist or does not contain 'containerRuntimeEndpoint:' field."
124+
fi
125+
' || {
126+
echo "Command failed for $node. Exiting.";
127+
exit 1;
128+
}
129+
done
130+
131+
exit 0
132+
timeout: 5m
133+
- name: check-flag
134+
description: |
135+
Check that the container-runtime-endpoint flag does not exist on each node.
136+
cmd: /bin/bash
137+
args:
138+
- -c
139+
- |
140+
set -x
141+
142+
for node in control-plane-{1..3} worker-{1..2}; do
143+
CMD="docker exec {{ .vars.clusterName }}-$node"
144+
145+
${CMD} bash -c '
146+
if [[ -f "/var/lib/kubelet/kubeadm-flags.env" ]] && grep -q "container-runtime-endpoint" /var/lib/kubelet/kubeadm-flags.env; then
147+
echo "File exists and contains 'container-runtime-endpoint' field."
148+
else
149+
echo "File does not contain 'container-runtime-endpoint' field."
123150
exit 1
124151
fi
125152
' || {
@@ -157,9 +184,9 @@ tasks:
157184
${CMD} bash -c '
158185
if [[ -f "/var/lib/kubelet/instance-config.yaml" ]] && grep -q "containerRuntimeEndpoint:" /var/lib/kubelet/instance-config.yaml; then
159186
echo "File exists and contains 'containerRuntimeEndpoint:' field."
187+
exit 1
160188
else
161189
echo "File does not exist or does not contain 'containerRuntimeEndpoint:' field."
162-
exit 1
163190
fi
164191
' || {
165192
echo "Command failed for $node. Exiting.";
@@ -169,9 +196,9 @@ tasks:
169196
170197
exit 0
171198
timeout: 5m
172-
- name: remove-config
199+
- name: check-flag-after-upgrade
173200
description: |
174-
Remove the kubelet instance configuration from work node.
201+
Check that the container-runtime-endpoint flag does not exist on each node.
175202
cmd: /bin/bash
176203
args:
177204
- -c
@@ -181,36 +208,41 @@ tasks:
181208
for node in control-plane-{1..3} worker-{1..2}; do
182209
CMD="docker exec {{ .vars.clusterName }}-$node"
183210
184-
${CMD} bash -c 'rm -f /var/lib/kubelet/instance-config.yaml' || {
211+
${CMD} bash -c '
212+
if [[ -f "/var/lib/kubelet/kubeadm-flags.env" ]] && grep -q "container-runtime-endpoint" /var/lib/kubelet/kubeadm-flags.env; then
213+
echo "File exists and contains 'container-runtime-endpoint' field."
214+
else
215+
echo "File does not contain 'container-runtime-endpoint' field."
216+
exit 1
217+
fi
218+
' || {
185219
echo "Command failed for $node. Exiting.";
186220
exit 1;
187221
}
188222
done
189223
190224
exit 0
191225
timeout: 5m
192-
- name: add-cri-socket-annotation
226+
- name: check-annotation-after-upgrade
193227
description: |
194-
Add the cri-socket annotation to each node.
228+
Check that the cri-socket annotation does not exist on each node.
195229
cmd: /bin/bash
196230
args:
197231
- -c
198232
- |
199233
set -x
200234
201235
docker exec {{ .vars.clusterName }}-control-plane-1 bash -c '
202-
ANNOTATION_KEY="kubeadm.alpha.kubernetes.io/cri-socket"
203-
ANNOTATION_VALUE="unix:///var/run/containerd/containerd.sock"
204-
205-
nodes=$(KUBECONFIG=/etc/kubernetes/admin.conf kubectl get nodes -o jsonpath='{.items[*].metadata.name}')
236+
nodes=$(KUBECONFIG=/etc/kubernetes/admin.conf kubectl get nodes -o jsonpath="{.items[*].metadata.name}")
206237
207238
for node in $nodes; do
208-
KUBECONFIG=/etc/kubernetes/admin.conf kubectl annotate node "$node" "$ANNOTATION_KEY=$ANNOTATION_VALUE" --overwrite
209-
if [ $? -eq 0 ]; then
210-
echo "Successfully added annotation to node $node."
211-
else
212-
echo "Failed to add annotation to node $node."
239+
annotation=$(KUBECONFIG=/etc/kubernetes/admin.conf kubectl get node "$node" -o jsonpath="{.metadata.annotations.kubeadm\.alpha\.kubernetes\.io\/cri-socket}")
240+
241+
if [ -z "$annotation" ]; then
242+
echo "Annotation not found on node $node"
213243
exit 1
244+
else
245+
echo "Annotation found on node $node: $annotation"
214246
fi
215247
done
216248
' || {
@@ -220,33 +252,39 @@ tasks:
220252
221253
exit 0
222254
timeout: 5m
223-
- name: check-and-add-flag
255+
256+
- name: enable-feature
224257
description: |
225-
Check and add the container-runtime-endpoint flag to each node's kubeadm-flags.env file
258+
enable the nodeLocalCRISocket Feature gate.
226259
cmd: /bin/bash
227260
args:
228261
- -c
229262
- |
230263
set -x
231264
232-
for node in control-plane-{1..3} worker-{1..2}; do
233-
CMD="docker exec {{ .vars.clusterName }}-$node"
234-
235-
${CMD} bash -c '
236-
FILE="/var/lib/kubelet/kubeadm-flags.env"
237-
NEW_ARG="--container-runtime-endpoint=unix:///run/containerd/containerd.sock"
238-
239-
if grep -q "container-runtime-endpoint" "$FILE"; then
240-
echo "flag container-runtime-endpoint already exists"
241-
exit 1
242-
fi
243-
244-
sed -i "/^KUBELET_KUBEADM_ARGS=/ s|\"$| $NEW_ARG\"|" "$FILE"
245-
' || {
246-
echo "Command failed for $node. Exiting.";
247-
exit 1;
248-
}
249-
done
265+
docker exec {{ .vars.clusterName }}-control-plane-1 bash -c '
266+
KUBECONFIG=/etc/kubernetes/admin.conf kubectl get configmap kubeadm-config -n kube-system -o yaml > config.yaml
267+
sed '\''s/^\( *\)\(NodeLocalCRISocket:\) false$/\1\2 true/'\'' config.yaml > updated_config.yaml
268+
269+
if grep -q "NodeLocalCRISocket: true" updated_config.yaml; then
270+
echo "Updating ConfigMap YAML Successful."
271+
else
272+
echo "Updating ConfigMap YAML failed."
273+
exit 1
274+
fi
275+
276+
if KUBECONFIG=/etc/kubernetes/admin.conf kubectl apply -f updated_config.yaml; then
277+
echo "ConfigMap updated successfully."
278+
else
279+
echo "Failed to apply updated ConfigMap."
280+
exit 1
281+
fi
282+
283+
rm config.yaml updated_config.yaml
284+
' || {
285+
echo "Command failed for $node. Exiting.";
286+
exit 1;
287+
}
250288
251289
exit 0
252290
timeout: 5m
@@ -299,10 +337,10 @@ tasks:
299337
set -x
300338
301339
docker exec {{ .vars.clusterName }}-control-plane-1 bash -c '
302-
nodes=$(KUBECONFIG=/etc/kubernetes/admin.conf kubectl get nodes -o jsonpath='{.items[*].metadata.name}')
340+
nodes=$(KUBECONFIG=/etc/kubernetes/admin.conf kubectl get nodes -o jsonpath="{.items[*].metadata.name}")
303341
304342
for node in $nodes; do
305-
annotation=$(KUBECONFIG=/etc/kubernetes/admin.conf kubectl get node "$node" -o jsonpath="{.metadata.annotations['kubeadm\.alpha\.kubernetes\.io/cri-socket']}")
343+
annotation=$(KUBECONFIG=/etc/kubernetes/admin.conf kubectl get node "$node" -o jsonpath="{.metadata.annotations.kubeadm\.alpha\.kubernetes\.io\/cri-socket}")
306344
307345
if [ -z "$annotation" ]; then
308346
echo "Annotation not found on node $node"
@@ -315,7 +353,6 @@ tasks:
315353
echo "Command failed for $node. Exiting.";
316354
exit 1;
317355
}
318-
319356
exit 0
320357
timeout: 5m
321358
- name: check-flag-after-second-upgrade
@@ -334,6 +371,8 @@ tasks:
334371
if [[ -f "/var/lib/kubelet/kubeadm-flags.env" ]] && grep -q "container-runtime-endpoint" /var/lib/kubelet/kubeadm-flags.env; then
335372
echo "File exists and contains 'container-runtime-endpoint' field."
336373
exit 1
374+
else
375+
echo "File does not contain 'container-runtime-endpoint' field."
337376
fi
338377
' || {
339378
echo "Command failed for $node. Exiting.";

0 commit comments

Comments
 (0)