forked from metallb/metallb
-
Notifications
You must be signed in to change notification settings - Fork 0
399 lines (346 loc) · 12.7 KB
/
ci.yaml
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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
name: CI
on:
merge_group:
pull_request:
paths-ignore:
- 'configsamples/**'
- 'design/**'
- 'website/**'
- 'CODE_OF_CONDUCT.md'
- 'CODEOWNERS'
- 'CONTRIBUTING.md'
- 'DCO'
- 'LICENSE'
- 'netlify.toml'
- 'README.md'
branches:
- "main"
- "v**"
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
static-security-analysis:
runs-on: ubuntu-22.04
env:
GO111MODULE: on
steps:
- name: Checkout Source
uses: actions/checkout@v4
- name: Run Gosec Security Scanner
uses: securego/gosec@master
with:
args: -exclude-dir e2etest -severity medium ./...
- name: Golang Vulncheck
uses: Templum/[email protected]
with:
skip-upload: true
commitlint:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: wagoid/commitlint-github-action@v5
unit-tests:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
cache: true
- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install python3-pip arping ndisc6
sudo pip3 install invoke semver pyyaml
- name: Unit Tests
run: |
inv test
- name: Lint
run: |
inv checkpatch
inv lint -e host
inv verifylicense
inv gomodtidy
inv checkchanges --action="run inv gomodtidy"
inv generatemanifests
inv checkchanges --action="run inv generatemanifests"
inv generateapidocs
inv checkchanges --action="run inv generateapidocs"
build-test-images:
runs-on: ubuntu-22.04
strategy:
fail-fast: true
matrix:
image: [speaker, controller, configmaptocrs]
steps:
- name: Code checkout
uses: actions/checkout@v4
- name: Setup docker buildx
uses: docker/setup-buildx-action@v3
- name: Build and export ${{ matrix.image }}
uses: docker/build-push-action@v5
with:
context: .
tags: quay.io/metallb/${{ matrix.image }}:dev-amd64
file: ${{matrix.image}}/Dockerfile
outputs: type=docker,dest=/tmp/${{ matrix.image }}.tar
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Upload ${{ matrix.image }} artifact
uses: actions/upload-artifact@v4
with:
retention-days: 1
name: image-tar-${{ matrix.image }}
path: /tmp/${{ matrix.image }}.tar
helm:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# Required for chart-testing
fetch-depth: 0
- name: Set up Helm
uses: azure/setup-helm@v4
with:
version: v3.12.1
- uses: actions/setup-python@v5
with:
python-version: '3.10'
check-latest: true
- name: Set up chart-testing
uses: helm/[email protected]
- name: Run chart-testing (list-changed)
id: list-changed
run: |
changed=$(ct list-changed --target-branch ${{ github.event.repository.default_branch }})
if [[ -n "$changed" ]]; then
echo "changed=true" >> "$GITHUB_OUTPUT"
fi
- name: Run chart-testing (lint)
if: steps.list-changed.outputs.changed == 'true'
run: |
helm repo add frrk8s https://metallb.github.io/frr-k8s
ct lint --check-version-increment=false --validate-maintainers=false --target-branch ${{ github.event.repository.default_branch }}
- name: Check if deps are updated
run: |
helm repo add frrk8s https://metallb.github.io/frr-k8s
helm dependency update charts/metallb
if [[ $(git status --porcelain | wc -l) -gt 0 ]]; then
echo "Please update the helm dependencies with: helm dependency update charts/metallb"
exit 1
fi
- name: Helm doc generate
uses: docker://jnorwood/helm-docs:v1.10.0
- name: Check if docs are different
run: |
if [[ $(git status --porcelain | wc -l) -gt 0 ]]; then
echo "Please update the helm docs with the \"helm-docs\" command (https://github.com/norwoodj/helm-docs) or use \"inv helmdocs\""
exit 1
fi
## TODO: Can't pass flags to the conftest GHA in order to use --fail-on-warn
## Should be fixed when https://github.com/instrumenta/conftest-action/issues/3
## is resolved
##
# - name: Conftest
# uses: instrumenta/conftest-action/helm@master
# with:
# chart: charts/metallb/
# policy: charts/metallb/policy
- name: Conftest
run: |
helm plugin install --debug https://github.com/instrumenta/helm-conftest
helm conftest charts/metallb/ -p charts/metallb/policy/ --fail-on-warn
e2e:
runs-on: ubuntu-22.04
needs:
- unit-tests
- build-test-images
- helm
- commitlint
strategy:
fail-fast: false
matrix:
ip-family: [ipv4, ipv6, dual]
bgp-type: [native, frr, frr-k8s]
deployment: [manifests, helm]
prometheus: [disabled, enabled]
exclude:
- ip-family: ipv6
prometheus: disabled
- ip-family: dual
prometheus: disabled
- bgp-type: frr
prometheus: disabled
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install kernel modules
run: |
sudo apt-get update
sudo apt-get install linux-modules-extra-$(uname -r)
- name: Setup
uses: ./.github/workflows/composite/setup
- name: Deploy MetalLB
run: |
HELM_FLAGS=""
PROMETHEUS_FLAGS=""
if [ ${{ matrix.deployment }} = "helm" ]; then HELM_FLAGS="--helm-install"; fi
if [ ${{ matrix.prometheus }} = "enabled" ]; then PROMETHEUS_FLAGS="--with-prometheus"; fi
inv dev-env -i ${{ matrix.ip-family }} -b ${{ matrix.bgp-type }} -l all $HELM_FLAGS --no-build-images $PROMETHEUS_FLAGS
- name: E2E
run: |
HELM_FLAGS=""
echo '/etc/frr/core-%e.%p.%h.%t' | sudo tee /proc/sys/kernel/core_pattern
if [ ${{ matrix.deployment }} = "helm" ]; then export SPEAKER_SELECTOR="app.kubernetes.io/component=speaker" && export CONTROLLER_SELECTOR="app.kubernetes.io/component=controller"; fi
# TODO restore to NONE when https://github.com/metallb/metallb/issues/2311 is fixed
SKIP="L2ServiceStatus"
WITH_VRF="--with-vrf"
FOCUS=""
if [ "${{ matrix.bgp-type }}" == "native" ]; then SKIP="$SKIP|FRR|FRR-MODE|FRRK8S-MODE|BFD|VRF|DUALSTACK"; WITH_VRF=""; fi
if [ "${{ matrix.ip-family }}" == "ipv4" ]; then SKIP="$SKIP|IPV6|DUALSTACK"; fi
if [ "${{ matrix.ip-family }}" == "dual" ]; then SKIP="$SKIP|IPV6"; fi
if [ "${{ matrix.ip-family }}" == "ipv6" ]; then SKIP="$SKIP|IPV4|DUALSTACK"; fi
if [ "${{ matrix.ip-family }}" == "ipv6" ] && [ ${{ matrix.bgp-type }} == "native" ]; then SKIP="$SKIP|BGP"; fi
if [ "${{ matrix.prometheus }}" == "disabled" ]; then SKIP="$SKIP|metrics"; fi
if [ "${{ matrix.bgp-type }}" == "frr" ]; then SKIP="$SKIP|FRRK8S-MODE"; fi
if [ "${{ matrix.bgp-type }}" == "frr-k8s" ]; then SKIP="$SKIP|FRR-MODE"; fi
echo "Skipping $SKIP"
echo "With VRF $WITH_VRF"
sudo -E env "PATH=$PATH" inv e2etest $FOCUS --skip $SKIP --bgp-mode ${{ matrix.bgp-type }} $WITH_VRF -e /tmp/kind_logs
- name: Collect Logs
if: ${{ failure() }}
uses: ./.github/workflows/composite/collectlogs
with:
artifact-name: kind-logs-${{ matrix.ip-family }}-${{ matrix.bgp-type }}-${{ matrix.deployment}}
- name: Publish JUnit Report
uses: mikepenz/action-junit-report@v4
if: success() || failure()
with:
annotate_only: true
report_paths: 'e2etest/junit-report.xml'
e2e-use-operator:
runs-on: ubuntu-22.04
needs:
- unit-tests
- build-test-images
- helm
- commitlint
defaults:
run:
shell: bash
steps:
- name: Install kernel modules
run: |
sudo apt-get update
sudo apt-get install linux-modules-extra-$(uname -r)
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup
uses: ./.github/workflows/composite/setup
- name: Checkout Metal LB Operator
uses: actions/checkout@v4
with:
repository: metallb/metallb-operator
path: metallboperator
ref: main
- name: Checkout MetalLB
uses: actions/checkout@v4
with:
path: metallb
fetch-depth: 0
- name: Create multi-node K8s Kind Cluster
run: |
cd ${GITHUB_WORKSPACE}/metallboperator
./hack/kind-multi-node-cluster-without-registry.sh
kind load docker-image quay.io/metallb/speaker:dev-amd64
kind load docker-image quay.io/metallb/controller:dev-amd64
export KUBECONFIG=${HOME}/.kube/config
- name: Deploy Metal LB Operator
run: |
cd ${GITHUB_WORKSPACE}/metallboperator
sed -i 's/quay.io\/metallb\/speaker:main/quay.io\/metallb\/speaker:dev-amd64/g' bin/metallb-operator.yaml
sed -i 's/quay.io\/metallb\/controller:main/quay.io\/metallb\/controller:dev-amd64/g' bin/metallb-operator.yaml
sed -i 's/native/frr/g' bin/metallb-operator.yaml
kubectl apply -f bin/metallb-operator.yaml
- name: Remove the exclude from external lb label from the master node
run: |
env "PATH=$PATH" inv remove-lb-exclusion-from-nodes
- name: Ensure MetalLB operator is ready
run: |
COUNT=0
while [ "$(kubectl get pods -n metallb-system -l control-plane='controller-manager' -o jsonpath='{.items[*].status.containerStatuses[0].ready}')" != "true" ]; do
sleep 5
COUNT=$((COUNT+1))
if [[ $COUNT -gt 15 ]] ; then
exit 1;
fi
echo "Waiting for operator pod to be ready."
done
- name: MetalLB E2E Tests with Operator Deployment
run: |
cat <<EOF | kubectl apply -f -
apiVersion: metallb.io/v1beta1
kind: MetalLB
metadata:
name: metallb
namespace: metallb-system
spec:
logLevel: debug
EOF
# TOOD remove skipping L2ServiceStatus once https://github.com/metallb/metallb/issues/2311 is fixed
sudo -E env "PATH=$PATH" inv e2etest --bgp-mode frr --skip "IPV6|DUALSTACK|metrics|L2-interface selector|FRRK8S-MODE|L2ServiceStatus" -e /tmp/kind_logs
- name: Collect Logs
if: ${{ failure() }}
uses: ./.github/workflows/composite/collectlogs
with:
artifact-name: kind_logs_use_operator
- name: Publish JUnit Report
uses: mikepenz/action-junit-report@v4
if: success() || failure()
with:
annotate_only: true
report_paths: 'e2etest/junit-report.xml'
oldest_k8s:
runs-on: ubuntu-22.04
needs:
- unit-tests
- build-test-images
- helm
- commitlint
steps:
- name: Install kernel modules
run: |
sudo apt-get update
sudo apt-get install linux-modules-extra-$(uname -r)
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup
uses: ./.github/workflows/composite/setup
- name: Deploy MetalLB
run: |
inv dev-env -b frr --with-prometheus --no-build-images --node-img kindest/node:v1.27.1@sha256:b7d12ed662b873bd8510879c1846e87c7e676a79fefc93e17b2a52989d3ff42b
- name: E2E
run: |
FOCUS="L2.*should work for ExternalTrafficPolicy=Cluster|BGP.*A service of protocol load balancer should work with.*IPV4 - ExternalTrafficPolicyCluster$|validate FRR running configuration"
sudo -E env "PATH=$PATH" inv e2etest --bgp-mode frr --focus "$FOCUS" --skip L2ServiceStatus -e /tmp/kind_logs
- name: Collect Logs
if: ${{ failure() }}
uses: ./.github/workflows/composite/collectlogs
with:
artifact-name: kind-logs-oldest-k8s
- name: Publish JUnit Report
uses: mikepenz/action-junit-report@v4
if: success() || failure()
with:
annotate_only: true
report_paths: 'e2etest/junit-report.xml'