Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[gitlab] add support for multiarch images in redhat #1252

Merged
merged 4 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 63 additions & 40 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,25 @@ preflight_redhat_image_amd64:
script:
- DOCKER_REGISTRY_LOGIN=$(aws ssm get-parameter --region us-east-1 --name ci.datadog-operator.$DOCKER_REGISTRY_LOGIN_SSM_KEY --with-decryption --query "Parameter.Value" --out text)
- aws ssm get-parameter --region us-east-1 --name ci.datadog-operator.$DOCKER_REGISTRY_PWD_SSM_KEY --with-decryption --query "Parameter.Value" --out text | docker login --username "$DOCKER_REGISTRY_LOGIN" --password-stdin "$DOCKER_REGISTRY_URL"
- export IMG_PLATFORM=linux/amd64
- make preflight-redhat-container


preflight_redhat_image_arm64:
stage: test-image
rules:
- if: $CI_COMMIT_TAG
when: on_success
- when: never
tags:
- "arch:amd64"
image: $JOB_DOCKER_IMAGE
variables:
IMG: $BUILD_DOCKER_REGISTRY/$PROJECTNAME:v${CI_PIPELINE_ID}-${CI_COMMIT_SHORT_SHA}-arm64
script:
- DOCKER_REGISTRY_LOGIN=$(aws ssm get-parameter --region us-east-1 --name ci.datadog-operator.$DOCKER_REGISTRY_LOGIN_SSM_KEY --with-decryption --query "Parameter.Value" --out text)
- aws ssm get-parameter --region us-east-1 --name ci.datadog-operator.$DOCKER_REGISTRY_PWD_SSM_KEY --with-decryption --query "Parameter.Value" --out text | docker login --username "$DOCKER_REGISTRY_LOGIN" --password-stdin "$DOCKER_REGISTRY_URL"
- export IMG_PLATFORM=linux/arm64
- make preflight-redhat-container


Expand Down Expand Up @@ -222,7 +241,6 @@ publish_public_tag:
IMG_DESTINATIONS_REGEX_REPL: ':'
IMG_SIGNING: "false"

