-
Notifications
You must be signed in to change notification settings - Fork 16
284 lines (249 loc) · 8.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
name: CI
on:
merge_group:
pull_request:
paths-ignore:
- 'DCO'
- 'LICENSE'
- 'README.md'
- 'HOW_TO_RELEASE.md'
- 'RELEASE_NOTES.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
go-version: latest
check-generated:
runs-on: ubuntu-22.04
if: github.actor != 'dependabot[bot]'
steps:
- name: Checkout Source
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
cache: true
- name: Check Generated
run: |
make bumplicense
go mod tidy
pushd e2etests
go mod tidy
popd
make manifests
make generate
make generate-all-in-one
make api-docs
make checkuncommitted
- name: Helm doc generate
uses: docker://jnorwood/helm-docs:v1.10.0
- name: Check if docs are different
run: make checkuncommitted
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: Unit Tests
run: |
make test
- name: Lint
run: |
ENV=host make lint
build-test-images:
runs-on: ubuntu-22.04
strategy:
fail-fast: true
steps:
- name: Code checkout
uses: actions/checkout@v4
- name: Setup docker buildx
uses: docker/setup-buildx-action@v3
- name: Build and export the image
uses: docker/build-push-action@v5
with:
context: .
tags: quay.io/metallb/frr-k8s:main
file: Dockerfile
outputs: type=docker,dest=/tmp/frrk8s.tar
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Upload frrk8s artifact
uses: actions/upload-artifact@v4
with:
retention-days: 1
name: image-tar-frrk8s
path: /tmp/frrk8s.tar
e2e:
runs-on: ubuntu-22.04
needs:
- unit-tests
- build-test-images
- commitlint
strategy:
fail-fast: false
matrix:
ip-family: [ipv4, ipv6, dual]
deployment: [manifests, helm]
exclude:
- ip-family: ipv6
deployment: helm
- ip-family: dual
deployment: helm
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
cache: true
- name: Install kernel modules
run: |
sudo apt-get update
sudo apt-get install linux-modules-extra-$(uname -r)
- name: Download frr8ks images
uses: actions/download-artifact@v4
with:
path: image
- name: Load image
working-directory: image
run: |
docker load -i image-tar-frrk8s/frrk8s.tar
- name: Deploy on kind
run: |
MAKE_RULE="deploy-with-prometheus"
if [ ${{ matrix.deployment }} = "helm" ]; then MAKE_RULE="deploy-helm"; fi
LOGLEVEL=debug IP_FAMILY="${{ matrix.ip-family }}" make $MAKE_RULE
mkdir -p /tmp/kind_logs/
- name: E2E
run: |
SKIP="none"
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
SKIP="$SKIP\|Leaked.*advertising" # TODO fixed by frr 10.0, remove this when https://github.com/metallb/frr-k8s/issues/165 is fixed
GINKGO_ARGS="--skip $SKIP" TEST_ARGS="--report-path=/tmp/kind_logs" make e2etests
- name: Export kind logs
if: ${{ failure() }}
run:
make kind-export-logs
- name: Collect Logs
if: ${{ failure() }}
uses: ./.github/workflows/composite/collectlogs
with:
artifact-name: kind-logs-${{ matrix.ip-family }}-${{ matrix.deployment }}
metallb_e2e:
runs-on: ubuntu-22.04
needs:
- unit-tests
- build-test-images
- commitlint
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 linux-modules-extra-$(uname -r) python3-pip arping ndisc6
- name: Download frr-k8s images
uses: actions/download-artifact@v4
with:
path: image
- name: Load image
working-directory: image
run: |
docker load -i image-tar-frrk8s/frrk8s.tar
- name: Deploy frr-k8s
run: |
helm_args="\
--set prometheus.serviceMonitor.metricRelabelings[0].sourceLabels=\{__name__\} \
--set prometheus.serviceMonitor.metricRelabelings[0].regex=\"frrk8s_bgp_(.*)\" \
--set prometheus.serviceMonitor.metricRelabelings[0].targetLabel=\"__name__\" \
--set prometheus.serviceMonitor.metricRelabelings[0].replacement=\"metallb_bgp_\\\$\$1\" \
--set prometheus.serviceMonitor.metricRelabelings[1].sourceLabels=\{__name__\} \
--set prometheus.serviceMonitor.metricRelabelings[1].regex=\"frrk8s_bfd_(.*)\" \
--set prometheus.serviceMonitor.metricRelabelings[1].targetLabel=\"__name__\" \
--set prometheus.serviceMonitor.metricRelabelings[1].replacement=\"metallb_bfd_\\\$\$1\" \
"
KIND_CLUSTER_NAME="kind" NAMESPACE=metallb-system LOGLEVEL=debug IP_FAMILY="ipv4" HELM_ARGS=${helm_args} make "deploy-helm"
mkdir -p /tmp/kind_logs/
- name: Checkout MetalLB
uses: actions/checkout@v4
with:
repository: metallb/metallb
path: metallb
ref: "main"
- name: Deploy MetalLB
run: |
export KUBECONFIG=${GITHUB_WORKSPACE}/bin/kubeconfig
cd ${GITHUB_WORKSPACE}/metallb/charts/metallb
# remove the frr-k8s dependencies
yq e --inplace '.dependencies |= [{"name": "crds", "condition": "crds.enabled", "version": "0.0.0"}]' Chart.yaml
rm -f charts/frr-k8s-*
# install with metrics enabled
helm_args="\
--namespace metallb-system \
--set speaker.logLevel=debug --set controller.logLevel=debug \
--set frrk8s.enabled=true --set speaker.frr.enabled=false \
--set controller.image.tag=main --set speaker.image.tag=main \
--set prometheus.serviceMonitor.enabled=true --set prometheus.secureMetricsPort=9120 \
--set prometheus.serviceAccount=prometheus-k8s --set prometheus.namespace=monitoring \
"
helm install metallb ${helm_args} .
kubectl wait -n metallb-system --for=condition=Ready pod -l "app.kubernetes.io/name=metallb" --timeout=300s
- name: MetalLB E2E Tests
run: |
export KUBECONFIG=${GITHUB_WORKSPACE}/bin/kubeconfig
sudo pip3 install -r ${GITHUB_WORKSPACE}/metallb/dev-env/requirements.txt
GOBIN=/home/runner/.local/bin go install -v github.com/onsi/ginkgo/v2/[email protected]
docker network create --ipv6 --subnet fc00:f853:ccd:e791::/64 -d bridge network2
KIND_NODES=$(kind get nodes)
for n in $KIND_NODES; do
docker network connect network2 "$n"
done
export SPEAKER_SELECTOR="app.kubernetes.io/component=speaker"
export CONTROLLER_SELECTOR="app.kubernetes.io/component=controller"
cd ${GITHUB_WORKSPACE}/metallb
env "PATH=$PATH" inv remove-lb-exclusion-from-nodes
sudo -E env "PATH=$PATH" inv e2etest -b "frr-k8s" --kubeconfig ${KUBECONFIG} --with-vrf --skip "L2|IPV6|DUALSTACK|FRR-MODE" -e /tmp/kind_logs
- name: Collect Logs
if: ${{ failure() }}
uses: ./.github/workflows/composite/collectlogs
with:
artifact-name: kind-logs-metallb-logs