Skip to content

Commit 9cf4faf

Browse files
authored
Merge pull request #123 from JunAr7112/ngc_pipeline_changes
NGC Pipeline changes
2 parents f9bd0f2 + 7f1b208 commit 9cf4faf

File tree

2 files changed

+78
-55
lines changed

2 files changed

+78
-55
lines changed

.common-ci.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ stages:
3131
- test
3232
- scan
3333
- release
34-
- sign
34+
- ngc-publish
3535

3636
.dist-ubi9:
3737
variables:
@@ -106,10 +106,10 @@ stages:
106106
extends:
107107
- .release
108108
variables:
109-
OUT_REGISTRY_USER: "${CI_REGISTRY_USER}"
110-
OUT_REGISTRY_TOKEN: "${CI_REGISTRY_PASSWORD}"
111-
OUT_REGISTRY: "${CI_REGISTRY}"
112-
OUT_IMAGE_NAME: "${CI_REGISTRY_IMAGE}/staging/k8s-kata-manager"
109+
OUT_REGISTRY_USER: "${NGC_REGISTRY_USER}"
110+
OUT_REGISTRY_TOKEN: "${NGC_REGISTRY_TOKEN}"
111+
OUT_REGISTRY: "${NGC_REGISTRY}"
112+
OUT_IMAGE_NAME: "${NGC_STAGING_REGISTRY}/k8s-kata-manager"
113113

114114
# Define an external release step that pushes an image to an external repository.
115115
.release:external:

.nvidia-ci.yml

Lines changed: 73 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -111,64 +111,87 @@ scan-arm64:
111111
- .dist-ubi9
112112
- .platform-arm64
113113