# RedHat does not support multi-arch images. Use docker commands in lieu of DataDog/public-images until they do.
publish_redhat_public_tag:
stage: release
rules:
Expand All @@ -231,30 +249,18 @@ publish_redhat_public_tag:
- when: never
needs:
- "preflight_redhat_image_amd64"
tags: ["runner:docker", "size:large"]
image: $JOB_DOCKER_IMAGE
script:
- apt-get update && apt-get -y install --no-install-recommends build-essential git awscli && apt-get -y clean && rm -rf /var/lib/apt/lists/*
# Docker login to pull build image
- DOCKER_REGISTRY_LOGIN=$(aws ssm get-parameter --region us-east-1 --name ci.datadog-operator.$DOCKER_REGISTRY_LOGIN_SSM_KEY --with-decryption --query "Parameter.Value" --out text)
- aws ssm get-parameter --region us-east-1 --name ci.datadog-operator.$DOCKER_REGISTRY_PWD_SSM_KEY --with-decryption --query "Parameter.Value" --out text | docker login --username "$DOCKER_REGISTRY_LOGIN" --password-stdin "$DOCKER_REGISTRY_URL"
- docker pull --platform linux/amd64 $BUILD_DOCKER_REGISTRY/$PROJECTNAME:$CI_COMMIT_TAG-amd64
- docker tag $BUILD_DOCKER_REGISTRY/$PROJECTNAME:$CI_COMMIT_TAG-amd64 $RH_PARTNER_REGISTRY/$RH_PARTNER_PROJECT_ID:${CI_COMMIT_TAG:1}
# Docker login to push image to Redhat
- aws ssm get-parameter --region us-east-1 --name ci.datadog-operator.$RH_PARTNER_REGISTRY_KEY_SSM_KEY --with-decryption --query "Parameter.Value" --out text | docker login -u "$RH_PARTNER_REGISTRY_USER" quay.io --password-stdin
- docker push $RH_PARTNER_REGISTRY/$RH_PARTNER_PROJECT_ID:${CI_COMMIT_TAG:1}

# Save for future use with public-images.
# trigger:
# project: DataDog/public-images
# branch: main
# strategy: depend
# variables:
# IMG_SOURCES: $BUILD_DOCKER_REGISTRY/$PROJECTNAME:$CI_COMMIT_TAG-amd64
# IMG_DESTINATIONS: operator:$CI_COMMIT_TAG
# IMG_DESTINATIONS_REGEX: ':v'
# IMG_DESTINATIONS_REGEX_REPL: ':'
# IMG_REGISTRIES: redhat-operator
- "preflight_redhat_image_arm64"
trigger:
project: DataDog/public-images
branch: main
strategy: depend
variables:
IMG_SOURCES: $BUILD_DOCKER_REGISTRY/$PROJECTNAME:$CI_COMMIT_TAG-amd64,$BUILD_DOCKER_REGISTRY/$PROJECTNAME:$CI_COMMIT_TAG-arm64
IMG_DESTINATIONS: $RH_PARTNER_PROJECT_ID:$CI_COMMIT_TAG
IMG_DESTINATIONS_REGEX: ':v'
IMG_DESTINATIONS_REGEX_REPL: ':'
IMG_REGISTRIES: redhat-operator
IMG_SIGNING: "false"

publish_public_latest:
stage: release
Expand All @@ -271,7 +277,6 @@ publish_public_latest:
IMG_DESTINATIONS: operator:latest
IMG_SIGNING: "false"

# RedHat does not support multi-arch images. Use docker commands in lieu of DataDog/public-images until they do.
publish_redhat_public_latest:
stage: release
rules:
Expand All @@ -280,18 +285,16 @@ publish_redhat_public_latest:
- when: never
needs:
- "preflight_redhat_image_amd64"
tags: ["runner:docker", "size:large"]
image: $JOB_DOCKER_IMAGE
script:
- apt-get update && apt-get -y install --no-install-recommends build-essential git awscli && apt-get -y clean && rm -rf /var/lib/apt/lists/*
# Docker login to pull build image
- DOCKER_REGISTRY_LOGIN=$(aws ssm get-parameter --region us-east-1 --name ci.datadog-operator.$DOCKER_REGISTRY_LOGIN_SSM_KEY --with-decryption --query "Parameter.Value" --out text)
- aws ssm get-parameter --region us-east-1 --name ci.datadog-operator.$DOCKER_REGISTRY_PWD_SSM_KEY --with-decryption --query "Parameter.Value" --out text | docker login --username "$DOCKER_REGISTRY_LOGIN" --password-stdin "$DOCKER_REGISTRY_URL"
- docker pull --platform linux/amd64 $BUILD_DOCKER_REGISTRY/$PROJECTNAME:$CI_COMMIT_TAG-amd64
- docker tag $BUILD_DOCKER_REGISTRY/$PROJECTNAME:$CI_COMMIT_TAG-amd64 $RH_PARTNER_REGISTRY/$RH_PARTNER_PROJECT_ID:latest
# Docker login to push image to Redhat
- aws ssm get-parameter --region us-east-1 --name ci.datadog-operator.$RH_PARTNER_REGISTRY_KEY_SSM_KEY --with-decryption --query "Parameter.Value" --out text | docker login -u "$RH_PARTNER_REGISTRY_USER" quay.io --password-stdin
- docker push $RH_PARTNER_REGISTRY/$RH_PARTNER_PROJECT_ID:latest
- "preflight_redhat_image_arm64"
trigger:
project: DataDog/public-images
branch: main
strategy: depend
variables:
IMG_SOURCES: $BUILD_DOCKER_REGISTRY/$PROJECTNAME:$CI_COMMIT_TAG-amd64,$BUILD_DOCKER_REGISTRY/$PROJECTNAME:$CI_COMMIT_TAG-arm64
IMG_DESTINATIONS: $RH_PARTNER_PROJECT_ID:latest
IMG_REGISTRIES: redhat-operator
IMG_SIGNING: "false"

trigger_internal_operator_image:
stage: release
Expand Down Expand Up @@ -435,7 +438,8 @@ e2e:
script:
- IMAGE_PULL_PASSWORD=$(aws ecr get-login-password) IMG=$TARGET_IMAGE make e2e-tests

submit_preflight_redhat_public_tag:

submit_preflight_redhat_image_amd64:
stage: post-release
rules:
- if: $CI_COMMIT_TAG
Expand All @@ -450,8 +454,26 @@ submit_preflight_redhat_public_tag:
- aws ssm get-parameter --region us-east-1 --name ci.datadog-operator.$RH_PARTNER_REGISTRY_KEY_SSM_KEY --with-decryption --query "Parameter.Value" --out text | docker login --username "$RH_PARTNER_REGISTRY_USER" --password-stdin "$RH_PARTNER_REGISTRY"
- export RH_PARTNER_API_TOKEN=$(aws ssm get-parameter --region us-east-1 --name ci.datadog-operator.$RH_PARTNER_API_KEY_SSM_KEY --with-decryption --query "Parameter.Value" --out text)
- export IMG=$RH_PARTNER_REGISTRY/$RH_PARTNER_PROJECT_ID:${CI_COMMIT_TAG:1}
- export IMG_PLATFORM=linux/amd64
- make preflight-redhat-container-submit

submit_preflight_redhat_image_arm64:
stage: post-release
rules:
- if: $CI_COMMIT_TAG
when: manual
- when: never
needs:
- "publish_redhat_public_tag"
tags: ["runner:docker", "size:large"]
image: $JOB_DOCKER_IMAGE
script:
- apt-get update && apt-get -y install --no-install-recommends build-essential git awscli && apt-get -y clean && rm -rf /var/lib/apt/lists/*
- aws ssm get-parameter --region us-east-1 --name ci.datadog-operator.$RH_PARTNER_REGISTRY_KEY_SSM_KEY --with-decryption --query "Parameter.Value" --out text | docker login --username "$RH_PARTNER_REGISTRY_USER" --password-stdin "$RH_PARTNER_REGISTRY"
- export RH_PARTNER_API_TOKEN=$(aws ssm get-parameter --region us-east-1 --name ci.datadog-operator.$RH_PARTNER_API_KEY_SSM_KEY --with-decryption --query "Parameter.Value" --out text)
- export IMG=$RH_PARTNER_REGISTRY/$RH_PARTNER_PROJECT_ID:${CI_COMMIT_TAG:1}
- export IMG_PLATFORM=linux/arm64
- make preflight-redhat-container-submit

publish_community_operators:
stage: post-release
Expand All @@ -460,7 +482,8 @@ publish_community_operators:
when: manual
- when: never
needs:
- "submit_preflight_redhat_public_tag"
- "submit_preflight_redhat_image_amd64"
- "submit_preflight_redhat_image_arm64"
tags: [ "runner:docker", "size:large" ]
image: $JOB_DOCKER_IMAGE
before_script:
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -294,12 +294,12 @@ generate-openapi: bin/$(PLATFORM)/openapi-gen

.PHONY: preflight-redhat-container
preflight-redhat-container: bin/$(PLATFORM)/preflight
bin/$(PLATFORM)/preflight check container ${IMG} -d ~/.docker/config.json
bin/$(PLATFORM)/preflight check container ${IMG} --platform=${IMG_PLATFORM} -d ~/.docker/config.json

# Runs only on Linux and requires `docker login` to scan.connect.redhat.com
.PHONY: preflight-redhat-container-submit
preflight-redhat-container-submit: bin/$(PLATFORM)/preflight
bin/$(PLATFORM)/preflight check container ${IMG} --submit --pyxis-api-token=${RH_PARTNER_API_TOKEN} --certification-project-id=${RH_PARTNER_PROJECT_ID} -d ~/.docker/config.json
bin/$(PLATFORM)/preflight check container ${IMG} --platform=${IMG_PLATFORM} --submit --pyxis-api-token=${RH_PARTNER_API_TOKEN} --certification-project-id=${RH_PARTNER_PROJECT_ID} -d ~/.docker/config.json

.PHONY: patch-crds
patch-crds: bin/$(PLATFORM)/yq ## Patch-crds
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ metadata:
operators.operatorframework.io/builder: operator-sdk-v1.2.0
operators.operatorframework.io/project_layout: go.kubebuilder.io/v2
repository: https://github.com/DataDog/datadog-operator
labels:
operatorframework.io/os.linux: supported
operatorframework.io/arch.amd64: supported
operatorframework.io/arch.arm64: supported
name: datadog-operator.v0.0.0
namespace: placeholder
spec:
Expand Down
Loading