E2E Upgrade Fleet in Rancher To HEAD #1128
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Upgrade fleet in latest Rancher to dev version and run MC tests | |
| name: E2E Upgrade Fleet in Rancher To HEAD | |
| on: | |
| schedule: | |
| # Run everyday day at 1:00 PM | |
| - cron: '0 13 * * *' | |
| workflow_dispatch: | |
| inputs: | |
| ref: | |
| description: "checkout git branch/tag" | |
| required: true | |
| default: "main" | |
| push: | |
| tags: [ 'v*' ] | |
| paths-ignore: | |
| - '*.md' | |
| env: | |
| GOARCH: amd64 | |
| CGO_ENABLED: 0 | |
| SETUP_K3S_VERSION: 'v1.35.1-k3s1' | |
| jobs: | |
| rancher-fleet-integration: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| fetch-depth: 0 | |
| ref: ${{ github.event.inputs.ref }} | |
| - | |
| uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.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@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3 | |
| 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 | |
| run: | | |
| if [ "${{ steps.cache-crust.outputs.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@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3 | |
| id: rancher-cli-cache | |
| with: | |
| path: /home/runner/.local/bin | |
| key: ${{ runner.os }}-rancher-cli-2.6.0 | |
| - | |
| name: Install Rancher CLI | |
| if: steps.rancher-cli-cache.outputs.cache-hit != 'true' | |
| run: | | |
| # download an older CLI to avoid https://github.com/rancher/rancher/issues/37574 | |
| # renovate: datasource=github-release-attachments depName=rancher/cli digestVersion=v2.6.0 | |
| RANCHER_CLI_SUM="e3f2f8bc04b763759d027ba30a6563b81a1ba6d881b1f3c95b24931a7804fb79" | |
| mkdir -p /home/runner/.local/bin | |
| wget -q https://github.com/rancher/cli/releases/download/v2.6.0/rancher-linux-amd64-v2.6.0.tar.gz | |
| echo "${RANCHER_CLI_SUM} rancher-linux-amd64-v2.6.0.tar.gz" | sha256sum -c - | |
| tar -xz --strip-components=2 -f rancher-linux-amd64-v2.6.0.tar.gz -C /home/runner/.local/bin | |
| rancher --version | |
| - | |
| name: Build fleet binaries | |
| run: | | |
| ./.github/scripts/build-fleet-binaries.sh | |
| - | |
| name: Set up QEMU | |
| uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a # v4.0.0 | |
| - | |
| name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0 | |
| - | |
| name: Get uuid | |
| id: uuid | |
| run: echo "::set-output name=uuid::$(uuidgen)" | |
| - | |
| id: meta-fleet | |
| uses: docker/metadata-action@030e881283bb7a6894de51c315a6bfe6a94e05cf # v6.0.0 | |
| with: | |
| images: | | |
| ttl.sh/rancher/fleet-${{ steps.uuid.outputs.uuid }} | |
| tags: type=raw,value=1h | |
| - | |
| uses: docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294 # v7.0.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@030e881283bb7a6894de51c315a6bfe6a94e05cf # v6.0.0 | |
| with: | |
| images: | | |
| ttl.sh/rancher/fleet-agent-${{ steps.uuid.outputs.uuid }} | |
| tags: type=raw,value=1h | |
| - | |
| uses: docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294 # v7.0.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@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3 | |
| with: | |
| path: ~/.local/bin/k3d | |
| key: ${{ runner.os }}-k3d-${{ hashFiles('.github/scripts/install-k3d.sh') }} | |
| restore-keys: | | |
| ${{ runner.os }}-k3d- | |
| - | |
| name: Install k3d | |
| run: | | |
| if [ "${{ steps.cache-k3d.outputs.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 | |
| env: | |
| public_hostname: "172.18.0.1.sslip.io" | |
| run: | | |
| ./.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 | |
| run: | | |
| echo "${{ steps.meta-fleet.outputs.tags }} ${{ steps.meta-fleet-agent.outputs.tags }}" | |
| ./.github/scripts/upgrade-rancher-fleet-to-dev-fleet.sh ${{ steps.meta-fleet.outputs.tags }} ${{ steps.meta-fleet-agent.outputs.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@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 | |
| if: failure() | |
| with: | |
| name: gha-fleet-rancher-logs-${{ github.sha }}-${{ github.run_id }} | |
| path: | | |
| tmp/downstream | |
| tmp/upstream | |
| retention-days: 2 |