forked from rancher/fleet
-
Notifications
You must be signed in to change notification settings - Fork 0
194 lines (186 loc) · 7.49 KB
/
rancher-upgrade-fleet.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
# 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/ginkgo@v2.8.0
-
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