114-
# Define the external release helpers
115-
.release:ngc:
116-
extends: .release:external
117-
variables:
118-
OUT_REGISTRY_USER: "${NGC_REGISTRY_USER}"
119-
OUT_REGISTRY_TOKEN: "${NGC_REGISTRY_TOKEN}"
120-
OUT_REGISTRY: "${NGC_REGISTRY}"
121-
OUT_IMAGE_NAME: "${NGC_REGISTRY_IMAGE}"
122-
123-
# Define the external release targets
124-
# Release to NGC
125-
release:ngc-ubi9:
126-
extends:
127-
- .release:ngc
128-
- .dist-ubi9
129-
130-
# Define the external image signing steps for NGC
131-
# Download the ngc cli binary for use in the sign steps
132-
.ngccli-setup:
114+
.ngc-publish-variables:
133115
before_script:
134-
- apt-get update && apt-get install -y curl unzip jq
135116
- |
136-
if [ -z "${NGCCLI_VERSION}" ]; then
137-
NGC_VERSION_URL="https://api.ngc.nvidia.com/v2/resources/nvidia/ngc-apps/ngc_cli/versions"
138-
# Extract the latest version from the JSON data using jq
139-
export NGCCLI_VERSION=$(curl -s $NGC_VERSION_URL | jq -r '.recipe.latestVersionIdStr')
117+
if [ -n "${CI_COMMIT_TAG}" ]; then
118+
echo "${CI_COMMIT_SHORT_SHA} ${CI_COMMIT_TAG}" > build-info-${CI_PIPELINE_ID}.txt
119+
else
120+
echo "${CI_COMMIT_SHORT_SHA} ${CI_COMMIT_SHORT_SHA}" > build-info-${CI_PIPELINE_ID}.txt
140121
fi
141-
echo "NGCCLI_VERSION ${NGCCLI_VERSION}"
142-
- curl -sSLo ngccli_linux.zip https://api.ngc.nvidia.com/v2/resources/nvidia/ngc-apps/ngc_cli/versions/${NGCCLI_VERSION}/files/ngccli_linux.zip
143-
- unzip ngccli_linux.zip
144-
- chmod u+x ngc-cli/ngc
145122
146-
# .sign forms the base of the deployment jobs which signs images in the CI registry.
147-
# This is extended with the image name and version to be deployed.
148-
.sign:ngc:
149-
image: ubuntu:latest
150-
when: always
151-
stage: sign
123+
.update-nspect:
124+
stage: ngc-publish
125+
needs:
126+
- job: release:staging-ubi9
127+
extends:
128+
- .ngc-publish-variables
129+
image:
130+
name: "${CNT_NGC_PUBLISH_IMAGE}"
131+
pull_policy: always
132+
variables:
133+
PROJECT_NAME: "k8s-kata-manager"
134+
REPO_URL: "https://github.com/NVIDIA/k8s-kata-manager.git"
135+
script:
136+
- |
137+
cnt-ngc-publish nspect --versions-file "build-info-${CI_PIPELINE_ID}.txt"
138+
139+
# Update the nspect staging environment to test the nspect publishing logic
140+
update-nspect-staging:
141+
extends:
142+
- .update-nspect
143+
except:
144+
- tags
145+
variables:
146+
ENV: "stage"
147+
RELEASE_VERSION: "test"
148+
NSPECT_CLIENT_ID: "${NSPECT_STAGING_CLIENT_ID}"
149+
NSPECT_CLIENT_SECRET: "${NSPECT_STAGING_CLIENT_SECRET}"
150+
151+
# Update the nspect production environment with the new release
152+
update-nspect:
153+
extends:
154+
- .update-nspect
152155
rules:
153156
- if: $CI_COMMIT_TAG
154157
variables:
155-
NGC_CLI_API_KEY: "${NGC_REGISTRY_TOKEN}"
156-
IMAGE_NAME: "${NGC_REGISTRY_IMAGE}"
157-
IMAGE_TAG: "${CI_COMMIT_TAG}"
158-
retry:
159-
max: 2
160-
before_script:
161-
- !reference [.ngccli-setup, before_script]
162-
# We ensure that the IMAGE_NAME and IMAGE_TAG is set
163-
- 'echo Image Name: ${IMAGE_NAME} && [[ -n "${IMAGE_NAME}" ]] || exit 1'
164-
- 'echo Image Tag: ${IMAGE_TAG} && [[ -n "${IMAGE_TAG}" ]] || exit 1'
158+
OSRB_BUG_ID: "${OSRB_BUG_ID}"
159+
ENV: "prod"
160+
RELEASE_VERSION: "${CI_COMMIT_TAG}"
161+
NSPECT_CLIENT_ID: "${NSPECT_PROD_CLIENT_ID}"
162+
NSPECT_CLIENT_SECRET: "${NSPECT_PROD_CLIENT_SECRET}"
163+
164+
.publish-images:
165+
stage: ngc-publish
166+
extends:
167+
- .ngc-publish-variables
168+
image:
169+
name: "${CNT_NGC_PUBLISH_IMAGE}"
170+
pull_policy: always
171+
variables:
172+
GITLAB_ACCESS_TOKEN: "${CNT_GITLAB_TOKEN}"
165173
script:
166-
- 'echo "Signing the image ${IMAGE_NAME}:${IMAGE_TAG}"'
167-
- ngc-cli/ngc registry image publish --source ${IMAGE_NAME}:${IMAGE_TAG} ${IMAGE_NAME}:${IMAGE_TAG} --public --discoverable --allow-guest --sign --org nvidia
174+
- cnt-ngc-publish render --project-name "k8s-kata-manager" --versions-file "build-info-${CI_PIPELINE_ID}.txt" --output k8s-kata-manager.yaml
175+
- cnt-ngc-publish merge-request --files "k8s-kata-manager.yaml"
168176

169-
sign:ngc-ubi9:
177+
# Raise an MR to publish the image to NGC
178+
ngc-image-publish:
170179
extends:
171-
- .dist-ubi9
172-
- .sign:ngc
180+
- .publish-images
181+
rules:
182+
- if: $CI_COMMIT_TAG
173183
needs:
174-
- release:ngc-ubi9
184+
- job: update-nspect
185+
variables:
186+
NGC_PUBLISHING_PROJECT_PATH: "${NGC_PUBLISHING_PROD_PROJECT_PATH}"
187+
188+
# Create a dummy MR that exercises the publishing logic
189+
mock-image-publish:
190+
extends:
191+
- .publish-images
192+
except:
193+
- tags
194+
needs:
195+
- job: update-nspect-staging
196+
variables:
197+
NGC_PUBLISHING_PROJECT_PATH: "${NGC_PUBLISHING_TEST_PROJECT_PATH}"

0 commit comments

Comments
 (0)