Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
171 changes: 130 additions & 41 deletions .github/workflows/helm-chart-smoketest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,71 +4,138 @@ on:
workflow_call:

env:
SHIM_SPIN_VERSION: v0.15.1
# TODO: bump to a more recent K8S_VERSION once rcm supports containerd 2.0+
# see https://github.com/spinframework/runtime-class-manager/issues/371
# For k3d in particular, containerd 2.0 is used starting with k3s image tag v1.32.2-k3s1
K8S_VERSION: v1.32.1
MICROK8S_CHANNEL: 1.32/stable
SHIM_SPIN_VERSION: v0.18.0
DOCKER_BUILD_SUMMARY: false

jobs:
helm-install-smoke-test:
build-images:
runs-on: ubuntu-22.04
strategy:
matrix:
config:
- {
name: "runtime-class-manager",
context: ".",
file: "./Dockerfile"
}
- {
name: "shim-downloader",
context: "./images/downloader",
file: "./images/downloader/Dockerfile"
}
- {
name: "node-installer",
context: ".",
file: "./images/installer/Dockerfile"
}
steps:
- uses: actions/checkout@v4

- name: Install helm
uses: Azure/setup-helm@v4
with:
version: v3.15.4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build RCM
- name: Build ${{ matrix.config.name }}
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
context: ${{ matrix.config.context }}
file: ${{ matrix.config.file }}
platforms: linux/amd64
cache-from: type=gha
cache-to: type=gha,mode=max
load: true
tags: |
runtime-class-manager:chart-test
outputs: type=docker,dest=/tmp/${{ matrix.config.name }}.tar
tags: ${{ matrix.config.name }}:chart-test

- name: Build node installer
uses: docker/build-push-action@v6
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
context: .
file: ./images/installer/Dockerfile
platforms: linux/amd64
cache-from: type=gha
cache-to: type=gha,mode=max
load: true
tags: |
node-installer:chart-test
name: image-${{ matrix.config.name }}
path: /tmp/${{ matrix.config.name }}.tar

- name: Build shim downloader
uses: docker/build-push-action@v6
helm-install-smoke-test:
runs-on: ubuntu-22.04
needs: build-images
strategy:
matrix:
config:
- {
type: "kind",
import_cmd: "kind load image-archive"
}
- {
type: "minikube",
import_cmd: "minikube image load"
}
- {
type: "microk8s",
import_cmd: "sudo microk8s ctr images import"
}
- {
type: "k3d",
import_cmd: "k3d image import"
}

steps:
- uses: actions/checkout@v4

- name: Install helm
uses: Azure/setup-helm@v4
with:
context: ./images/downloader
file: ./images/downloader/Dockerfile
platforms: linux/amd64
cache-from: type=gha
cache-to: type=gha,mode=max
load: true
tags: |
shim-downloader:chart-test
version: v3.17.2

- name: create kind cluster
- name: Download artifact
uses: actions/download-artifact@v4
with:
pattern: image-*
merge-multiple: true
path: /tmp

# Note: 'uses' doesn't support variable interpolation, hence the
# k8s-specific steps below.
# Ref: https://github.com/orgs/community/discussions/25824
- name: Create kind cluster
if: matrix.config.type == 'kind'
uses: helm/kind-action@v1
with:
cluster_name: kind
# Versions lower than v0.27.0 encounter https://github.com/kubernetes-sigs/kind/issues/3795
version: v0.27.0
node_image: kindest/node:${{ env.K8S_VERSION }}

- name: Create minikube cluster
if: matrix.config.type == 'minikube'
uses: medyagh/[email protected]
with:
container-runtime: containerd
kubernetes-version: ${{ env.K8S_VERSION }}

- name: Create microk8s cluster
if: matrix.config.type == 'microk8s'
uses: balchua/[email protected]
with:
channel: ${{ env.MICROK8S_CHANNEL }}

- name: Create k3d cluster
if: matrix.config.type == 'k3d'
uses: AbsaOSS/k3d-action@v2
with:
cluster-name: k3s-default
k3d-version: v5.8.3
args: |
--image docker.io/rancher/k3s:${{ env.K8S_VERSION }}-k3s1

- name: import images into kind cluster
- name: Import images
run: |
kind load docker-image runtime-class-manager:chart-test
kind load docker-image node-installer:chart-test
kind load docker-image shim-downloader:chart-test
for image in $(ls /tmp/*.tar); do
${{ matrix.config.import_cmd }} $image
done

- name: helm install runtime-class-manager
run: |
Expand All @@ -94,23 +161,45 @@ jobs:
- name: label nodes
run: kubectl label node --all spin=true

# MicroK8s runs directly on the host, so both the host's containerd process and MicroK8s' would
# otherwise be detected by runtime-class-manager. As of writing, rcm will fail if more than one
# containerd process is detected when attempting to restart. So, we stop the host process until
# the shim has been installed and the test app has been confirmed to run.
- name: stop system containerd
if: matrix.config.type == 'microk8s'
run: sudo systemctl stop containerd

- name: run Spin App
run: |
kubectl apply -f testdata/apps/spin-app.yaml
kubectl rollout status deployment wasm-spin --timeout 90s
kubectl rollout status deployment wasm-spin --timeout 180s
kubectl get pods -A
kubectl port-forward svc/wasm-spin 8083:80 &
timeout 15s bash -c 'until curl -f -vvv http://localhost:8083/hello; do sleep 2; done'
timeout 60s bash -c 'until curl -f -vvv http://localhost:8083/hello; do sleep 2; done'

- name: restart system containerd
if: matrix.config.type == 'microk8s'
run: sudo systemctl start containerd

- name: debug
if: failure()
run: |
kubectl get pods -A
kubectl describe shim spin-v2
kubectl describe runtimeclass wasmtime-spin-v2
kubectl describe -n rcm pod -l job-name=kind-control-plane-spin-v2-install || true

# Get install pod logs
# Note: there may be multiple pods pending fix in https://github.com/spinkube/runtime-class-manager/issues/140
install_pod=$(kubectl get pods -n rcm --no-headers -o name | awk '{if ($1 ~ "-spin-v2-install") print $0}' | tail -n 1)
kubectl describe -n rcm $install_pod || true
kubectl logs -n rcm -c downloader $install_pod || true
kubectl logs -n rcm -c provisioner $install_pod || true

# RCM pod logs
kubectl logs -n rcm -l app.kubernetes.io/name=runtime-class-manager || true
kubectl describe -n rcm pod -l app.kubernetes.io/name=runtime-class-manager || true

# App logs
kubectl logs -l app=wasm-spin || true
kubectl describe pod -l app=wasm-spin || true

Expand Down
10 changes: 9 additions & 1 deletion images/downloader/download_shim.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,15 @@ mkdir -p /assets

# overwrite default name of shim binary; use the name of shim resource instead
# to enable installing multiple versions of the same shim
curl -sL "${SHIM_LOCATION}" | tar --transform "s/containerd-shim-.*/containerd-shim-${SHIM_NAME}/" -xzf - -C /assets
curl -sLo "containerd-shim-${SHIM_NAME}" "${SHIM_LOCATION}"
ls -lah "containerd-shim-${SHIM_NAME}"

log "$(curl --version)" "INFO"
log "$(tar --version)" "INFO"
log "md5sum: $(md5sum containerd-shim-${SHIM_NAME})" "INFO"
log "sha256sum: $(sha256sum containerd-shim-${SHIM_NAME})" "INFO"

tar -xzf "containerd-shim-${SHIM_NAME}" -C /assets
log "download successful:" "INFO"

ls -lah /assets
Loading