Skip to content

Commit

Permalink
Support arm64/amd64 for k3s
Browse files Browse the repository at this point in the history
  • Loading branch information
gavinbunney committed Nov 26, 2024
1 parent e1a913e commit 7feb2c9
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
15 changes: 11 additions & 4 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Cache images for tests in GHCR
name: Cache Images

on:
push:
Expand Down Expand Up @@ -42,7 +42,14 @@ jobs:
for image in ${IMAGES//,/ }; do
new_image="ghcr.io/gavinbunney/terraform-provider-kubectl/testacc-$(echo $image | sed 's/\//-/')"
echo "Caching $image as $new_image"
docker pull $image
docker tag $image $new_image
docker push $new_image
docker rmi $image --force
docker pull $image --platform linux/amd64
docker tag $image $new_image-amd64
docker push $new_image-amd64
docker tag $image $new_image-x86_64
docker push $new_image-x86_64
docker rmi $image --force
docker pull $image --platform linux/arm64
docker tag $image $new_image-arm64
docker push $new_image-arm64
done
6 changes: 3 additions & 3 deletions scripts/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
services:
server:
image: ghcr.io/gavinbunney/terraform-provider-kubectl/testacc-rancher-k3s:v1.31.2-k3s1
image: ghcr.io/gavinbunney/terraform-provider-kubectl/testacc-rancher-k3s:v1.31.2-k3s1-${ARCH:-amd64}
command: server --disable-agent --tls-san 172.17.0.1 --agent-token somethingtotallyrandom
privileged: true
environment:
Expand All @@ -20,7 +20,7 @@ services:
- 6443:6443

node:
image: ghcr.io/gavinbunney/terraform-provider-kubectl/testacc-rancher-k3s:v1.31.2-k3s1
image: ghcr.io/gavinbunney/terraform-provider-kubectl/testacc-rancher-k3s:v1.31.2-k3s1-${ARCH:-amd64}
command: agent --token somethingtotallyrandom --server https://server:6443
privileged: true
restart: always
Expand All @@ -35,6 +35,6 @@ services:

registry:
platform: linux/amd64
image: ghcr.io/gavinbunney/terraform-provider-kubectl/testacc-registry:2
image: ghcr.io/gavinbunney/terraform-provider-kubectl/testacc-registry:2-amd64
ports:
- 6500:5000
5 changes: 3 additions & 2 deletions scripts/start-k3s.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ cd ${DIR}

export KUBECONFIG="${DIR}/kubeconfig.yaml"
export COMPOSE_PROJECT_NAME=k3s
export DOCKER_DEFAULT_PLATFORM=linux/$(uname -m)
export ARCH=$(uname -m | tr '[:upper:]' '[:lower:]')
export DOCKER_DEFAULT_PLATFORM=linux/${ARCH}

echo "--> Tearing down k3s in docker-compose"
docker-compose down -v &>/dev/null || true
rm -rf ${KUBECONFIG}
sync; sync;

echo "--> Starting k3s in docker-compose"
echo "--> Starting k3s in docker-compose for arch ${ARCH}"
docker-compose up -d --build --pull always

echo "--> Allow insecure access to registry"
Expand Down
2 changes: 2 additions & 0 deletions scripts/stop-k3s.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
cd ${DIR}

export COMPOSE_PROJECT_NAME=k3s
export ARCH=$(uname -m | tr '[:upper:]' '[:lower:]')
export DOCKER_DEFAULT_PLATFORM=linux/${ARCH}

echo "--> Stopping k3s in docker-compose"
docker-compose down -v
Expand Down

0 comments on commit 7feb2c9

Please sign in to comment.