Skip to content

Upgrade Fleet in Rancher to Latest Release #59

Upgrade Fleet in Rancher to Latest Release

Upgrade Fleet in Rancher to Latest Release #59

# Upgrade fleet in specific Rancher versions to latest fleet release and run MC tests
name: Upgrade Fleet in Rancher to Latest Release
on:
schedule:
# Run every other day at 1:00 PM
- cron: '0 13 */2 * *'
workflow_dispatch:
inputs:
ref:
description: "checkout git branch/tag"
required: true
default: "master"
enable_tmate:
description: 'Enable debugging via tmate'
required: false
default: "false"
push:
tags: ['v*']
env:
GOARCH: amd64
CGO_ENABLED: 0
SETUP_GO_VERSION: '1.19.*'
SETUP_K3D_VERSION: 'v5.4.7'
jobs:
rancher-fleet-upgrade:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
k3s_version:
# k3d version list k3s | sed 's/+/-/' | sort -h
# https://hub.docker.com/r/rancher/k3s/tags
# 1.19 not working in k3d: failed to find memory cgroup
#- v1.19.16-k3s1
- v1.20.15-k3s1
- v1.24.1-k3s1
rancher_version:
- v2.5.16 # k3s: 1.19 - 1.20
- v2.6.11 # k3s: 1.20 - 1.24
- v2.7.3 # k3s: 1.23 - 1.24
fleet_version:
- "0.7.0-rc.2"
exclude:
- k3s_version: v1.20.15-k3s1
rancher_version: v2.7.3
- k3s_version: v1.24.1-k3s1
rancher_version: v2.5.16
steps:
-
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.event.inputs.ref }}
-
uses: actions/setup-go@v4
with:
go-version: ${{ env.SETUP_GO_VERSION }}
-
uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
-
name: Install Ginkgo CLI
run: go install github.com/onsi/ginkgo/v2/[email protected]
-
uses: actions/cache@v3
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
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
tar -xz --strip-components=2 -f rancher-linux-amd64-v2.6.0.tar.gz -C /home/runner/.local/bin
rancher --version
-
name: Set up k3d control-plane cluster
uses: AbsaOSS/k3d-action@v2
with:
k3d-version: ${{ env.SETUP_K3D_VERSION }}
cluster-name: "upstream"
args: >-
-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:${{matrix.k3s_version}}
-
name: Set up k3d downstream cluster
uses: AbsaOSS/k3d-action@v2
with:
k3d-version: ${{ env.SETUP_K3D_VERSION }}
cluster-name: "downstream"
args: >-
-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:${{matrix.k3s_version}}
-
name: Set up tmate debug session
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.enable_tmate == 'true' }}
uses: mxschmitt/action-tmate@v3
timeout-minutes: 15
with:
limit-access-to-actor: true
-
name: Set up Rancher
env:
url: "172.18.0.1.omg.howdoi.website"
fleetns: "${{ matrix.rancher_version == 'v2.5.16' && 'fleet-system' || 'cattle-fleet-system' }}"
run: |
./.github/scripts/setup-rancher.sh "${{matrix.rancher_version}}"
./.github/scripts/wait-for-loadbalancer.sh
./.github/scripts/register-downstream-clusters.sh
./.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
-
name: Deploy latest fleet
env:
url_crd: "https://github.com/rancher/fleet/releases/download/v${{matrix.fleet_version}}/fleet-crd-${{matrix.fleet_version}}.tgz"
url: "https://github.com/rancher/fleet/releases/download/v${{matrix.fleet_version}}/fleet-${{matrix.fleet_version}}.tgz"
version: v${{matrix.fleet_version}}
fleetns: "${{ matrix.rancher_version == 'v2.5.16' && 'fleet-system' || 'cattle-fleet-system' }}"
run: |
helm upgrade fleet-crd "$url_crd" --wait -n "$fleetns"
until helm -n "$fleetns" status fleet-crd | grep -q "STATUS: deployed"; do echo waiting for original fleet-crd chart to be deployed; sleep 1; done
helm upgrade fleet "$url" \
--wait -n "$fleetns" \
--set image.tag="$version" \
--set agentImage.tag="$version"
until helm -n "$fleetns" status fleet | grep -q "STATUS: deployed"; do echo waiting for original fleet chart to be deployed; sleep 3; done
kubectl -n "$fleetns" rollout status deploy/fleet-controller
# wait for bundle update
until kubectl get bundles -n fleet-local fleet-agent-local -ojsonpath='{.spec.resources}' | grep -q "image: rancher/fleet-agent:$version"; do sleep 3; done
until kubectl get bundles -n fleet-default -ojsonpath='{.items[*].spec.resources}' | grep -q "image: rancher/fleet-agent:$version"; do sleep 3; done
# wait for fleet agent bundles
{ grep -E -q -m 1 "fleet-agent-local.*1/1"; kill $!; } < <(kubectl get bundles -n fleet-local -w)
{ grep -E -q -m 1 "fleet-agent-c.*1/1"; kill $!; } < <(kubectl get bundles -n fleet-default -w)
-
name: Verify Installation
env:
FLEET_E2E_NS: fleet-local
FLEET_VERSION: v${{matrix.fleet_version}}
FLEET_LOCAL_AGENT_NAMESPACE: "${{ matrix.rancher_version == 'v2.5.16' && 'fleet-system' || 'cattle-fleet-local-system' }}"
FLEET_AGENT_NAMESPACE: "${{ matrix.rancher_version == 'v2.5.16' && 'fleet-system' || 'cattle-fleet-system' }}"
run: |
ginkgo --label-filter="!single-cluster" e2e/installation
-
name: E2E tests for examples
run: |
ginkgo --label-filter="!difficult" e2e/multi-cluster
-
name: Dump failed environment
if: failure()
run: |
./.github/scripts/dump-failed-k3ds.sh
-
name: Upload logs
uses: actions/upload-artifact@v3
if: failure()
with:
name: gha-fleet-upgrade-rancher-logs-${{ matrix.rancher_version }}-${{ matrix.k3s_version }}-${{ github.sha }}-${{ github.run_id }}
path: |
tmp/*.json
tmp/*.log
retention-days: 2