forked from NVIDIA/gpu-operator
-
Notifications
You must be signed in to change notification settings - Fork 2
/
.nvidia-ci.yml
330 lines (297 loc) · 9.17 KB
/
.nvidia-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
default:
tags:
- cnt
- container-dev
- docker/privileged
- docker/multi-arch
- os/linux
- type/docker
include:
- local: '.common-ci.yml'
- project: nsv-devops/cnt-ci
file: cnt-ci.yml
ref: "2023.10.09"
variables:
# Release "devel"-tagged images off the master branch
RELEASE_DEVEL_BRANCH: "master"
DEVEL_RELEASE_IMAGE_VERSION: "devel"
# On the multi-arch builder we don't need the qemu setup.
SKIP_QEMU_SETUP: "1"
# Define the public staging registry
STAGING_REGISTRY: registry.gitlab.com/nvidia/kubernetes/gpu-operator/staging
STAGING_VERSION: ${CI_COMMIT_SHORT_SHA}
GIT_SUBMODULE_PATHS: cnt-ci
.image-pull:
stage: image-build
variables:
IN_REGISTRY: "${STAGING_REGISTRY}"
IN_IMAGE_NAME: gpu-operator
IN_VERSION: "${STAGING_VERSION}"
OUT_REGISTRY_USER: "${CI_REGISTRY_USER}"
OUT_REGISTRY_TOKEN: "${CI_REGISTRY_PASSWORD}"
OUT_REGISTRY: "${CI_REGISTRY}"
OUT_IMAGE_NAME: "${CI_REGISTRY_IMAGE}"
# We delay the job start to allow the public pipeline to generate the required images.
when: delayed
start_in: 30 minutes
timeout: 30 minutes
retry:
max: 2
when:
- job_execution_timeout
- stuck_or_timeout_failure
before_script:
- !reference [.regctl-setup, before_script]
- apk add --no-cache make bash
- >
regctl manifest get ${IN_REGISTRY}/${IN_IMAGE_NAME}:${IN_VERSION}-${DIST} --list > /dev/null && echo "${IN_REGISTRY}/${IN_IMAGE_NAME}:${IN_VERSION}-${DIST}" || ( echo "${IN_REGISTRY}/${IN_IMAGE_NAME}:${IN_VERSION}-${DIST} does not exist" && sleep infinity )
script:
- regctl registry login "${OUT_REGISTRY}" -u "${OUT_REGISTRY_USER}" -p "${OUT_REGISTRY_TOKEN}"
- make IMAGE=${IN_REGISTRY}/${IN_IMAGE_NAME}:${IN_VERSION}-${DIST} OUT_IMAGE=${OUT_IMAGE_NAME}:${CI_COMMIT_SHORT_SHA}-${DIST} push-${DIST}
image:gpu-operator:
extends:
- .image-pull
- .dist-ubi8
- .target-gpu-operator
image:gpu-operator-validator:
extends:
- .image-pull
- .dist-ubi8
- .target-gpu-operator-validator
variables:
OUT_IMAGE_NAME: "${CI_REGISTRY_IMAGE}/gpu-operator-validator"
# We skip the integration tests for the internal CI:
.integration:
stage: test
before_script:
- echo "Skipped in internal CI"
script:
- echo "Skipped in internal CI"
# The .scan step forms the base of the image scan operation performed before releasing
# images.
.scan:
stage: scan
image: "${PULSE_IMAGE}"
variables:
IMAGE: "${IMAGE_NAME}:${CI_COMMIT_SHORT_SHA}-${DIST}"
IMAGE_ARCHIVE: "gpu-operator.tar"
except:
variables:
- $CI_COMMIT_MESSAGE =~ /\[skip[ _-]scans?\]/i
- $SKIP_SCANS && $SKIP_SCANS == "yes"
before_script:
- docker login -u "${CI_REGISTRY_USER}" -p "${CI_REGISTRY_PASSWORD}" "${CI_REGISTRY}"
- docker pull --platform="${PLATFORM}" "${IMAGE}"
- docker save "${IMAGE}" -o "${IMAGE_ARCHIVE}"
- AuthHeader=$(echo -n $SSA_CLIENT_ID:$SSA_CLIENT_SECRET | base64 -w0)
- >
export SSA_TOKEN=$(curl --request POST --header "Authorization: Basic $AuthHeader" --header "Content-Type: application/x-www-form-urlencoded" ${SSA_ISSUER_URL} | jq ".access_token" | tr -d '"')
- if [ -z "$SSA_TOKEN" ]; then exit 1; else echo "SSA_TOKEN set!"; fi
script:
- pulse-cli -n $NSPECT_ID --ssa $SSA_TOKEN scan -i $IMAGE_ARCHIVE -p $CONTAINER_POLICY -o
artifacts:
when: always
expire_in: 1 week
paths:
- pulse-cli.log
- licenses.json
- sbom.json
- vulns.json
- policy_evaluation.json
.scan:gpu-operator:
extends:
- .scan
- .dist-ubi8
- .target-gpu-operator
needs:
- image:gpu-operator
scan:gpu-operator-amd64:
extends:
- .scan:gpu-operator
- .platform-amd64
scan:gpu-operator-arm64:
extends:
- .scan:gpu-operator
- .platform-arm64
needs:
- scan:gpu-operator-amd64
.scan:gpu-operator-validator:
extends:
- .scan
- .dist-ubi8
- .target-gpu-operator-validator
needs:
- image:gpu-operator-validator
scan:gpu-operator-validator-amd64:
extends:
- .scan:gpu-operator-validator
- .platform-amd64
scan:gpu-operator-validator-arm64:
extends:
- .scan:gpu-operator-validator
- .platform-arm64
needs:
- scan:gpu-operator-validator-amd64
# Define the external release steps for NGC and Dockerhub
.release:ngc:
extends: .release:external
variables:
OUT_REGISTRY_USER: "${NGC_REGISTRY_USER}"
OUT_REGISTRY_TOKEN: "${NGC_REGISTRY_TOKEN}"
OUT_REGISTRY: "${NGC_REGISTRY}"
OUT_IMAGE_NAME: "${NGC_REGISTRY_IMAGE}" # This needs to change for the gpu-operator and gpu-operator-validator
release:ngc-gpu-operator:
extends:
- .release:ngc
- .dist-ubi8
- .target-gpu-operator
release:ngc-gpu-operator-validator:
extends:
- .release:ngc
- .dist-ubi8
- .target-gpu-operator-validator
variables:
IN_IMAGE_NAME: "gpu-operator-validator"
OUT_IMAGE_NAME: "${NGC_PROD_VALIDATOR_IMAGE}"
# Define the external image signing steps for NGC
# Download the ngc cli binary for use in the sign steps
.ngccli-setup:
before_script:
- export NGCLI_VERSION=3.31.0
- apk add --no-cache curl
- curl -sSLo ngccli_linux.zip https://api.ngc.nvidia.com/v2/resources/nvidia/ngc-apps/ngc_cli/versions/${NGCLI_VERSION}/files/ngccli_linux.zip
- unzip ngccli_linux.zip
- chmod u+x ngc-cli/ngc
- export PATH=$(pwd)/ngc-cli:${PATH}
- ngc config set --api_key=${NGC_REGISTRY_TOKEN} --org=nvidia
# .sign forms the base of the deployment jobs which signs images in the CI registry.
# This is extended with the image name and version to be deployed.
.sign:ngc:
stage: sign
variables:
IMAGE_NAME: "${OUT_IMAGE_NAME}"
VERSION: "${OUT_IMAGE_VERSION}"
retry:
max: 2
before_script:
- !reference [.ngccli-setup, before_script]
# We ensure that the OUT_IMAGE_VERSION is set
- 'echo Version: ${IMAGE_NAME} ; [[ -n "${VERSION}" ]] || exit 1'
- apk add --no-cache bash
script:
- 'echo "Signing the image ${IMAGE_NAME}:${VERSION}"'
- 'echo "ngc registry image publish --source ${IMAGE_NAME}:${VERSION} ${IMAGE_NAME}:${VERSION} --public --discoverable --allow-guest --sign"'
sign:ngc-gpu-operator:
extends:
- .sign:ngc
needs:
- release:ngc-gpu-operator
rules:
- if: $CI_COMMIT_TAG
variables:
OUT_IMAGE_VERSION: "${CI_COMMIT_TAG}"
OUT_IMAGE_NAME: "${NGC_REGISTRY_IMAGE}" # This needs to change for the gpu-operator and gpu-operator-validator
sign:ngc-gpu-operator-validator:
extends:
- .sign:ngc
needs:
- release:ngc-gpu-operator-validator
rules:
- if: $CI_COMMIT_TAG
variables:
OUT_IMAGE_VERSION: "${CI_COMMIT_TAG}"
OUT_IMAGE_NAME: "${NGC_PROD_VALIDATOR_IMAGE}"
.schedule_defaults:
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
.e2e_defaults:
variables:
# These should match the images generated by the deploy step.
# TODO: Should these use the staging release instead?
OPERATOR_VERSION: "${CI_COMMIT_SHORT_SHA}"
OPERATOR_IMAGE: "${STAGING_REGISTRY}/gpu-operator"
VALIDATOR_VERSION: "${CI_COMMIT_SHORT_SHA}"
VALIDATOR_IMAGE: "${STAGING_REGISTRY}/gpu-operator-validator"
TARGET_DRIVER_VERSION: "525.147.05"
.e2e_tests:
extends:
- .e2e_defaults
- .schedule_defaults
stage: e2e_tests
image: alpine
variables:
SKIP_LAUNCH: "true"
before_script:
- apk add --no-cache openssh-client rsync bash sshpass curl
script:
- source cnt-ci/infrastructure-info
- chmod 400 ${VSPHERE_SSH_PRIVATE_KEY}
- export private_key="${VSPHERE_SSH_PRIVATE_KEY}"
- export instance_hostname="${instance_hostname}"
- rc=0
- ${CI_PROJECT_DIR}/tests/ci-run-e2e.sh ${OPERATOR_IMAGE} ${OPERATOR_VERSION} ${VALIDATOR_IMAGE} ${VALIDATOR_VERSION} ${GPU_DEVICE} || rc=$?
- ${CI_PROJECT_DIR}/tests/scripts/pull.sh /tmp/logs logs
- exit $rc
artifacts:
when: always
paths:
- logs/
e2e_tests_containerd_k8s1_25:
extends:
- .e2e_tests
- .runtime-containerd
dependencies:
- cnt_kube_setup_containerd_k8s1_25
needs:
- cnt_kube_setup_containerd_k8s1_25
e2e_tests_containerd_k8s1_27:
extends:
- .e2e_tests
- .runtime-containerd
dependencies:
- cnt_kube_setup_containerd_k8s1_27
needs:
- cnt_kube_setup_containerd_k8s1_27
.launch_infra:
extends:
- .cnt_kube_setup
- .e2e_defaults
- .infra_setup_defaults
- .schedule_defaults
.clean_infra:
extends:
- .cnt_kube_clean
- .e2e_defaults
- .schedule_defaults
.infra_setup_defaults:
variables:
TF_VAR_os: "ubuntu20.04"
TF_VAR_gpu_mode: "passthrough"
.runtime-containerd:
variables:
TF_VAR_container_runtime: "containerd"
CONTAINER_RUNTIME: "containerd"
cnt_kube_setup_containerd_k8s1_25:
extends:
- .launch_infra
- .runtime-containerd
variables:
TF_VAR_kubernetes_version: "1.25.11"
TF_VAR_gpu_device_name: "NVIDIA-A100-PCIE-40GB"
cnt_kube_clean_containerd_k8s1_25:
extends:
- .clean_infra
dependencies:
- cnt_kube_setup_containerd_k8s1_25
cnt_kube_setup_containerd_k8s1_27:
extends:
- .launch_infra
- .runtime-containerd
variables:
TF_VAR_kubernetes_version: "1.27.3"
TF_VAR_gpu_device_name: "NVIDIA-A100-PCIE-40GB"
cnt_kube_clean_containerd_k8s1_27:
extends:
- .clean_infra
dependencies:
- cnt_kube_setup_containerd_k8s1_27