-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'add-internal-ci' into 'main'
Add CI for internal gitlab See merge request nvidia/cloud-native/k8s-kata-manager!18
- Loading branch information
Showing
2 changed files
with
130 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
# Copyright (c) NVIDIA CORPORATION. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
include: | ||
- local: '.common-ci.yml' | ||
|
||
default: | ||
tags: | ||
- cnt | ||
- container-dev | ||
- docker/multi-arch | ||
- docker/privileged | ||
- os/linux | ||
- type/docker | ||
|
||
variables: | ||
DOCKER_DRIVER: overlay2 | ||
DOCKER_TLS_CERTDIR: "/certs" | ||
# 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/cloud-native/k8s-kata-manager/staging | ||
STAGING_VERSION: ${CI_COMMIT_SHORT_SHA} | ||
|
||
image-build: | ||
stage: image-build | ||
variables: | ||
IN_REGISTRY: "${STAGING_REGISTRY}" | ||
IN_IMAGE_NAME: k8s-kata-manager | ||
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}" | ||
PUSH_MULTIPLE_TAGS: "false" | ||
# 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: | ||
- apk add --no-cache make bash | ||
script: | ||
- docker login "${OUT_REGISTRY}" -u "${OUT_REGISTRY_USER}" -p "${OUT_REGISTRY_TOKEN}" | ||
- make IMAGE=${IN_REGISTRY}/${IN_IMAGE_NAME}:${IN_VERSION} pull-image | ||
- make IMAGE=${IN_REGISTRY}/${IN_IMAGE_NAME}:${IN_VERSION} OUT_IMAGE=${OUT_IMAGE_NAME}:${CI_COMMIT_SHORT_SHA} push-image | ||
|
||
# The .scan step forms the base of the image scan operation performed before releasing | ||
# images. | ||
.scan: | ||
stage: scan | ||
image: "${PULSE_IMAGE}" | ||
variables: | ||
IMAGE: "${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHORT_SHA}" | ||
IMAGE_ARCHIVE: "k8s-kata-manager.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-amd64: | ||
extends: | ||
- .scan | ||
- .platform-amd64 | ||
|
||
# Define the external release helpers | ||
.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}" | ||
# Disable external releases for now | ||
DOCKER: echo docker | ||
REGCTL: echo regctl | ||
|
||
# Define the external release targets | ||
# Release to NGC | ||
release:ngc: | ||
extends: | ||
- .release:ngc |