-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
401 lines (351 loc) · 9.15 KB
/
.gitlab-ci.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
399
400
401
stages:
- info
- lint
- test
- build
- e2e
- deploy_dev_tags
- deploy_prod_alpha
- deploy_prod_beta
- deploy_prod_ea
- deploy_prod_stable
- deploy_prod_rock_solid
- cleanup
default:
tags:
- deckhouse
.build:
stage: build
script:
# Build images
- |
werf build \
--repo=${MODULES_MODULE_SOURCE}/${MODULES_MODULE_NAME} \
--save-build-report --build-report-path images_tags_werf.json
# Bundle image
- |
IMAGE_SRC="$(jq -r '.Images."bundle".DockerImageName' images_tags_werf.json)"
IMAGE_DST="$(jq -r '.Images.bundle.DockerRepo' images_tags_werf.json):${MODULES_MODULE_TAG}"
echo "✨ Pushing ${IMAGE_SRC} to ${IMAGE_DST}"
crane copy ${IMAGE_SRC} ${IMAGE_DST}
# Release-channel image
- |
IMAGE_SRC="$(jq -r '.Images."release-channel-version".DockerImageName' images_tags_werf.json)"
IMAGE_DST="$(jq -r '.Images."release-channel-version".DockerRepo' images_tags_werf.json)/release:${MODULES_MODULE_TAG}"
echo "✨ Pushing ${IMAGE_SRC} to ${IMAGE_DST}"
crane copy ${IMAGE_SRC} ${IMAGE_DST}
# Register module
- |
echo "✨ Register the module ${MODULES_MODULE_NAME}"
crane append \
--oci-empty-base \
--new_layer "" \
--new_tag "${MODULES_MODULE_SOURCE}:${MODULES_MODULE_NAME}"
.deploy:
stage: deploy
script:
- |
REPO="${MODULES_MODULE_SOURCE}/${MODULES_MODULE_NAME}/release"
IMAGE_SRC="${REPO}:${MODULES_MODULE_TAG}"
IMAGE_DST="${REPO}:${RELEASE_CHANNEL}"
echo "✨ Pushing ${IMAGE_SRC} to ${IMAGE_DST}"
crane copy "${IMAGE_SRC}" "${IMAGE_DST}"
.info:
script:
- |
cat << OUTER
Create ModuleConfig and ModulePullOverride resources to test this MR:
cat <<EOF | kubectl apply -f -
---
apiVersion: deckhouse.io/v1alpha1
kind: ModulePullOverride
metadata:
name: virtualization
spec:
imageTag: ${MODULES_MODULE_TAG}
source: deckhouse
---
apiVersion: deckhouse.io/v1alpha1
kind: ModuleConfig
metadata:
name: ${MODULE_NAME}
spec:
enabled: true
settings:
dvcr:
storage:
type: PersistentVolumeClaim
persistentVolumeClaim:
size: 50G
virtualMachineCIDRs:
- 10.66.10.0/24
- 10.66.20.0/24
- 10.66.30.0/24
version: 1
EOF
Or patch an existing ModulePullOverride:
kubectl patch mpo ${MODULE_NAME} --type merge -p '{"spec":{"imageTag":"${MODULES_MODULE_TAG}"}}'
OUTER
before_script:
# Setup werf
- |
type trdl && . $(trdl use werf 1.2 stable)
type werf && source $(werf ci-env gitlab --as-file)
# Login to gitlab registry by default
if [[ "x${MODULES_REGISTRY_LOGIN}" == "x" ]]; then
MODULES_REGISTRY_LOGIN="${CI_REGISTRY_USER}"
fi
if [[ "x${MODULES_REGISTRY_PASSWORD}" == "x" ]]; then
MODULES_REGISTRY_PASSWORD="${CI_REGISTRY_PASSWORD}"
fi
werf cr login -u ${MODULES_REGISTRY_LOGIN} -p ${MODULES_REGISTRY_PASSWORD} ${MODULES_REGISTRY}
# Vars =================================================================================================================
variables:
MODULES_MODULE_NAME: virtualization
# DEV registry
.dev_vars:
variables:
MODULES_REGISTRY_LOGIN: ${EXTERNAL_MODULES_DEV_REGISTRY_LOGIN}
MODULES_REGISTRY_PASSWORD: ${EXTERNAL_MODULES_DEV_REGISTRY_PASSWORD}
MODULES_REGISTRY: dev-registry.deckhouse.io
MODULES_MODULE_SOURCE: ${MODULES_REGISTRY}/sys/deckhouse-oss/modules
ENV: DEV
# PROD registry
.prod_vars:
variables:
MODULES_REGISTRY_LOGIN: ${EXTERNAL_MODULES_PROD_REGISTRY_LOGIN}
MODULES_REGISTRY_PASSWORD: ${EXTERNAL_MODULES_PROD_REGISTRY_PASSWORD}
MODULES_REGISTRY: registry-write.deckhouse.io
MODULES_MODULE_SOURCE: ${MODULES_REGISTRY}/deckhouse/${EDITION}/modules
ENV: PROD
# Templates ============================================================================================================
.dev:
variables:
MODULES_MODULE_TAG: mr${CI_MERGE_REQUEST_IID}
extends:
- .dev_vars
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
when: always
- when: never
.dev_tags:
variables:
MODULES_MODULE_TAG: ${CI_COMMIT_REF_NAME}
extends:
- .dev_vars
rules:
# https://regex101.com/r/0VtnPP/1
- if: '$CI_COMMIT_TAG =~ /^v\d+\.\d+\.\d+-dev.*$/'
when: always
- when: never
.main:
variables:
MODULES_MODULE_TAG: v0.0.0-main
extends:
- .dev_vars
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH # main
when: always
- when: never
.prod_manual:
variables:
MODULES_MODULE_TAG: ${CI_COMMIT_REF_NAME}
extends:
- .prod_vars
rules:
# https://regex101.com/r/lToOvi/1
- if: '$CI_COMMIT_TAG =~ /^v\d+\.\d+\.\d+$/'
when: manual
- when: never
.prod_always:
variables:
MODULES_MODULE_TAG: ${CI_COMMIT_REF_NAME}
extends:
- .prod_vars
rules:
# https://regex101.com/r/lToOvi/1
- if: '$CI_COMMIT_TAG =~ /^v\d+\.\d+\.\d+$/'
when: always
- when: never
# DCO ==================================================================================================================
# dco:
# stage: lint
# script:
# - pip3 install -U dco-check
# - |
# if [ "${CI_MERGE_REQUEST_EVENT_TYPE:-}" = detached ]; then
# git fetch -a # so that we can resolve branch names below
# export CI_COMMIT_BRANCH="$CI_COMMIT_REF_NAME";
# export CI_MERGE_REQUEST_SOURCE_BRANCH_SHA="$(git rev-parse "origin/$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME")";
# export CI_MERGE_REQUEST_TARGET_BRANCH_SHA="$(git rev-parse "origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME")";
# fi
# - dco-check --default-branch-from-remote --verbose
# extends:
# - .dev
# Info =============================================================================================
show_dev_manifest:
stage: info
extends:
- .info
- .dev
show_main_manifest:
stage: info
extends:
- .info
- .main
# Linsers and Tests ====================================================================================================
lint:virtualization-controller:
stage: lint
script:
- task virtualization-controller:init
- task virtualization-controller:lint
# TODO: need to fix this
# - task virtualization-controller:dvcr:lint
extends:
- .dev
test:virtualization-controller:
stage: test
script:
- task virtualization-controller:init
- task virtualization-controller:test:unit
extends:
- .dev
test:hooks:
stage: test
script:
- task hooks:test
extends:
- .dev
# Build ================================================================================================================
build_dev:
stage: build
extends:
- .build
- .dev
build_dev_tags:
stage: build
extends:
- .build
- .dev_tags
build_main:
stage: build
interruptible: true
extends:
- .build
- .main
build_prod:
stage: build
resource_group: prod
extends:
- .build
- .prod_always
parallel:
matrix:
- EDITION:
- ce
- ee
- fe
# Deploy ===============================================================================================================
deploy_for_dev_tag:
stage: deploy_dev_tags
needs: ['build_dev_tags']
extends:
- .deploy
- .dev_tags
parallel:
matrix:
- RELEASE_CHANNEL:
- alpha
- beta
- early-access
- stable
- rock-solid
deploy_to_prod_alpha:
stage: deploy_prod_alpha
variables:
RELEASE_CHANNEL: alpha
needs: ['build_prod']
extends:
- .deploy
- .prod_manual
parallel:
matrix:
- EDITION:
- ce
- ee
- fe
deploy_to_prod_beta:
stage: deploy_prod_beta
variables:
RELEASE_CHANNEL: beta
needs: ['deploy_to_prod_alpha']
extends:
- .deploy
- .prod_manual
parallel:
matrix:
- EDITION:
- ce
- ee
- fe
deploy_to_prod_ea:
stage: deploy_prod_ea
variables:
RELEASE_CHANNEL: early-access
needs: ['deploy_to_prod_beta']
extends:
- .deploy
- .prod_manual
parallel:
matrix:
- EDITION:
- ce
- ee
- fe
deploy_to_prod_stable:
stage: deploy_prod_stable
variables:
RELEASE_CHANNEL: stable
needs: ['deploy_to_prod_ea']
extends:
- .deploy
- .prod_manual
parallel:
matrix:
- EDITION:
- ce
- ee
- fe
deploy_to_prod_rock_solid:
stage: deploy_prod_rock_solid
variables:
RELEASE_CHANNEL: rock-solid
needs: ['deploy_to_prod_stable']
extends:
- .deploy
- .prod_manual
parallel:
matrix:
- EDITION:
- ce
- ee
- fe
# # Other ================================================================================================================
# e2e_for_main:
# stage: e2e
# needs: ['build_main']
# resource_group: main
# extends:
# - .main
# script:
# - echo e2e
cleanup:
stage: cleanup
variables:
MODULES_MODULE_TAG: v0.0.0-main
extends:
- .dev_vars
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
script:
- werf cleanup --repo dev-registry.deckhouse.io/sys/deckhouse-oss/modules/virtualization --without-kube=true