Skip to content

Commit

Permalink
kubeadm: enable join dry-run e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
SataQiu committed Oct 30, 2024
1 parent 5433725 commit ed957ec
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,29 @@ tasks:
- --worker-nodes={{ .vars.workerNodes }}
- --loglevel=debug
timeout: 5m
- name: init-dryrun
- name: dryrun-without-cluster
description: |
Initializes the Kubernetes cluster in dryrun mode
Run kubeadm commands in dryrun mode without a real cluster
cmd: /bin/bash
args:
- -c
- |
docker exec {{ .vars.clusterName }}-control-plane-1 bash -c "until crictl ps &> /dev/null; do echo 'Waiting for the container runtime to be running ...'; sleep 1; done"
docker exec {{ .vars.clusterName }}-control-plane-1 kubeadm init --ignore-preflight-errors={{ .vars.kubeadmIgnorePreflightErrors }} --kubernetes-version={{ .vars.kubernetesVersion }} --dry-run=true --v={{ .vars.kubeadmVerbosity }} || exit 1
docker exec {{ .vars.clusterName }}-control-plane-1 kubeadm init --ignore-preflight-errors={{ .vars.kubeadmIgnorePreflightErrors }} --kubernetes-version={{ .vars.kubernetesVersion }} --upload-certs=true --dry-run=true --v={{ .vars.kubeadmVerbosity }} || exit 1
set -x
required_version="1.32" # dryrun without cluster is available since v1.32
current_version=$(echo "{{ .vars.kubernetesVersion }}" | grep -oP '\d+\.\d+')
if awk "BEGIN {exit !($current_version < $required_version)}"; then
echo "Full dryrun support without cluster is not available for Kubernetes version {{ .vars.kubernetesVersion }}, only init-dryrun will be executed for this task."
docker exec {{ .vars.clusterName }}-control-plane-1 bash -c "until crictl ps &> /dev/null; do echo 'Waiting for the container runtime to be running ...'; sleep 1; done"
docker exec {{ .vars.clusterName }}-control-plane-1 kubeadm init --ignore-preflight-errors={{ .vars.kubeadmIgnorePreflightErrors }} --kubernetes-version={{ .vars.kubernetesVersion }} --dry-run --v={{ .vars.kubeadmVerbosity }} || exit 1
else
docker exec {{ .vars.clusterName }}-control-plane-1 bash -c "until crictl ps &> /dev/null; do echo 'Waiting for the container runtime to be running ...'; sleep 1; done"
docker exec {{ .vars.clusterName }}-control-plane-1 kubeadm init --ignore-preflight-errors={{ .vars.kubeadmIgnorePreflightErrors }} --kubernetes-version={{ .vars.kubernetesVersion }} --dry-run --v={{ .vars.kubeadmVerbosity }} || exit 1
docker exec {{ .vars.clusterName }}-control-plane-1 kubeadm join 192.168.0.101:6443 --control-plane --token abcdef.abcdef0123456789 --discovery-token-ca-cert-hash sha256:3b793efefe27a19f93b0fbe6e637e9c41d0dde8a377d6ab1c0f656bf1136dd8a --certificate-key 2e3c4239bc78c27f40530ddc2df7049a2c5ff146e5a702e9c9b6cdbec70df9f3 --ignore-preflight-errors={{ .vars.kubeadmIgnorePreflightErrors }} --dry-run --v={{ .vars.kubeadmVerbosity }} || exit 1
docker exec {{ .vars.clusterName }}-control-plane-1 kubeadm join 192.168.0.101:6443 --token abcdef.abcdef0123456789 --discovery-token-ca-cert-hash sha256:3b793efefe27a19f93b0fbe6e637e9c41d0dde8a377d6ab1c0f656bf1136dd8a --ignore-preflight-errors={{ .vars.kubeadmIgnorePreflightErrors }} --dry-run --v={{ .vars.kubeadmVerbosity }} || exit 1
docker exec {{ .vars.clusterName }}-control-plane-1 /kinder/upgrade/{{ .vars.upgradeVersion }}/kubeadm upgrade apply -f {{ .vars.upgradeVersion }} --ignore-preflight-errors={{ .vars.kubeadmIgnorePreflightErrors }} --allow-release-candidate-upgrades=true --allow-experimental-upgrades=true --dry-run --v={{ .vars.kubeadmVerbosity }} || exit 1
docker exec {{ .vars.clusterName }}-control-plane-1 /kinder/upgrade/{{ .vars.upgradeVersion }}/kubeadm upgrade node --ignore-preflight-errors={{ .vars.kubeadmIgnorePreflightErrors }} --dry-run --v={{ .vars.kubeadmVerbosity }} || exit 1
docker exec {{ .vars.clusterName }}-control-plane-1 kubeadm reset --force=true --ignore-preflight-errors={{ .vars.kubeadmIgnorePreflightErrors }} --dry-run --v={{ .vars.kubeadmVerbosity }} || exit 1
fi
timeout: 5m
- name: init
description: |
Expand All @@ -80,7 +93,7 @@ tasks:
- -c
- |
docker exec {{ .vars.clusterName }}-worker-1 bash -c "until crictl ps &> /dev/null; do echo 'Waiting for the container runtime to be running ...'; sleep 1; done"
docker exec {{ .vars.clusterName }}-worker-1 $(docker exec {{ .vars.clusterName }}-control-plane-1 kubeadm token create --print-join-command) --ignore-preflight-errors={{ .vars.kubeadmIgnorePreflightErrors }} --dry-run=true --v={{ .vars.kubeadmVerbosity }} || exit 1
docker exec {{ .vars.clusterName }}-worker-1 $(docker exec {{ .vars.clusterName }}-control-plane-1 kubeadm token create --print-join-command) --ignore-preflight-errors={{ .vars.kubeadmIgnorePreflightErrors }} --dry-run --v={{ .vars.kubeadmVerbosity }} || exit 1
timeout: 10m
- name: join
description: |
Expand All @@ -100,17 +113,17 @@ tasks:
args:
- -c
- |
docker exec {{ .vars.clusterName }}-control-plane-1 /kinder/upgrade/{{ .vars.upgradeVersion }}/kubeadm upgrade apply -f {{ .vars.upgradeVersion }} --ignore-preflight-errors={{ .vars.kubeadmIgnorePreflightErrors }} --allow-release-candidate-upgrades=true --allow-experimental-upgrades=true --dry-run=true --v={{ .vars.kubeadmVerbosity }} || exit 1
docker exec {{ .vars.clusterName }}-worker-1 /kinder/upgrade/{{ .vars.upgradeVersion }}/kubeadm upgrade node --ignore-preflight-errors={{ .vars.kubeadmIgnorePreflightErrors }} --dry-run=true --v={{ .vars.kubeadmVerbosity }} || exit 1
docker exec {{ .vars.clusterName }}-control-plane-1 /kinder/upgrade/{{ .vars.upgradeVersion }}/kubeadm upgrade apply -f {{ .vars.upgradeVersion }} --ignore-preflight-errors={{ .vars.kubeadmIgnorePreflightErrors }} --allow-release-candidate-upgrades=true --allow-experimental-upgrades=true --dry-run --v={{ .vars.kubeadmVerbosity }} || exit 1
docker exec {{ .vars.clusterName }}-worker-1 /kinder/upgrade/{{ .vars.upgradeVersion }}/kubeadm upgrade node --ignore-preflight-errors={{ .vars.kubeadmIgnorePreflightErrors }} --dry-run --v={{ .vars.kubeadmVerbosity }} || exit 1
- name: reset-dryrun
description: |
Exec kubeadm reset in dryrun mode
cmd: /bin/bash
args:
- -c
- |
docker exec {{ .vars.clusterName }}-control-plane-1 kubeadm reset --force=true --ignore-preflight-errors={{ .vars.kubeadmIgnorePreflightErrors }} --dry-run=true --v={{ .vars.kubeadmVerbosity }} || exit 1
docker exec {{ .vars.clusterName }}-worker-1 kubeadm reset --force=true --ignore-preflight-errors={{ .vars.kubeadmIgnorePreflightErrors }} --dry-run=true --v={{ .vars.kubeadmVerbosity }} || exit 1
docker exec {{ .vars.clusterName }}-control-plane-1 kubeadm reset --force=true --ignore-preflight-errors={{ .vars.kubeadmIgnorePreflightErrors }} --dry-run --v={{ .vars.kubeadmVerbosity }} || exit 1
docker exec {{ .vars.clusterName }}-worker-1 kubeadm reset --force=true --ignore-preflight-errors={{ .vars.kubeadmIgnorePreflightErrors }} --dry-run --v={{ .vars.kubeadmVerbosity }} || exit 1
force: true
- name: reset
description: |
Expand Down
33 changes: 23 additions & 10 deletions kinder/ci/workflows/dryrun-tasks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,29 @@ tasks:
- --worker-nodes={{ .vars.workerNodes }}
- --loglevel=debug
timeout: 5m
- name: init-dryrun
- name: dryrun-without-cluster
description: |
Initializes the Kubernetes cluster in dryrun mode
Run kubeadm commands in dryrun mode without a real cluster
cmd: /bin/bash
args:
- -c
- |
docker exec {{ .vars.clusterName }}-control-plane-1 bash -c "until crictl ps &> /dev/null; do echo 'Waiting for the container runtime to be running ...'; sleep 1; done"
docker exec {{ .vars.clusterName }}-control-plane-1 kubeadm init --ignore-preflight-errors={{ .vars.kubeadmIgnorePreflightErrors }} --kubernetes-version={{ .vars.kubernetesVersion }} --dry-run=true --v={{ .vars.kubeadmVerbosity }} || exit 1
docker exec {{ .vars.clusterName }}-control-plane-1 kubeadm init --ignore-preflight-errors={{ .vars.kubeadmIgnorePreflightErrors }} --kubernetes-version={{ .vars.kubernetesVersion }} --upload-certs=true --dry-run=true --v={{ .vars.kubeadmVerbosity }} || exit 1
set -x
required_version="1.32" # dryrun without cluster is available since v1.32
current_version=$(echo "{{ .vars.kubernetesVersion }}" | grep -oP '\d+\.\d+')
if awk "BEGIN {exit !($current_version < $required_version)}"; then
echo "Full dryrun support without cluster is not available for Kubernetes version {{ .vars.kubernetesVersion }}, only init-dryrun will be executed for this task."
docker exec {{ .vars.clusterName }}-control-plane-1 bash -c "until crictl ps &> /dev/null; do echo 'Waiting for the container runtime to be running ...'; sleep 1; done"
docker exec {{ .vars.clusterName }}-control-plane-1 kubeadm init --ignore-preflight-errors={{ .vars.kubeadmIgnorePreflightErrors }} --kubernetes-version={{ .vars.kubernetesVersion }} --dry-run --v={{ .vars.kubeadmVerbosity }} || exit 1
else
docker exec {{ .vars.clusterName }}-control-plane-1 bash -c "until crictl ps &> /dev/null; do echo 'Waiting for the container runtime to be running ...'; sleep 1; done"
docker exec {{ .vars.clusterName }}-control-plane-1 kubeadm init --ignore-preflight-errors={{ .vars.kubeadmIgnorePreflightErrors }} --kubernetes-version={{ .vars.kubernetesVersion }} --dry-run --v={{ .vars.kubeadmVerbosity }} || exit 1
docker exec {{ .vars.clusterName }}-control-plane-1 kubeadm join 192.168.0.101:6443 --control-plane --token abcdef.abcdef0123456789 --discovery-token-ca-cert-hash sha256:3b793efefe27a19f93b0fbe6e637e9c41d0dde8a377d6ab1c0f656bf1136dd8a --certificate-key 2e3c4239bc78c27f40530ddc2df7049a2c5ff146e5a702e9c9b6cdbec70df9f3 --ignore-preflight-errors={{ .vars.kubeadmIgnorePreflightErrors }} --dry-run --v={{ .vars.kubeadmVerbosity }} || exit 1
docker exec {{ .vars.clusterName }}-control-plane-1 kubeadm join 192.168.0.101:6443 --token abcdef.abcdef0123456789 --discovery-token-ca-cert-hash sha256:3b793efefe27a19f93b0fbe6e637e9c41d0dde8a377d6ab1c0f656bf1136dd8a --ignore-preflight-errors={{ .vars.kubeadmIgnorePreflightErrors }} --dry-run --v={{ .vars.kubeadmVerbosity }} || exit 1
docker exec {{ .vars.clusterName }}-control-plane-1 /kinder/upgrade/{{ .vars.upgradeVersion }}/kubeadm upgrade apply -f {{ .vars.upgradeVersion }} --ignore-preflight-errors={{ .vars.kubeadmIgnorePreflightErrors }} --allow-release-candidate-upgrades=true --allow-experimental-upgrades=true --dry-run --v={{ .vars.kubeadmVerbosity }} || exit 1
docker exec {{ .vars.clusterName }}-control-plane-1 /kinder/upgrade/{{ .vars.upgradeVersion }}/kubeadm upgrade node --ignore-preflight-errors={{ .vars.kubeadmIgnorePreflightErrors }} --dry-run --v={{ .vars.kubeadmVerbosity }} || exit 1
docker exec {{ .vars.clusterName }}-control-plane-1 kubeadm reset --force=true --ignore-preflight-errors={{ .vars.kubeadmIgnorePreflightErrors }} --dry-run --v={{ .vars.kubeadmVerbosity }} || exit 1
fi
timeout: 5m
- name: init
description: |
Expand All @@ -81,7 +94,7 @@ tasks:
- -c
- |
docker exec {{ .vars.clusterName }}-worker-1 bash -c "until crictl ps &> /dev/null; do echo 'Waiting for the container runtime to be running ...'; sleep 1; done"
docker exec {{ .vars.clusterName }}-worker-1 $(docker exec {{ .vars.clusterName }}-control-plane-1 kubeadm token create --print-join-command) --ignore-preflight-errors={{ .vars.kubeadmIgnorePreflightErrors }} --dry-run=true --v={{ .vars.kubeadmVerbosity }} || exit 1
docker exec {{ .vars.clusterName }}-worker-1 $(docker exec {{ .vars.clusterName }}-control-plane-1 kubeadm token create --print-join-command) --ignore-preflight-errors={{ .vars.kubeadmIgnorePreflightErrors }} --dry-run --v={{ .vars.kubeadmVerbosity }} || exit 1
timeout: 10m
- name: join
description: |
Expand All @@ -101,17 +114,17 @@ tasks:
args:
- -c
- |
docker exec {{ .vars.clusterName }}-control-plane-1 /kinder/upgrade/{{ .vars.upgradeVersion }}/kubeadm upgrade apply -f {{ .vars.upgradeVersion }} --ignore-preflight-errors={{ .vars.kubeadmIgnorePreflightErrors }} --allow-release-candidate-upgrades=true --allow-experimental-upgrades=true --dry-run=true --v={{ .vars.kubeadmVerbosity }} || exit 1
docker exec {{ .vars.clusterName }}-worker-1 /kinder/upgrade/{{ .vars.upgradeVersion }}/kubeadm upgrade node --ignore-preflight-errors={{ .vars.kubeadmIgnorePreflightErrors }} --dry-run=true --v={{ .vars.kubeadmVerbosity }} || exit 1
docker exec {{ .vars.clusterName }}-control-plane-1 /kinder/upgrade/{{ .vars.upgradeVersion }}/kubeadm upgrade apply -f {{ .vars.upgradeVersion }} --ignore-preflight-errors={{ .vars.kubeadmIgnorePreflightErrors }} --allow-release-candidate-upgrades=true --allow-experimental-upgrades=true --dry-run --v={{ .vars.kubeadmVerbosity }} || exit 1
docker exec {{ .vars.clusterName }}-worker-1 /kinder/upgrade/{{ .vars.upgradeVersion }}/kubeadm upgrade node --ignore-preflight-errors={{ .vars.kubeadmIgnorePreflightErrors }} --dry-run --v={{ .vars.kubeadmVerbosity }} || exit 1
- name: reset-dryrun
description: |
Exec kubeadm reset in dryrun mode
cmd: /bin/bash
args:
- -c
- |
docker exec {{ .vars.clusterName }}-control-plane-1 kubeadm reset --force=true --ignore-preflight-errors={{ .vars.kubeadmIgnorePreflightErrors }} --dry-run=true --v={{ .vars.kubeadmVerbosity }} || exit 1
docker exec {{ .vars.clusterName }}-worker-1 kubeadm reset --force=true --ignore-preflight-errors={{ .vars.kubeadmIgnorePreflightErrors }} --dry-run=true --v={{ .vars.kubeadmVerbosity }} || exit 1
docker exec {{ .vars.clusterName }}-control-plane-1 kubeadm reset --force=true --ignore-preflight-errors={{ .vars.kubeadmIgnorePreflightErrors }} --dry-run --v={{ .vars.kubeadmVerbosity }} || exit 1
docker exec {{ .vars.clusterName }}-worker-1 kubeadm reset --force=true --ignore-preflight-errors={{ .vars.kubeadmIgnorePreflightErrors }} --dry-run --v={{ .vars.kubeadmVerbosity }} || exit 1
force: true
- name: reset
description: |
Expand Down

0 comments on commit ed957ec

Please sign in to comment.