From eaf61649163a3dc7d60df48a42152fd163bac6e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Date: Mon, 11 Sep 2023 15:44:10 +0200 Subject: [PATCH] ci: kata-deploy: Add the ability to deploy k0s MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This will be very useful in the near future, when we start testing kata-deploy with k0s as well. Signed-off-by: Fabiano FidĂȘncio --- tests/gha-run-k8s-common.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/gha-run-k8s-common.sh b/tests/gha-run-k8s-common.sh index 1dfb13cc84..ba25a75393 100644 --- a/tests/gha-run-k8s-common.sh +++ b/tests/gha-run-k8s-common.sh @@ -97,6 +97,31 @@ function get_nodes_and_pods_info() { kubectl get pods -o name | grep node-debugger | xargs kubectl delete || true } +function deploy_k0s() { + curl -sSLf https://get.k0s.sh | sudo sh + + sudo k0s install controller --single + + sudo k0s start + + # This is an arbitrary value that came up from local tests + sleep 120s + + # Download the kubectl binary into /usr/bin so we can avoid depending + # on `k0s kubectl` command + ARCH=$(uname -m) + if [ "${ARCH}" = "x86_64" ]; then + ARCH=amd64 + fi + kubectl_version=$(sudo k0s kubectl version --short 2>/dev/null | grep "Client Version" | sed -e 's/Client Version: //') + sudo curl -fL --progress-bar -o /usr/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/${kubectl_version}/bin/linux/${ARCH}/kubectl + sudo chmod +x /usr/bin/kubectl + + mkdir -p ~/.kube + sudo cp /var/lib/k0s/pki/admin.conf ~/.kube/config + sudo chown ${USER}:${USER} ~/.kube/config +} + function deploy_k3s() { curl -sfL https://get.k3s.io | sh -s - --write-kubeconfig-mode 644 @@ -129,6 +154,7 @@ function deploy_k8s() { echo "::group::Deploying ${KUBERNETES}" case ${KUBERNETES} in + k0s) deploy_k0s ;; k3s) deploy_k3s ;; *) >&2 echo "${KUBERNETES} flavour is not supported"; exit 2 ;; esac