Skip to content

Commit e1cb848

Browse files
authored
CLOUDP-264334: Explicitly trust ubi certs in Dockerfile (#1721)
* CLOUDP-264334: Explicitly trust ubi certs in Dockerfile * Make CI preflight check the test images Signed-off-by: jose.vazquez <[email protected]> --------- Signed-off-by: jose.vazquez <[email protected]>
1 parent 3d10806 commit e1cb848

File tree

8 files changed

+49
-17
lines changed

8 files changed

+49
-17
lines changed
Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
name: 'certify-openshift-images'
22
description: 'Push image to RedHat Connect for certification'
33
inputs:
4+
registry:
5+
description: Name of the registry to certify from
6+
required: true
7+
default: "quay.io"
48
repository:
59
description: The name of repository of the image to be certified
610
required: true
711
version:
812
description: The version of the image to be certified
913
required: true
10-
quay_password:
14+
registry_password:
1115
description: The password to access the quay.io registry
1216
required: true
1317
rhcc_token:
@@ -16,12 +20,18 @@ inputs:
1620
rhcc_project:
1721
description: The Redhat certification central project id
1822
required: true
23+
submit:
24+
description: Whether or not to submit the result of the preflight
25+
required: true
26+
default: false
1927
runs:
2028
using: 'docker'
2129
image: 'Dockerfile'
2230
env:
31+
REGISTRY: ${{ inputs.registry }}
2332
REPOSITORY: ${{ inputs.repository }}
2433
VERSION: ${{ inputs.version }}
25-
QUAY_PASSWORD: ${{ inputs.quay_password }}
34+
REGISTRY_PASSWORD: ${{ inputs.registry_password }}
2635
RHCC_TOKEN: ${{ inputs.rhcc_token }}
27-
RHCC_PROJECT: ${{ inputs.rhcc_project }}
36+
RHCC_PROJECT: ${{ inputs.rhcc_project }}
37+
SUBMIT: ${{ inputs.submit }}

.github/actions/certify-openshift-images/entrypoint.sh

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,27 @@
22

33
set -eou pipefail
44

5-
docker login -u mongodb+mongodb_atlas_kubernetes -p "${QUAY_PASSWORD}" quay.io
5+
docker login -u mongodb+mongodb_atlas_kubernetes -p "${REGISTRY_PASSWORD}" "${REGISTRY}"
66

7-
DIGESTS=$(docker manifest inspect "quay.io/${REPOSITORY}:${VERSION}" | jq -r '.manifests[] | select(.platform.os!="unknown") | .digest')
8-
mapfile -t PLATFORMS < <(docker manifest inspect "quay.io/${REPOSITORY}:${VERSION}" | jq -r '.manifests[] | select(.platform.os!="unknown") | .platform.architecture')
7+
DIGESTS=$(docker manifest inspect "${REGISTRY}/${REPOSITORY}:${VERSION}" | jq -r '.manifests[] | select(.platform.os!="unknown") | .digest')
8+
mapfile -t PLATFORMS < <(docker manifest inspect "${REGISTRY}/${REPOSITORY}:${VERSION}" | jq -r '.manifests[] | select(.platform.os!="unknown") | .platform.architecture')
9+
10+
submit_flag=--submit
11+
if [ "${SUBMIT}" == "false" ]; then
12+
submit_flag=
13+
fi
914

1015
INDEX=0
1116
for DIGEST in $DIGESTS; do
1217
echo "Check and Submit result to RedHat Connect"
1318
# Send results to RedHat if preflight finished wthout errors
14-
preflight check container "quay.io/${REPOSITORY}@${DIGEST}" \
19+
preflight check container "${REGISTRY}/${REPOSITORY}@${DIGEST}" \
1520
--artifacts "${DIGEST}" \
1621
--platform "${PLATFORMS[$INDEX]}" \
1722
--pyxis-api-token="${RHCC_TOKEN}" \
1823
--certification-project-id="${RHCC_PROJECT}" \
1924
--docker-config="${HOME}/.docker/config.json" \
20-
--submit
25+
${submit_flag}
2126

2227
(( INDEX++ )) || true
2328
done

.github/workflows/openshift-upgrade-test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ concurrency:
2828
cancel-in-progress: true
2929
jobs:
3030
e2e-tests:
31-
name: Prepare E2E configuration and image
31+
name: Upgrade test on Openshift
3232
runs-on: ubuntu-latest
3333
if: ${{ vars.SKIP_OPENSHIFT != 'true' }}
3434
steps:

.github/workflows/release-openshift.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,13 @@ jobs:
6666
- name: Certify Openshift images
6767
uses: ./.github/actions/certify-openshift-images
6868
with:
69-
repository: quay.io/mongodb/mongodb-atlas-kubernetes-operator
69+
registry: quay.io
70+
registry_password: ${{ secrets.QUAY_PASSWORD }}
71+
repository: mongodb/mongodb-atlas-kubernetes-operator
7072
version: ${{ github.event.inputs.version }}
71-
quay_password: ${{ secrets.QUAY_PASSWORD }}
7273
rhcc_token: ${{ secrets.RH_CERTIFICATION_PYXIS_API_TOKEN }}
7374
rhcc_project: ${{ secrets.RH_CERTIFICATION_OSPID }}
75+
submit: true
7476
- name: Configure certified release
7577
if: ${{ matrix.certified }}
7678
env:

.github/workflows/release-post-merge.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,13 @@ jobs:
160160
if: ${{ steps.tag.outputs.certify == 'true' }}
161161
uses: ./.github/actions/certify-openshift-images
162162
with:
163+
registry: quay.io
164+
registry_password: ${{ secrets.QUAY_PASSWORD }}
163165
repository: ${{ steps.tag.outputs.repo }}
164166
version: ${{ steps.tag.outputs.certified_version }}
165-
quay_password: ${{ secrets.QUAY_PASSWORD }}
166167
rhcc_token: ${{ secrets.RH_CERTIFICATION_PYXIS_API_TOKEN }}
167168
rhcc_project: ${{ secrets.RH_CERTIFICATION_OSPID }}
169+
submit: true
168170
- name: Login to artifactory.corp.mongodb.com
169171
if: steps.check-signing-support.outputs.sign == 'true'
170172
uses: docker/login-action@v3

.github/workflows/test-e2e.yml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
name: Prepare E2E configuration and image
3232
runs-on: ubuntu-latest
3333
env:
34-
GHCR_REPO: ghcr.io/${{ github.repository_owner }}/mongodb-atlas-kubernetes-operator-prerelease
34+
REPOSITORY: ${{ github.repository_owner }}/mongodb-atlas-kubernetes-operator-prerelease
3535
steps:
3636
- if: ${{ inputs.forked == false }}
3737
name: Check out code
@@ -56,12 +56,23 @@ jobs:
5656
- name: Build and Push image
5757
uses: ./.github/actions/build-push-image
5858
with:
59-
repository: ${{ env.GHCR_REPO }}
59+
repository: ghcr.io/${{ env.REPOSITORY }}
6060
version: ${{ steps.prepare.outputs.tag }}
61-
tags: ${{ env.GHCR_REPO }}:${{ steps.prepare.outputs.tag }}
61+
tags: ghcr.io/${{ env.REPOSITORY }}:${{ steps.prepare.outputs.tag }}
6262
platforms: linux/amd64
6363
push_to_docker: false
6464
forked: ${{ inputs.forked }}
65+
- name: Do preflight-check on test image
66+
uses: ./.github/actions/certify-openshift-images
67+
with:
68+
registry: ghcr.io
69+
registry_password: ${{ secrets.GITHUB_TOKEN }}
70+
repository: ${{ env.REPOSITORY }}
71+
version: ${{ steps.prepare.outputs.tag }}
72+
rhcc_token: ${{ secrets.RH_CERTIFICATION_PYXIS_API_TOKEN }}
73+
rhcc_project: ${{ secrets.RH_CERTIFICATION_OSPID }}
74+
submit: false
75+
6576
prepare-e2e-bundle:
6677
name: Prepare E2E Bundle configuration and image
6778
runs-on: ubuntu-latest

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ ENV TARGET_OS=${TARGETOS}
2828

2929
RUN make manager
3030

31+
FROM registry.access.redhat.com/ubi9/ubi:9.2 as ubi-certs
3132
FROM registry.access.redhat.com/ubi9/ubi-micro:9.2
3233

3334
LABEL name="MongoDB Atlas Operator" \
@@ -46,7 +47,7 @@ LABEL name="MongoDB Atlas Operator" \
4647
WORKDIR /
4748
COPY --from=builder /workspace/bin/manager .
4849
COPY hack/licenses licenses
49-
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem
50+
COPY --from=ubi-certs /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem
5051

5152
USER 1001:0
5253
ENTRYPOINT ["/manager"]

fast.Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# TODO: Eventually replace main Dockerfile
22
FROM golang:1.22 as certs-source
33

4+
FROM registry.access.redhat.com/ubi9/ubi:9.2 as ubi-certs
45
FROM registry.access.redhat.com/ubi9/ubi-micro:9.2
56

67
ARG TARGETOS
@@ -23,7 +24,7 @@ LABEL name="MongoDB Atlas Operator" \
2324
WORKDIR /
2425
COPY bin/${TARGET_OS}/${TARGET_ARCH}/manager .
2526
COPY hack/licenses licenses
26-
COPY --from=certs-source /etc/ssl/certs/ca-certificates.crt /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem
27+
COPY --from=ubi-certs /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem
2728

2829
USER 1001:0
2930
ENTRYPOINT ["/manager"]

0 commit comments

Comments
 (0)