Skip to content

E2E Upgrade Fleet in Rancher To HEAD #1316

E2E Upgrade Fleet in Rancher To HEAD

E2E Upgrade Fleet in Rancher To HEAD #1316

# Upgrade fleet in latest Rancher to dev version and run MC tests
name: E2E Upgrade Fleet in Rancher To HEAD
on:
schedule:
# Runs everyday at 05:20 UTC
- cron: '20 5 * * *'
workflow_dispatch:
inputs:
ref:
description: "checkout git branch/tag"
required: true
default: "main"
push:
tags: [ 'v*' ]
paths-ignore:
- '*.md'
permissions:
contents: read
env:
GOARCH: amd64
CGO_ENABLED: 0
SETUP_K3S_VERSION: 'v1.36.0-k3s1'
jobs:
rancher-fleet-integration:
runs-on: ubuntu-latest
steps:
-
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 0
persist-credentials: false
ref: ${{ github.event.inputs.ref }}
-
uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
with:
go-version-file: 'go.mod'
-
name: Install Ginkgo CLI
run: go install github.com/onsi/ginkgo/v2/ginkgo
-
name: Cache crust-gather CLI
id: cache-crust
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/.local/bin/crust-gather
key: ${{ runner.os }}-crust-gather-${{ hashFiles('.github/scripts/install-crust-gather.sh') }}
restore-keys: |
${{ runner.os }}-crust-gather-
-
name: Install crust-gather CLI
env:
CACHE_HIT: ${{ steps.cache-crust.outputs.cache-hit }}
run: |
if [ "$CACHE_HIT" != "true" ]; then
./.github/scripts/install-crust-gather.sh
else
echo "Using cached crust-gather CLI"
chmod +x ~/.local/bin/crust-gather
fi
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
-
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
id: rancher-cli-cache
with:
path: ~/.local/bin/rancher
key: ${{ runner.os }}-rancher-cli-2.14.0
-
name: Install Rancher CLI
if: steps.rancher-cli-cache.outputs.cache-hit != 'true'
run: |
mkdir -p ~/.local/bin
# renovate: datasource=github-releases depName=rancher/cli
RANCHER_CLI_VERSION="v2.14.2"
# renovate: datasource=github-release-attachments depName=rancher/cli digestVersion=v2.14.2
RANCHER_CLI_SUM_amd64="3a3eb0da83cbeb5e726f3153c8e16a8c067298c0ddc1c2ba86b7732fa0231149"
curl -fsSL -o "rancher-linux-amd64-${RANCHER_CLI_VERSION}.tar.gz" \
"https://github.com/rancher/cli/releases/download/${RANCHER_CLI_VERSION}/rancher-linux-amd64-${RANCHER_CLI_VERSION}.tar.gz"
echo "${RANCHER_CLI_SUM_amd64} rancher-linux-amd64-${RANCHER_CLI_VERSION}.tar.gz" | sha256sum -c -
tar -xz --strip-components=2 -f "rancher-linux-amd64-${RANCHER_CLI_VERSION}.tar.gz" -C ~/.local/bin
rancher --version
-
name: Build fleet binaries
run: |
./.github/scripts/build-fleet-binaries.sh
-
name: Set up QEMU
uses: docker/setup-qemu-action@96fe6ef7f33517b61c61be40b68a1882f3264fb8 # v4.2.0
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4.1.0
-
name: Get uuid
id: uuid
run: |
if ! command -v uuidgen >/dev/null 2>&1; then
sudo apt-get update
sudo apt install -y uuid-runtime # should provide uuidgen
fi
echo "uuid=$(uuidgen)" >> $GITHUB_OUTPUT
-
id: meta-fleet
uses: docker/metadata-action@80c7e94dd9b9319bd5eb7a0e0fe9291e23a2a2e9 # v6.1.0
with:
images: |
ttl.sh/rancher/fleet-${{ steps.uuid.outputs.uuid }}
tags: type=raw,value=1h
-
uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0
with:
context: .
file: package/Dockerfile
build-args: |
ARCH=${{ env.GOARCH }}
push: true
tags: ${{ steps.meta-fleet.outputs.tags }}
labels: ${{ steps.meta-fleet.outputs.labels }}
-
id: meta-fleet-agent
uses: docker/metadata-action@80c7e94dd9b9319bd5eb7a0e0fe9291e23a2a2e9 # v6.1.0
with:
images: |
ttl.sh/rancher/fleet-agent-${{ steps.uuid.outputs.uuid }}
tags: type=raw,value=1h
-
uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0
with:
context: .
file: package/Dockerfile.agent
build-args: |
ARCH=${{ env.GOARCH }}
push: true
tags: ${{ steps.meta-fleet-agent.outputs.tags }}
labels: ${{ steps.meta-fleet-agent.outputs.labels }}
-
name: Cache k3d CLI
id: cache-k3d
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/.local/bin/k3d
key: ${{ runner.os }}-k3d-${{ hashFiles('.github/scripts/install-k3d.sh') }}
restore-keys: |
${{ runner.os }}-k3d-
-
name: Install k3d
env:
CACHE_HIT: ${{ steps.cache-k3d.outputs.cache-hit }}
run: |
if [ "$CACHE_HIT" != "true" ]; then
./.github/scripts/install-k3d.sh
else
echo "Using cached k3d"
chmod +x ~/.local/bin/k3d
fi
-
name: Set up k3d control-plane cluster
run: |
k3d cluster create upstream --wait \
-p "80:80@agent:0:direct" \
-p "443:443@agent:0:direct" \
--api-port 6443 \
--agents 1 \
--k3s-arg '--kubelet-arg=eviction-hard=imagefs.available<1%,nodefs.available<1%@agent:*' \
--k3s-arg '--kubelet-arg=eviction-minimum-reclaim=imagefs.available=1%,nodefs.available=1%@agent:*' \
--network "nw01" \
--image docker.io/rancher/k3s:${{ env.SETUP_K3S_VERSION }} \
--k3s-arg "--cluster-init@server:0"
-
name: Set up k3d downstream cluster
run: |
k3d cluster create downstream --wait \
-p "81:80@agent:0:direct" \
-p "444:443@agent:0:direct" \
--api-port 6644 \
--agents 1 \
--k3s-arg '--kubelet-arg=eviction-hard=imagefs.available<1%,nodefs.available<1%@agent:*' \
--k3s-arg '--kubelet-arg=eviction-minimum-reclaim=imagefs.available=1%,nodefs.available=1%@agent:*' \
--network "nw01" \
--image docker.io/rancher/k3s:${{ env.SETUP_K3S_VERSION }} \
--k3s-arg "--cluster-init@server:0"
-
name: Set up Rancher
run: |
ip=""
attempts=0
max_attempts=50
kubectl config use-context k3d-upstream
while [ -z "$ip" ]; do
attempts=$((attempt +1))
ip=$(kubectl get service -n kube-system traefik -o jsonpath='{.status.loadBalancer.ingress[0].ip}' || true)
if [ -z "$ip" ]; then
if [ "$attempts" -ge "$max_attempts" ]; then
echo "Timed out waiting for traefik load balancer ingress IP after $((max_attempts * 3)) seconds."
exit 1
fi
echo "Waiting for traefik load balancer ingress... (attempt $attempts/$max_attempts)"
sleep 3
fi
done
export public_hostname=$ip.sslip.io
./.github/scripts/setup-rancher.sh
./.github/scripts/wait-for-loadbalancer.sh
./.github/scripts/register-downstream-clusters.sh
sleep 30
./.github/scripts/label-downstream-cluster.sh
-
name: Create example workload
run: |
kubectl apply -n fleet-local -f e2e/assets/fleet-upgrade/gitrepo-simple.yaml
kubectl apply -n fleet-default -f e2e/assets/fleet-upgrade/gitrepo-simple.yaml
# wait for bundle ready
until kubectl get bundles -n fleet-local test-simple-simple-chart -o=jsonpath='{.status.conditions[?(@.type=="Ready")].status}' | grep -q "True"; do sleep 3; done
until kubectl get bundles -n fleet-default test-simple-simple-chart -o=jsonpath='{.status.conditions[?(@.type=="Ready")].status}' | grep -q "True"; do sleep 3; done
-
name: Deploy development fleet
env:
FLEET_TAGS: ${{ steps.meta-fleet.outputs.tags }}
FLEET_AGENT_TAGS: ${{ steps.meta-fleet-agent.outputs.tags }}
run: |
echo "$FLEET_TAGS $FLEET_AGENT_TAGS"
./.github/scripts/upgrade-rancher-fleet-to-dev-fleet.sh "$FLEET_TAGS" "$FLEET_AGENT_TAGS"
-
name: E2E tests for examples
env:
FLEET_E2E_NS: fleet-local
FLEET_E2E_NS_DOWNSTREAM: fleet-default
run: |
kubectl config use-context k3d-upstream
export CI_REGISTERED_CLUSTER=$(kubectl get clusters.fleet.cattle.io -n $FLEET_E2E_NS_DOWNSTREAM -o jsonpath='{..name}')
ginkgo --github-output --trace e2e/multi-cluster
-
name: Dump Failed Downstream Environment
if: failure()
run: |
kubectl config use-context k3d-downstream
crust-gather collect --exclude-namespace=kube-system --exclude-kind=Lease --duration=5s -f tmp/downstream
-
name: Upload logs
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
if: failure()
with:
name: gha-fleet-rancher-logs-${{ github.sha }}-${{ github.run_id }}
path: |
tmp/downstream
tmp/upstream
retention-days: 2