-
Notifications
You must be signed in to change notification settings - Fork 14
/
.drone.yml
398 lines (365 loc) · 12.6 KB
/
.drone.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
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
# Copyright (c) 2017-present SIGHUP s.r.l All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
name: qa
kind: pipeline
type: docker
platform:
os: linux
arch: amd64
clone:
depth: 1
steps:
- name: license-check
image: quay.io/sighup/golang:1.23.3
pull: always
commands:
- make license-check
- name: schema-check
image: quay.io/sighup/golang:1.23.3
pull: always
commands:
- |-
cat schemas/public/ekscluster-kfd-v1alpha2.json | \
json-patch -p schemas/private/ekscluster-kfd-v1alpha2.patch.json | \
jq -r > /tmp/schemas-private-ekscluster-kfd-v1alpha2.json
- diff schemas/private/ekscluster-kfd-v1alpha2.json /tmp/schemas-private-ekscluster-kfd-v1alpha2.json
- name: lint
image: quay.io/sighup/policeman
pull: always
environment:
# Identifies false positives like missing 'selector'.
# Doing this is valid for Kustomize patches
VALIDATE_KUBERNETES_KUBEVAL: "false"
# Some duplicated code is intended.
VALIDATE_JSCPD: "false"
# Disable natural language checks
VALIDATE_NATURAL_LANGUAGE: "false"
# Disable go linting, we use the one included in the go image
VALIDATE_GO: "false"
# Exclude template files from linting. The linter does not understand Go template.
FILTER_REGEX_EXCLUDE: (templates/|\.github)
depends_on:
- license-check
- schema-check
# - name: lint-go
# image: quay.io/sighup/golang:1.23.3
# pull: always
# commands:
# - make lint-go
# depends_on:
# - license-check
# - schema-check
- name: test-schema
image: quay.io/sighup/e2e-testing:1.1.0_1.31.1_3.10.0_4.33.3
pull: always
depends_on:
- license-check
- schema-check
environment:
JV_VERSION: 6.0.1
commands:
# we need to download `jv` for running the JSON Schemas tests.
- curl -L https://github.com/santhosh-tekuri/jsonschema/releases/download/v$${JV_VERSION}/jv-v$${JV_VERSION}-linux-amd64.tar.gz | tar zx --directory /usr/local/bin/
- bats -t tests/schema.sh
- name: render
image: quay.io/sighup/e2e-testing:1.1.0_1.31.1_3.10.0_4.33.3
pull: always
depends_on:
- license-check
- schema-check
environment:
NETRC_FILE:
from_secret: NETRC_FILE
FURYCTL_VERSION: v0.31.0-rc.0
FURYCTL_CONFIG: tests/e2e/kfddistribution/furyctl-init-cluster.yaml
FURYCTL_DISTRO_LOCATION: ./
FURYCTL_OUTDIR: ./
FURYCTL_DISABLE_ANALYTICS: "true"
KUBECONFIG: ./dummy
commands:
- echo $${NETRC_FILE} > /root/.netrc
- echo "Installing furyctl version $${FURYCTL_VERSION}..."
- curl -L "https://github.com/sighupio/furyctl/releases/download/$${FURYCTL_VERSION}/furyctl-$(uname -s)-amd64.tar.gz" | tar xz -C /usr/local/bin/
- furyctl download dependencies && furyctl dump template
# Move the folder with the manifests generated from the templates into the right path
- mv distribution $${FURYTCL_OUTDIR}.furyctl/$$(yq .metadata.name $FURYCTL_CONFIG)
# Build the whole distribution
- kustomize build $${FURYTCL_OUTDIR}.furyctl/$$(yq .metadata.name $FURYCTL_CONFIG)/distribution/manifests > distribution.yml
- name: check-deprecated-apis
image: us-docker.pkg.dev/fairwinds-ops/oss/pluto:v5
pull: always
depends_on:
- render
commands:
# we use --ignore-deprecations because we don't want the CI to fail when the API has not been removed yet.
- /pluto detect distribution.yml --ignore-deprecations --target-versions=k8s=v1.31.0
---
name: e2e-kubernetes-1.31
kind: pipeline
type: docker
depends_on:
- qa
clone:
depth: 1
platform:
os: linux
arch: amd64
trigger:
ref:
include:
- refs/tags/**
exclude:
- refs/tags/**-docs*
steps:
- name: create Kind cluster
image: quay.io/sighup/dind-kind-kubectl-kustomize:0.24.0_1.31.1_3.10.0
pull: always
volumes:
- name: dockersock
path: /var/run/docker.sock
environment:
CLUSTER_VERSION: v1.31.0
CLUSTER_NAME: ${DRONE_REPO_NAME}-${DRONE_BUILD_NUMBER}
# /drone/src is the default workdir for the pipeline
# using this folder we don't need to mount another
# shared volume between the steps
KUBECONFIG: /drone/src/kubeconfig
commands:
# create a custom config to disable Kind's default CNI so
# we can test using KFD's networking module.
- |
cat <<EOF > kind-config.yaml
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
networking:
disableDefaultCNI: true
nodes:
- role: control-plane
- role: worker
- role: worker
EOF
# NOTE: kind's `--wait` flag that waits for the control-plane ot be ready
# does not work when disabling the default CNI. It will always go in timeout.
- kind create cluster --name $${CLUSTER_NAME} --image registry.sighup.io/fury/kindest/node:$${CLUSTER_VERSION} --config kind-config.yaml
# save the kubeconfig so we can use it from other steps.
- kind get kubeconfig --name $${CLUSTER_NAME} > $${KUBECONFIG}
- name: e2e-kfddistribution
image: quay.io/sighup/e2e-testing:1.1.0_1.31.1_3.10.0_4.33.3
pull: always
# we need to use host network to access Kind API port that is listening on the worker's loopback
# beacuse we mount the host's Docker socket to run Kind.
network_mode: host
environment:
CLUSTER_NAME: ${DRONE_REPO_NAME}-${DRONE_BUILD_NUMBER}
KUBECONFIG: /drone/src/kubeconfig
FURYCTL_VERSION: v0.31.0-rc.0
depends_on: [create Kind cluster]
commands:
- export KUBECONFIG=/drone/src/kubeconfig
# We change the loopback IP in the kubeconfig to use the service hostname and keep the port.
# - 'sed -Ei "s#(server: https://)(.*)(:.*)#\1kind-cluster\3#" $${KUBECONFIG}'
- echo "Installing the correct furyctl version..."
- curl -L "https://github.com/sighupio/furyctl/releases/download/$${FURYCTL_VERSION}/furyctl-$(uname -s)-amd64.tar.gz" -o /tmp/furyctl.tar.gz && tar xfz /tmp/furyctl.tar.gz -C /tmp
# to use furyctl latest, use the following instead:
# - curl -L "https://github.com/sighupio/furyctl/releases/latest/download/furyctl-$(uname -s)-amd64.tar.gz" -o /tmp/furyctl.tar.gz && tar xfz /tmp/furyctl.tar.gz -C /tmp
- chmod +x /tmp/furyctl
# check that the kind cluster is ready before we move on
# - kubectl wait --timeout=180s --for=condition=ready pod --all -n kube-system
- until kubectl get serviceaccount default > /dev/null 2>&1; do echo "waiting for control-plane" && sleep 1; done
# finally, run the e2e tests
- tests/e2e-kfddistribution.sh
- name: delete-kind-cluster
image: quay.io/sighup/dind-kind-kubectl-kustomize:0.24.0_1.31.1_3.10.0
volumes:
- name: dockersock
path: /var/run/docker.sock
environment:
CLUSTER_NAME: ${DRONE_REPO_NAME}-${DRONE_BUILD_NUMBER}
commands:
# does not matter if the command fails
- kind delete cluster --name $${CLUSTER_NAME} || true
depends_on:
- e2e-kfddistribution
when:
status:
- success
- failure
volumes:
- name: dockersock
host:
path: /var/run/docker.sock
---
name: e2e-kubernetes-1.30.0-to-1.31.0
kind: pipeline
type: docker
depends_on:
- qa
# I comment out the following dependency because we have now 2 workers, so we can run both pipelines in paralel.
# - e2e-kubernetes-1.31
clone:
depth: 1
platform:
os: linux
arch: amd64
trigger:
ref:
include:
- refs/tags/**
exclude:
- refs/tags/**-docs*
steps:
- name: create Kind cluster
image: quay.io/sighup/dind-kind-kubectl-kustomize:0.24.0_1.31.1_3.10.0
pull: always
volumes:
- name: dockersock
path: /var/run/docker.sock
environment:
CLUSTER_VERSION: v1.31.0
CLUSTER_NAME: ${DRONE_REPO_NAME}-${DRONE_BUILD_NUMBER}-upgrades
# /drone/src is the default workdir for the pipeline
# using this folder we don't need to mount another
# shared volume between the steps
KUBECONFIG: /drone/src/kubeconfig-upgrades
commands:
# create a custom config to disable Kind's default CNI so
# we can test using KFD's networking module.
- |
cat <<EOF > kind-config.yaml
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
networking:
disableDefaultCNI: true
nodes:
- role: control-plane
- role: worker
- role: worker
EOF
# NOTE: kind's `--wait` flag that waits for the control-plane ot be ready
# does not work when disabling the default CNI. It will always go in timeout.
- kind create cluster --name $${CLUSTER_NAME} --image registry.sighup.io/fury/kindest/node:$${CLUSTER_VERSION} --config kind-config.yaml
# save the kubeconfig so we can use it from other steps.
- kind get kubeconfig --name $${CLUSTER_NAME} > $${KUBECONFIG}
- name: e2e-kfddistribution
image: quay.io/sighup/e2e-testing:1.1.0_1.31.1_3.10.0_4.33.3
pull: always
# we need to use host network to access Kind API port that is listening on the worker's loopback
# beacuse we mount the host's Docker socket to run Kind.
network_mode: host
environment:
CLUSTER_NAME: ${DRONE_REPO_NAME}-${DRONE_BUILD_NUMBER}-upgrades
KUBECONFIG: /drone/src/kubeconfig-upgrades
FURYCTL_VERSION: v0.31.0-rc.0
depends_on: [create Kind cluster]
commands:
- export KUBECONFIG=/drone/src/kubeconfig-upgrades
# We change the loopback IP in the kubeconfig to use the service hostname and keep the port.
# - 'sed -Ei "s#(server: https://)(.*)(:.*)#\1kind-cluster\3#" $${KUBECONFIG}'
- echo "Installing the correct furyctl version..."
- curl -L "https://github.com/sighupio/furyctl/releases/download/$${FURYCTL_VERSION}/furyctl-$(uname -s)-amd64.tar.gz" -o /tmp/furyctl.tar.gz && tar xfz /tmp/furyctl.tar.gz -C /tmp
# to use furyctl latest, use the following instead:
# - curl -L "https://github.com/sighupio/furyctl/releases/latest/download/furyctl-$(uname -s)-amd64.tar.gz" -o /tmp/furyctl.tar.gz && tar xfz /tmp/furyctl.tar.gz -C /tmp
- chmod +x /tmp/furyctl
# check that the kind cluster is ready before we move on
# - kubectl wait --timeout=180s --for=condition=ready pod --all -n kube-system
- until kubectl get serviceaccount default > /dev/null 2>&1; do echo "waiting for control-plane" && sleep 1; done
# finally, run the e2e tests
- tests/e2e-kfddistribution-upgrades.sh
- name: delete-kind-cluster
image: quay.io/sighup/dind-kind-kubectl-kustomize:0.24.0_1.31.1_3.10.0
volumes:
- name: dockersock
path: /var/run/docker.sock
environment:
CLUSTER_NAME: ${DRONE_REPO_NAME}-${DRONE_BUILD_NUMBER}-upgrades
commands:
# does not matter if the command fails
- kind delete cluster --name $${CLUSTER_NAME} || true
depends_on:
- e2e-kfddistribution
when:
status:
- success
- failure
volumes:
- name: dockersock
host:
path: /var/run/docker.sock
---
name: release
kind: pipeline
type: docker
depends_on:
- e2e-kubernetes-1.31
- e2e-kubernetes-1.30.0-to-1.31.0
platform:
os: linux
arch: amd64
trigger:
ref:
include:
- refs/tags/v**
exclude:
- refs/tags/**-docs*
steps:
- name: prepare-release-notes
image: quay.io/sighup/fury-release-notes-plugin:3.7_2.8.4
depends_on: [clone]
settings:
release_notes_file_path: release-notes.md
when:
ref:
include:
- refs/tags/v**
exclude:
- refs/tags/**-docs*
- name: publish-prerelease
image: plugins/github-release
pull: always
depends_on:
- prepare-release-notes
settings:
api_key:
from_secret: github_token
file_exists: skip
files:
- kfd.yaml
prerelease: true
overwrite: true
title: "Prerelease ${DRONE_TAG}"
note: release-notes.md
checksum:
- md5
- sha256
when:
ref:
include:
- refs/tags/v**-rc**
exclude:
- refs/tags/**-docs*
- name: publish-stable
image: plugins/github-release
pull: always
depends_on:
- prepare-release-notes
settings:
api_key:
from_secret: github_token
file_exists: skip
files:
- kfd.yaml
prerelease: false
overwrite: true
title: "Release ${DRONE_TAG}"
note: release-notes.md
checksum:
- md5
- sha256
when:
ref:
exclude:
- refs/tags/v**-rc**
- refs/tags/**-docs*
include:
- refs/tags/v**