test: Verify deployement of kata-deploy on microk8s

Enable fonctional test to verify deployment of kata-deploy on a Microk8s cluster

Signed-off-by: Stephane Talbot <Stephane.Talbot@univ-savoie.fr>
This commit is contained in:
Stephane Talbot
2025-02-04 15:11:40 +01:00
parent f2ba224e6c
commit f80e7370d5
3 changed files with 27 additions and 0 deletions

View File

@@ -34,6 +34,7 @@ jobs:
- k0s
- k3s
- rke2
- microk8s
# TODO: There are a couple of vmm/k8s combination failing (https://github.com/kata-containers/kata-containers/issues/9854)
# and we will put the entire kata-deploy-tests on GARM on maintenance.
# TODO: Transition to free runner (see #9940).

View File

@@ -72,6 +72,8 @@ setup() {
kubectl apply -k "tools/packaging/kata-deploy/kata-deploy/overlays/k3s"
elif [ "${KUBERNETES}" = "rke2" ]; then
kubectl apply -k "tools/packaging/kata-deploy/kata-deploy/overlays/rke2"
elif [ "${KUBERNETES}" = "microk8s" ]; then
kubectl apply -k "tools/packaging/kata-deploy/kata-deploy/overlays/microk8s"
else
kubectl apply -f "tools/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml"
fi
@@ -142,6 +144,9 @@ teardown() {
elif [ "${KUBERNETES}" = "rke2" ]; then
deploy_spec="-k \"tools/packaging/kata-deploy/kata-deploy/overlays/rke2\""
cleanup_spec="-k \"tools/packaging/kata-deploy/kata-cleanup/overlays/rke2\""
elif [ "${KUBERNETES}" = "microk8s" ]; then
deploy_spec="-k \"tools/packaging/kata-deploy/kata-deploy/overlays/microk8s\""
cleanup_spec="-k \"tools/packaging/kata-deploy/kata-cleanup/overlays/microk8s\""
else
deploy_spec="-f \"tools/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml\""
cleanup_spec="-f \"tools/packaging/kata-deploy/kata-cleanup/base/kata-cleanup.yaml\""

View File

@@ -323,6 +323,26 @@ function deploy_rke2() {
sudo chown ${USER}:${USER} ~/.kube/config
}
function deploy_microk8s() {
sudo snap install microk8s --classic
# These are arbitrary values
sleep 30
sudo /snap/bin/microk8s.status --wait-ready --timeout 300
# install kubectl
ARCH=$(arch_to_golang)
kubectl_version=$(/snap/bin/microk8s.version | grep -oe 'v[0-9]\+\(\.[0-9]\+\)*')
sudo curl -fL --progress-bar -o /usr/bin/kubectl https://dl.k8s.io/release/${kubectl_version}/bin/linux/${ARCH}/kubectl
sudo chmod +x /usr/bin/kubectl
sudo rm -rf /usr/local/bin/kubectl
mkdir -p ~/.kube
sudo /snap/bin/microk8s.config > ~/.kube/config
sudo chown ${USER}:${USER} ~/.kube/config
newgrp microk8s
}
function _get_k0s_kubernetes_version_for_crio() {
# k0s version will look like:
# v1.27.5+k0s.0
@@ -358,6 +378,7 @@ function deploy_k8s() {
k0s) deploy_k0s ;;
k3s) deploy_k3s ;;
rke2) deploy_rke2 ;;
microk8s) deploy_microk8s ;;
*) >&2 echo "${KUBERNETES} flavour is not supported"; exit 2 ;;
esac