ci: k8s: Add a function to deploy k3s

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 <fabiano.fidencio@intel.com>
This commit is contained in:
Fabiano Fidêncio 2023-09-05 14:50:27 +02:00
parent cf258090aa
commit 54f7117212

View File

@ -68,6 +68,24 @@ function deploy_kata() {
echo "::endgroup::" 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() { function run_tests() {
# Delete any spurious tests namespace that was left behind # Delete any spurious tests namespace that was left behind
kubectl delete namespace kata-containers-k8s-tests &> /dev/null || true kubectl delete namespace kata-containers-k8s-tests &> /dev/null || true
@ -138,6 +156,7 @@ function main() {
install-azure-cli) install_azure_cli ;; install-azure-cli) install_azure_cli ;;
login-azure) login_azure ;; login-azure) login_azure ;;
create-cluster) create_cluster ;; create-cluster) create_cluster ;;
deploy-k8s) deploy_k8s ;;
install-bats) install_bats ;; install-bats) install_bats ;;
install-kubectl) install_kubectl ;; install-kubectl) install_kubectl ;;
get-cluster-credentials) get_cluster_credentials ;; get-cluster-credentials) get_cluster_credentials ;;