diff --git a/kinder/ci/tools/update-workflows/templates/workflows/instance-config-tasks.yaml b/kinder/ci/tools/update-workflows/templates/workflows/instance-config-tasks.yaml index c9374420..6fbd94c5 100644 --- a/kinder/ci/tools/update-workflows/templates/workflows/instance-config-tasks.yaml +++ b/kinder/ci/tools/update-workflows/templates/workflows/instance-config-tasks.yaml @@ -218,6 +218,36 @@ tasks: exit 1; } + exit 0 + timeout: 5m +- name: check-and-add-flag + description: | + Check and add the container-runtime-endpoint flag to each node's kubeadm-flags.env file + cmd: /bin/bash + args: + - -c + - | + set -x + + for node in control-plane-{1..3} worker-{1..2}; do + CMD="docker exec {{ .vars.clusterName }}-$node" + + ${CMD} bash -c ' + FILE="/var/lib/kubelet/kubeadm-flags.env" + NEW_ARG="--container-runtime-endpoint=unix:///run/containerd/containerd.sock" + + if grep -q "container-runtime-endpoint" "$FILE"; then + echo "flag container-runtime-endpoint already exists" + exit 1 + fi + + sed -i "/^KUBELET_KUBEADM_ARGS=/ s|\"$| $NEW_ARG\"|" "$FILE" + ' || { + echo "Command failed for $node. Exiting."; + exit 1; + } + done + exit 0 timeout: 5m - name: upgrade-again @@ -257,6 +287,60 @@ tasks: } done + exit 0 + timeout: 5m +- name: check-annotation-after-second-upgrade + description: | + Check that the cri-socket annotation does not exist on each node. + cmd: /bin/bash + args: + - -c + - | + set -x + + docker exec {{ .vars.clusterName }}-control-plane-1 bash -c ' + nodes=$(KUBECONFIG=/etc/kubernetes/admin.conf kubectl get nodes -o jsonpath='{.items[*].metadata.name}') + + for node in $nodes; do + annotation=$(KUBECONFIG=/etc/kubernetes/admin.conf kubectl get node "$node" -o jsonpath="{.metadata.annotations['kubeadm\.alpha\.kubernetes\.io/cri-socket']}") + + if [ -z "$annotation" ]; then + echo "Annotation not found on node $node" + else + echo "Annotation found on node $node: $annotation" + exit 1 + fi + done + ' || { + echo "Command failed for $node. Exiting."; + exit 1; + } + + exit 0 + timeout: 5m +- name: check-flag-after-second-upgrade + description: | + Check that the container-runtime-endpoint flag does not exist on each node. + cmd: /bin/bash + args: + - -c + - | + set -x + + for node in control-plane-{1..3} worker-{1..2}; do + CMD="docker exec {{ .vars.clusterName }}-$node" + + ${CMD} bash -c ' + if [[ -f "/var/lib/kubelet/kubeadm-flags.env" ]] && grep -q "container-runtime-endpoint" /var/lib/kubelet/kubeadm-flags.env; then + echo "File exists and contains 'container-runtime-endpoint' field." + exit 1 + fi + ' || { + echo "Command failed for $node. Exiting."; + exit 1; + } + done + exit 0 timeout: 5m - name: cluster-info diff --git a/kinder/ci/workflows/instance-config-tasks.yaml b/kinder/ci/workflows/instance-config-tasks.yaml index 15257833..24f054fc 100644 --- a/kinder/ci/workflows/instance-config-tasks.yaml +++ b/kinder/ci/workflows/instance-config-tasks.yaml @@ -219,6 +219,36 @@ tasks: exit 1; } + exit 0 + timeout: 5m +- name: check-and-add-flag + description: | + Check and add the container-runtime-endpoint flag to each node's kubeadm-flags.env file + cmd: /bin/bash + args: + - -c + - | + set -x + + for node in control-plane-{1..3} worker-{1..2}; do + CMD="docker exec {{ .vars.clusterName }}-$node" + + ${CMD} bash -c ' + FILE="/var/lib/kubelet/kubeadm-flags.env" + NEW_ARG="--container-runtime-endpoint=unix:///run/containerd/containerd.sock" + + if grep -q "container-runtime-endpoint" "$FILE"; then + echo "flag container-runtime-endpoint already exists" + exit 1 + fi + + sed -i "/^KUBELET_KUBEADM_ARGS=/ s|\"$| $NEW_ARG\"|" "$FILE" + ' || { + echo "Command failed for $node. Exiting."; + exit 1; + } + done + exit 0 timeout: 5m - name: upgrade-again @@ -258,6 +288,60 @@ tasks: } done + exit 0 + timeout: 5m +- name: check-annotation-after-second-upgrade + description: | + Check that the cri-socket annotation does not exist on each node. + cmd: /bin/bash + args: + - -c + - | + set -x + + docker exec {{ .vars.clusterName }}-control-plane-1 bash -c ' + nodes=$(KUBECONFIG=/etc/kubernetes/admin.conf kubectl get nodes -o jsonpath='{.items[*].metadata.name}') + + for node in $nodes; do + annotation=$(KUBECONFIG=/etc/kubernetes/admin.conf kubectl get node "$node" -o jsonpath="{.metadata.annotations['kubeadm\.alpha\.kubernetes\.io/cri-socket']}") + + if [ -z "$annotation" ]; then + echo "Annotation not found on node $node" + else + echo "Annotation found on node $node: $annotation" + exit 1 + fi + done + ' || { + echo "Command failed for $node. Exiting."; + exit 1; + } + + exit 0 + timeout: 5m +- name: check-flag-after-second-upgrade + description: | + Check that the container-runtime-endpoint flag does not exist on each node. + cmd: /bin/bash + args: + - -c + - | + set -x + + for node in control-plane-{1..3} worker-{1..2}; do + CMD="docker exec {{ .vars.clusterName }}-$node" + + ${CMD} bash -c ' + if [[ -f "/var/lib/kubelet/kubeadm-flags.env" ]] && grep -q "container-runtime-endpoint" /var/lib/kubelet/kubeadm-flags.env; then + echo "File exists and contains 'container-runtime-endpoint' field." + exit 1 + fi + ' || { + echo "Command failed for $node. Exiting."; + exit 1; + } + done + exit 0 timeout: 5m - name: cluster-info