From 81f21b5860d426deba87fd75a6c14317befccaf8 Mon Sep 17 00:00:00 2001 From: Gavin Bunney Date: Wed, 27 Nov 2024 12:02:56 -0800 Subject: [PATCH] Expand testing of k8s versions --- .github/workflows/build.yml | 9 +++++++++ .github/workflows/docker.yml | 3 --- scripts/docker-compose.yaml | 4 ++-- scripts/start-k3s.sh | 2 ++ scripts/stop-k3s.sh | 2 ++ 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3e0611b1..7bf2124d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -45,6 +45,13 @@ jobs: run: make test testacc: + strategy: + matrix: + k3s_version: + - v1.31.2-k3s1 + - v1.29.10-k3s1 + - v1.27.16-k3s1 + - v1.25.16-k3s4 runs-on: ubuntu-latest env: GO111MODULE: on @@ -61,6 +68,8 @@ jobs: run: make ci-build-setup - name: Start k3s run: make k3s-start + env: + K3S_VERSION: ${{ matrix.k3s_version }} - name: Run acceptance tests run: make testacc - name: Stop k3s diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 4be1caae..79de83a0 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -5,9 +5,6 @@ on: paths: - '.github/workflows/docker.yml' -env: - IMAGES: "rancher/k3s:v1.31.2-k3s1,rancher/k3s:v1.29.10-k3s1,rancher/k3s:v1.27.16-k3s1,rancher/k3s:v1.25.16-k3s4,registry:2" - jobs: cache-images: strategy: diff --git a/scripts/docker-compose.yaml b/scripts/docker-compose.yaml index 3cfba625..4973198f 100644 --- a/scripts/docker-compose.yaml +++ b/scripts/docker-compose.yaml @@ -1,6 +1,6 @@ services: server: - image: ghcr.io/gavinbunney/terraform-provider-kubectl/testacc-rancher-k3s:v1.31.2-k3s1-${ARCH:-amd64} + image: ghcr.io/gavinbunney/terraform-provider-kubectl/testacc-rancher-k3s:${K3S_VERSION}-${ARCH} command: server --disable-agent --tls-san 172.17.0.1 --agent-token somethingtotallyrandom privileged: true environment: @@ -20,7 +20,7 @@ services: - 6443:6443 node: - image: ghcr.io/gavinbunney/terraform-provider-kubectl/testacc-rancher-k3s:v1.31.2-k3s1-${ARCH:-amd64} + image: ghcr.io/gavinbunney/terraform-provider-kubectl/testacc-rancher-k3s:${K3S_VERSION}-${ARCH} command: agent --token somethingtotallyrandom --server https://server:6443 privileged: true restart: always diff --git a/scripts/start-k3s.sh b/scripts/start-k3s.sh index 67b35154..a463a922 100755 --- a/scripts/start-k3s.sh +++ b/scripts/start-k3s.sh @@ -9,6 +9,8 @@ export COMPOSE_PROJECT_NAME=k3s export ARCH=$(uname -m | tr '[:upper:]' '[:lower:]') export DOCKER_DEFAULT_PLATFORM=linux/${ARCH} +export K3S_VERSION=${K3S_VERSION:-v1.31.2-k3s1} + echo "--> Tearing down k3s in docker-compose" docker-compose down -v &>/dev/null || true rm -rf ${KUBECONFIG} diff --git a/scripts/stop-k3s.sh b/scripts/stop-k3s.sh index 928463a7..5be65645 100755 --- a/scripts/stop-k3s.sh +++ b/scripts/stop-k3s.sh @@ -8,6 +8,8 @@ export COMPOSE_PROJECT_NAME=k3s export ARCH=$(uname -m | tr '[:upper:]' '[:lower:]') export DOCKER_DEFAULT_PLATFORM=linux/${ARCH} +export K3S_VERSION=${K3S_VERSION:-v1.31.2-k3s1} + echo "--> Stopping k3s in docker-compose" docker-compose down -v rm -rf kubeconfig.yaml