59
59
- --name={{ .vars.clusterName }}
60
60
- --loglevel=debug
61
61
- --kubeadm-verbosity={{ .vars.kubeadmVerbosity }}
62
- - --kubeadm-feature-gate="NodeLocalCRISocket=true "
62
+ - --kubeadm-feature-gate="NodeLocalCRISocket=false "
63
63
- --copy-certs=auto
64
64
timeout : 5m
65
65
- name : join
@@ -84,16 +84,16 @@ tasks:
84
84
set -x
85
85
86
86
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}" )
88
88
89
89
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}")
91
91
92
92
if [ -z "$annotation" ]; then
93
93
echo "Annotation not found on node $node"
94
+ exit 1
94
95
else
95
96
echo "Annotation found on node $node: $annotation"
96
- exit 1
97
97
fi
98
98
done
99
99
' || {
@@ -118,8 +118,35 @@ tasks:
118
118
${CMD} bash -c '
119
119
if [[ -f "/var/lib/kubelet/instance-config.yaml" ]] && grep -q "containerRuntimeEndpoint:" /var/lib/kubelet/instance-config.yaml; then
120
120
echo "File exists and contains 'containerRuntimeEndpoint:' field."
121
+ exit 1
121
122
else
122
123
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."
123
150
exit 1
124
151
fi
125
152
' || {
@@ -157,9 +184,9 @@ tasks:
157
184
${CMD} bash -c '
158
185
if [[ -f "/var/lib/kubelet/instance-config.yaml" ]] && grep -q "containerRuntimeEndpoint:" /var/lib/kubelet/instance-config.yaml; then
159
186
echo "File exists and contains 'containerRuntimeEndpoint:' field."
187
+ exit 1
160
188
else
161
189
echo "File does not exist or does not contain 'containerRuntimeEndpoint:' field."
162
- exit 1
163
190
fi
164
191
' || {
165
192
echo "Command failed for $node. Exiting.";
@@ -169,9 +196,9 @@ tasks:
169
196
170
197
exit 0
171
198
timeout : 5m
172
- - name : remove-config
199
+ - name : check-flag-after-upgrade
173
200
description : |
174
- Remove the kubelet instance configuration from work node.
201
+ Check that the container-runtime-endpoint flag does not exist on each node.
175
202
cmd : /bin/bash
176
203
args :
177
204
- -c
@@ -181,36 +208,41 @@ tasks:
181
208
for node in control-plane-{1..3} worker-{1..2}; do
182
209
CMD="docker exec {{ .vars.clusterName }}-$node"
183
210
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
+ ' || {
185
219
echo "Command failed for $node. Exiting.";
186
220
exit 1;
187
221
}
188
222
done
189
223
190
224
exit 0
191
225
timeout : 5m
192
- - name : add-cri-socket-annotation
226
+ - name : check-annotation-after-upgrade
193
227
description : |
194
- Add the cri-socket annotation to each node.
228
+ Check that the cri-socket annotation does not exist on each node.
195
229
cmd : /bin/bash
196
230
args :
197
231
- -c
198
232
- |
199
233
set -x
200
234
201
235
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}")
206
237
207
238
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"
213
243
exit 1
244
+ else
245
+ echo "Annotation found on node $node: $annotation"
214
246
fi
215
247
done
216
248
' || {
@@ -220,33 +252,39 @@ tasks:
220
252
221
253
exit 0
222
254
timeout : 5m
223
- - name : check-and-add-flag
255
+
256
+ - name : enable-feature
224
257
description : |
225
- Check and add the container-runtime-endpoint flag to each node's kubeadm-flags.env file
258
+ enable the nodeLocalCRISocket Feature gate.
226
259
cmd : /bin/bash
227
260
args :
228
261
- -c
229
262
- |
230
263
set -x
231
264
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
+ }
250
288
251
289
exit 0
252
290
timeout : 5m
@@ -299,10 +337,10 @@ tasks:
299
337
set -x
300
338
301
339
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}" )
303
341
304
342
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}")
306
344
307
345
if [ -z "$annotation" ]; then
308
346
echo "Annotation not found on node $node"
@@ -315,7 +353,6 @@ tasks:
315
353
echo "Command failed for $node. Exiting.";
316
354
exit 1;
317
355
}
318
-
319
356
exit 0
320
357
timeout : 5m
321
358
- name : check-flag-after-second-upgrade
@@ -334,6 +371,8 @@ tasks:
334
371
if [[ -f "/var/lib/kubelet/kubeadm-flags.env" ]] && grep -q "container-runtime-endpoint" /var/lib/kubelet/kubeadm-flags.env; then
335
372
echo "File exists and contains 'container-runtime-endpoint' field."
336
373
exit 1
374
+ else
375
+ echo "File does not contain 'container-runtime-endpoint' field."
337
376
fi
338
377
' || {
339
378
echo "Command failed for $node. Exiting.";
0 commit comments