From 54f71172129d9973b463453ff057c47f13de254e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Date: Tue, 5 Sep 2023 14:50:27 +0200 Subject: [PATCH] ci: k8s: Add a function to deploy k3s MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit One can use different kubernetes flavours for getting a kubernetes cluster up and running. As part of our CI, though, I really would like to avoid contributors spending time maintaining and updating kubernetes dependencies, as done with the tests repo, and which has been proven to be really good on getting things rotten. With this in mind, I'm taking the bullet and using "k3s" as the way to deploy kubernetes for the devmapper related tests, and that's the reason I'm adding a function to do so, and this will be used later on as part of this series. It's important to note that the k3s setup doesn't take into consideration a BM machine, and this is not suitable for that. We're really only targetting GHA runners which will be thrown away after the run is over. Signed-off-by: Fabiano FidĂȘncio --- tests/integration/kubernetes/gha-run.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/integration/kubernetes/gha-run.sh b/tests/integration/kubernetes/gha-run.sh index b11c1d0064..11e2b2be7d 100755 --- a/tests/integration/kubernetes/gha-run.sh +++ b/tests/integration/kubernetes/gha-run.sh @@ -68,6 +68,24 @@ function deploy_kata() { echo "::endgroup::" } +function deploy_k3s() { + curl -sfL https://get.k3s.io | sh - + + # This is an arbitrary value that came up from local tests + wait 240s +} + +function deploy_k8s() { + echo "::group::Deploying ${KUBERNETES}" + + case ${KUBERNETES} in + k3s) deploy_k3s ;; + *) >&2 echo "${KUBERNETES} flavour is not supported"; exit 2 ;; + esac + + echo "::endgroup::" +} + function run_tests() { # Delete any spurious tests namespace that was left behind kubectl delete namespace kata-containers-k8s-tests &> /dev/null || true @@ -138,6 +156,7 @@ function main() { install-azure-cli) install_azure_cli ;; login-azure) login_azure ;; create-cluster) create_cluster ;; + deploy-k8s) deploy_k8s ;; install-bats) install_bats ;; install-kubectl) install_kubectl ;; get-cluster-credentials) get_cluster_credentials ;;