8000 feat: Add redhat certification for operator by jaitaiwan · Pull Request #2081 · Altinity/clickhouse-operator · GitHub
[go: up one dir, main page]

Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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
< 10BC8 div class="container-md js-file-filter-blankslate" data-target="diff-file-filter.blankslate" hidden>

There are no files selected for viewing

67 changes: 67 additions & 0 deletions .github/workflows/check_redhat_bundle.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: check_redhat_bundle

on:
pull_request:
paths:
- .github/workflows/check_redhat_bundle.yaml
- .github/workflows/publish_redhat_bundle.yaml
- deploy/certified-operator/**
- deploy/operatorhub/metadata/annotations.yaml
- deploy/builder/operatorhub.sh
- deploy/builder/templates-operatorhub/**
- deploy/builder/templates-install-bundle/**
- docs/chi-examples/**
- docs/chk-examples/**
- config/**
- pkg/apis/**
- release
- releases
workflow_dispatch:

permissions:
contents: read

env:
OPERATOR_SDK_VERSION: v1.42.3
YQ_VERSION: v4.47.2
OPERATOR_IMAGE: registry.example.invalid/altinity/clickhouse-operator@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
METRICS_IMAGE: registry.example.invalid/altinity/metrics-exporter@sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
OPENSHIFT_VERSIONS: v4.18-v4.22
VALID_SUBSCRIPTION: No subscription required; optional commercial support is available from Altinity
RELATED_IMAGES: |
clickhouse-server=registry.example.invalid/altinity/clickhouse-server@sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
clickhouse-keeper=registry.example.invalid/altinity/clickhouse-keeper@sha256:dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd
clickhouse-log=registry.example.invalid/redhat/ubi-minimal@sha256:eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee

jobs:
validate:
name: Generate and validate certified bundle
runs-on: ubuntu-latest
steps:
- name: Checkout project
uses: actions/checkout@v4

- name: Install bundle tools
run: |
set -euo pipefail
sudo curl -fsSLo /usr/local/bin/yq \
"https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_amd64"
sudo chmod 0755 /usr/local/bin/yq
curl -fsSLo /tmp/operator-sdk \
"https://github.com/operator-framework/operator-sdk/releases/download/${OPERATOR_SDK_VERSION}/operator-sdk_linux_amd64"
sudo install -m 0755 /tmp/operator-sdk /usr/local/bin/operator-sdk

- name: Generate certified bundle
run: ./deploy/certified-operator/build-bundle.sh

- name: Validate certified bundle
run: ./deploy/certified-operator/verify-bundle.sh

- name: Build bundle image
run: |
docker build \
--file deploy/certified-operator/bundle.Dockerfile \
--build-arg BUNDLE_PACKAGE=altinity-clickhouse-operator \
--build-arg OPENSHIFT_VERSIONS="${OPENSHIFT_VERSIONS}" \
--tag localhost/altinity-clickhouse-operator-bundle:validation \
.
150 changes: 150 additions & 0 deletions .github/workflows/check_ubi9.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
name: check_ubi9

on:
pull_request:
paths:
- .github/workflows/check_ubi9.yaml
- .github/workflows/release_ubi9.yaml
- dockerfile/ubi9/**
- .dockerignore
- LICENSE
- THIRD_PARTY_NOTICES.md
- cmd/**
- config/**
- dev/go_build_*.sh
- go.mod
- go.sum
- pkg/**
- release
workflow_dispatch:

permissions:
contents: read

env:
REGISTRY: localhost
REGISTRY_NAMESPACE: ubi9-check
OPERATOR_IMAGE_NAME: clickhouse-operator
METRICS_IMAGE_NAME: metrics-exporter
IMAGE_RELEASE: "1"
GOFIPS140: v1.0.0
GODEBUG_FIPS140: off

jobs:
dockerfiles:
name: Check UBI Dockerfiles
runs-on: ubuntu-latest
steps:
- name: Checkout project
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Verify UBI-only base image declarations
run: |
set -euo pipefail
files=(
dockerfile/ubi9/operator/Dockerfile
dockerfile/ubi9/metrics-exporter/Dockerfile
)
# Both images must ship on the same Red Hat base
ubi_images=$(grep -h '^ARG UBI_IMAGE=' "${files[@]}" | sort -u)
if [[ $(wc -l <<< "${ubi_images}") -ne 1 || "${ubi_images}" != "ARG UBI_IMAGE=registry.access.redhat.com/"* ]]; then
echo "UBI Dockerfiles must declare one Red Hat UBI_IMAGE, got: ${ubi_images}" >&2
exit 1
fi
for file in "${files[@]}"; do
if grep -nE '^FROM .*\b(golang|docker\.io|gcr\.io|quay\.io)/?' "${file}"; then
echo "Non-Red Hat base image declared in ${file}" >&2
exit 1
fi
docker buildx build --check --file "${file}" .
done

build:
name: Build ${{ matrix.component }} (${{ matrix.arch }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- component: operator
arch: amd64
platform: linux/amd64
dockerfile: dockerfile/ubi9/operator/Dockerfile
binary: clickhouse-operator
- component: operator
arch: arm64
platform: linux/arm64
dockerfile: dockerfile/ubi9/operator/Dockerfile
binary: clickhouse-operator
- component: metrics-exporter
arch: amd64
platform: linux/amd64
dockerfile: dockerfile/ubi9/metrics-exporter/Dockerfile
binary: metrics-exporter
- component: metrics-exporter
arch: arm64
platform: linux/arm64
dockerfile: dockerfile/ubi9/metrics-exporter/Dockerfile
binary: metrics-exporter

steps:
- name: Checkout project
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build UBI image
env:
COMPONENT: ${{ matrix.component }}
PLATFORM: ${{ matrix.platform }}
ARCH: ${{ matrix.arch }}
DOCKERFILE: ${{ matrix.dockerfile }}
run: |
set -euo pipefail
GO_VERSION=$(awk '/^go / { print $2 }' go.mod)
VERSION=$(cat release)
TAG="ubi9-${ARCH}"
case "${COMPONENT}" in
operator) IMAGE_NAME="${OPERATOR_IMAGE_NAME}" ;;
metrics-exporter) IMAGE_NAME="${METRICS_IMAGE_NAME}" ;;
*) echo "Unknown component: ${COMPONENT}" >&2; exit 1 ;;
esac
IMAGE="${REGISTRY}/${REGISTRY_NAMESPACE}/${IMAGE_NAME}:${TAG}"
docker buildx build \
--load \
--pull \
--platform "${PLATFORM}" \
--target image-prod \
--file "${DOCKERFILE}" \
--tag "${IMAGE}" \
--build-arg "GO_VERSION=${GO_VERSION}" \
--build-arg "GIT_SHA=$(git rev-parse --short HEAD)" \
--build-arg "VERSION=${VERSION}" \
--build-arg "RELEASE=${IMAGE_RELEASE}" \
--build-arg "GOFIPS140=${GOFIPS140}" \
--build-arg "GODEBUG_FIPS140=${GODEBUG_FIPS140}" \
.
echo "IMAGE=${IMAGE}" >> "${GITHUB_ENV}"

- name: Verify UBI runtime
env:
PLATFORM: ${{ matrix.platform }}
BINARY: ${{ matrix.binary }}
run: |
set -euo pipefail
expected_version=$(cat release)
configured_user=$(docker image inspect "${IMAGE}" --format '{{.Config.User}}')
base_label=$(docker image inspect "${IMAGE}" --format '{{index .Config.Labels "altinity.image.base"}}')
test "${configured_user}" = nobody
test "ARG UBI_IMAGE=${base_label}" = "$(grep '^ARG UBI_IMAGE=' dockerfile/ubi9/operator/Dockerfile)"
actual_version=$(docker run --rm --platform "${PLATFORM}" "${IMAGE}" -version)
test "${actual_version}" = "${expected_version}"
docker run --rm --platform "${PLATFORM}" --user 0 --entrypoint /bin/bash "${IMAGE}" -lc \
"set -euo pipefail; grep -q '^Red Hat Enterprise Linux release 9\\.' /etc/redhat-release; test -x /${BINARY}; test -f /licenses/LICENSE; test -f /licenses/THIRD_PARTY_NOTICES.md; test -z \"\$(rpm -V bash curl-minimal)\""
Loading
Loading
0