From bd9bfe76123bf3f35c5125f22a1f6c854fb43c16 Mon Sep 17 00:00:00 2001 From: Francesco Giudici Date: Fri, 11 Aug 2023 15:18:04 +0200 Subject: [PATCH 1/8] Charts: update rancher annotations drop experimental, add few more (affects only installation from Rancher Marketplace) and remove useless ones on crds chart. Signed-off-by: Francesco Giudici --- charts/crds/Chart.yaml | 4 ---- charts/operator/Chart.yaml | 7 ++++++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/charts/crds/Chart.yaml b/charts/crds/Chart.yaml index a00f98baf..bc21371b0 100644 --- a/charts/crds/Chart.yaml +++ b/charts/crds/Chart.yaml @@ -5,10 +5,6 @@ version: 0.0.0 appVersion: 0.0.0 annotations: catalog.cattle.io/certified: rancher - catalog.cattle.io/display-name: Elemental CRDs - catalog.cattle.io/experimental: "true" catalog.cattle.io/namespace: cattle-elemental-system - catalog.cattle.io/os: linux - catalog.cattle.io/provides-gvr: elemental.cattle.io/v1beta1 catalog.cattle.io/release-name: elemental-operator-crds catalog.cattle.io/hidden: true # Hide specific charts. Only use on CRD charts. diff --git a/charts/operator/Chart.yaml b/charts/operator/Chart.yaml index 2d5c77f44..d1d3ceb41 100644 --- a/charts/operator/Chart.yaml +++ b/charts/operator/Chart.yaml @@ -5,10 +5,15 @@ icon: https://raw.githubusercontent.com/rancher/elemental/main/logo/icon-element version: 0.0.0 appVersion: 0.0.0 annotations: + catalog.cattle.io/auto-install: elemental-crd=match catalog.cattle.io/certified: rancher catalog.cattle.io/display-name: Elemental - catalog.cattle.io/experimental: "true" + catalog.cattle.io/kube-version: '>= 1.23.0-0 < 1.28.0-0' catalog.cattle.io/namespace: cattle-elemental-system catalog.cattle.io/os: linux + catalog.cattle.io/permits-os: linux catalog.cattle.io/provides-gvr: elemental.cattle.io/v1beta1 + catalog.cattle.io/rancher-version: '>= 2.7.0-0 < 2.8.0-0' catalog.cattle.io/release-name: elemental-operator + catalog.cattle.io/scope: management + catalog.cattle.io/type: cluster-tool \ No newline at end of file From 55ed01b78a4620e278b465b33453ce6942cbd958 Mon Sep 17 00:00:00 2001 From: Francesco Giudici Date: Fri, 11 Aug 2023 15:32:56 +0200 Subject: [PATCH 2/8] Charts: enforce templating on the channel resource also remove the registry url from the default images reference: resources are already templated getting the registry url from the global.cattle.systemDefaultRegistry variable. Signed-off-by: Francesco Giudici --- charts/operator/templates/channel.yaml | 2 +- charts/operator/values.yaml | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/charts/operator/templates/channel.yaml b/charts/operator/templates/channel.yaml index ba5ea608b..fc65fb83f 100644 --- a/charts/operator/templates/channel.yaml +++ b/charts/operator/templates/channel.yaml @@ -6,6 +6,6 @@ metadata: namespace: fleet-default spec: options: - image: {{ .Values.channel.repository }}:{{ .Values.channel.tag }} + image: {{ template "system_default_registry" . }}{{ .Values.channel.repository }}:{{ .Values.channel.tag }} type: custom {{ end }} diff --git a/charts/operator/values.yaml b/charts/operator/values.yaml index 363306aac..bd0e1c730 100644 --- a/charts/operator/values.yaml +++ b/charts/operator/values.yaml @@ -1,14 +1,18 @@ image: empty: rancher/pause:3.1 - repository: "quay.io/costoolkit/elemental-operator" + repository: "rancher/elemental-operator" tag: latest imagePullPolicy: IfNotPresent seedImage: - repository: "quay.io/costoolkit/seedimage-builder" + repository: "rancher/seedimage-builder" tag: latest imagePullPolicy: IfNotPresent +#channel: +# repository: rancher/elemental-teal-channel +# tag: latest + # number of operator replicas to deploy replicas: 1 From e15e5da9e551e7ac28c24d1eca9f040171298df4 Mon Sep 17 00:00:00 2001 From: Francesco Giudici Date: Fri, 11 Aug 2023 15:36:17 +0200 Subject: [PATCH 3/8] Charts: add README Signed-off-by: Francesco Giudici --- charts/operator/README.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 charts/operator/README.md diff --git a/charts/operator/README.md b/charts/operator/README.md new file mode 100644 index 000000000..bf7b83ea6 --- /dev/null +++ b/charts/operator/README.md @@ -0,0 +1,5 @@ +# Elemental Operator Helm Chart + +This chart bootstraps an elemental-operator deployment on a [Rancher Manager](https://rancher.com/docs/rancher/) cluster using the [Helm](https://helm.sh) package manager. + +Check out the [Elemental Operator Helm Chart documentation](https://elemental.docs.rancher.com/elementaloperatorchart-reference/) in the official [Elemental guide](https://elemental.docs.rancher.com/). From 158d42b288b74288dba405f4ecad5e50c9621de9 Mon Sep 17 00:00:00 2001 From: Francesco Giudici Date: Fri, 11 Aug 2023 16:08:40 +0200 Subject: [PATCH 4/8] Charts: add registry templating for custom airgap Airgap could be managed via Rancher Marketplace once we will have our chart landing there (excluding the teal OS images). We could anyway provide registry templating to allow separate airgap management of the operator, seedimage-builder and channel images. Signed-off-by: Francesco Giudici --- charts/operator/templates/_helpers.tpl | 12 +++++++++++- charts/operator/templates/channel.yaml | 2 +- charts/operator/templates/deployment.yaml | 6 +++--- charts/operator/values.yaml | 3 +++ 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/charts/operator/templates/_helpers.tpl b/charts/operator/templates/_helpers.tpl index f652b5643..2e2c6ea7f 100644 --- a/charts/operator/templates/_helpers.tpl +++ b/charts/operator/templates/_helpers.tpl @@ -4,4 +4,14 @@ {{- else -}} {{- "" -}} {{- end -}} -{{- end -}} \ No newline at end of file +{{- end -}} + +{{- define "registry_url" -}} +{{- if .Values.global.cattle.systemDefaultRegistry -}} +{{ include "system_default_registry" . }} +{{- else if .Values.registry_url -}} +{{- printf "%s/" .Values.registry_url -}} +{{- else -}} +{{- "" -}} +{{- end -}} +{{- end -}} diff --git a/charts/operator/templates/channel.yaml b/charts/operator/templates/channel.yaml index fc65fb83f..92920a65f 100644 --- a/charts/operator/templates/channel.yaml +++ b/charts/operator/templates/channel.yaml @@ -6,6 +6,6 @@ metadata: namespace: fleet-default spec: options: - image: {{ template "system_default_registry" . }}{{ .Values.channel.repository }}:{{ .Values.channel.tag }} + image: {{ template "registry_url" . }}{{ .Values.channel.repository }}:{{ .Values.channel.tag }} type: custom {{ end }} diff --git a/charts/operator/templates/deployment.yaml b/charts/operator/templates/deployment.yaml index 8ca92b2da..576d58d59 100644 --- a/charts/operator/templates/deployment.yaml +++ b/charts/operator/templates/deployment.yaml @@ -24,7 +24,7 @@ spec: {{- end }} name: {{ .Release.Name }} imagePullPolicy: "{{ .Values.image.imagePullPolicy }}" - image: {{ template "system_default_registry" . }}{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }} + image: {{ template "registry_url" . }}{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }} args: - operator {{- if .Values.debug }} @@ -34,9 +34,9 @@ spec: - --namespace - {{ .Release.Namespace }} - --operator-image - - {{ template "system_default_registry" . }}{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }} + - {{ template "registry_url" . }}{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }} - --seedimage-image - - {{ template "system_default_registry" . }}{{ .Values.seedImage.repository }}:{{ .Values.seedImage.tag | default .Chart.AppVersion }} + - {{ template "registry_url" . }}{{ .Values.seedImage.repository }}:{{ .Values.seedImage.tag | default .Chart.AppVersion }} - --seedimage-image-pullpolicy - {{ .Values.seedImage.imagePullPolicy}} serviceAccountName: {{ .Release.Name }} diff --git a/charts/operator/values.yaml b/charts/operator/values.yaml index bd0e1c730..291645f2c 100644 --- a/charts/operator/values.yaml +++ b/charts/operator/values.yaml @@ -26,6 +26,9 @@ global: cattle: systemDefaultRegistry: "" +# used only if systemDefaultRegistry is empty +registry_url: "" + # enable debug output for operator debug: false From 080c86c0cdcbc1e4bc88f70f47e80da530e20d25 Mon Sep 17 00:00:00 2001 From: Francesco Giudici Date: Mon, 21 Aug 2023 17:27:55 +0200 Subject: [PATCH 5/8] Makefile: add the REGISTRY_URL var this is needed to align with the registry/repo templating introduced for airgapped scenario support. While there, also drop the SEEDIMAGE_TAG: just use the common TAG for the seedimage container image. Signed-off-by: Francesco Giudici --- Makefile | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index 083529996..fe8e62490 100644 --- a/Makefile +++ b/Makefile @@ -2,10 +2,17 @@ GIT_COMMIT?=$(shell git rev-parse HEAD) GIT_COMMIT_SHORT?=$(shell git rev-parse --short HEAD) GIT_TAG?=$(shell git describe --abbrev=0 --tags 2>/dev/null || echo "v0.0.0" ) TAG?=${GIT_TAG}-${GIT_COMMIT_SHORT} -REPO?=quay.io/costoolkit/elemental-operator-ci -REPO_REGISTER?=quay.io/costoolkit/elemental-register-ci -TAG_SEEDIMAGE?=${TAG} -REPO_SEEDIMAGE?=quay.io/costoolkit/seedimage-builder-ci +REPO?=elemental-operator-ci +REPO_REGISTER?=elemental-register-ci +REPO_SEEDIMAGE?=seedimage-builder-ci +REGISTRY_URL?=quay.io/coostoolkit +#REGISTRY_URL?=registry.opensuse.org/isv/rancher/elemental/dev/containers +ifneq ($(REGISTRY_URL),) + REGISTRY_HEADER := $(REGISTRY_URL)/ +else + REGISTRY_HEADER := "" +endif + export ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) CHART_VERSION?=$(subst v,,$(GIT_TAG)) CHART?=$(shell find $(ROOT_DIR) -type f -name "elemental-operator-$(CHART_VERSION).tgz" -print) @@ -91,7 +98,7 @@ build-docker-operator: --build-arg "TAG=${GIT_TAG}" \ --build-arg "COMMIT=${GIT_COMMIT}" \ --build-arg "COMMITDATE=${COMMITDATE}" \ - -t ${REPO}:${TAG} . + -t ${REGISTRY_HEADER}${REPO}:${TAG} . .PHONY: build-docker-register build-docker-register: @@ -101,25 +108,25 @@ build-docker-register: --build-arg "TAG=${GIT_TAG}" \ --build-arg "COMMIT=${GIT_COMMIT}" \ --build-arg "COMMITDATE=${COMMITDATE}" \ - -t ${REPO_REGISTER}:${TAG} . + -t ${REGISTRY_HEADER}${REPO_REGISTER}:${TAG} . .PHONY: build-docker-seedimage-builder build-docker-seedimage-builder: DOCKER_BUILDKIT=1 docker build \ -f Dockerfile.seedimage \ - -t ${REPO_SEEDIMAGE}:${TAG} . + -t ${REGISTRY_HEADER}${REPO_SEEDIMAGE}:${TAG} . .PHONY: build-docker-push-operator build-docker-push-operator: build-docker-operator - docker push ${REPO}:${TAG} + docker push ${REGISTRY_HEADER}${REPO}:${TAG} .PHONY: build-docker-push-register build-docker-push-register: build-docker-register - docker push ${REPO_REGISTER}:${TAG} + docker push ${REGISTRY_HEADER}${REPO_REGISTER}:${TAG} .PHONY: build-docker-push-seedimage-builder build-docker-push-seedimage-builder: build-docker-seedimage-builder - docker push ${REPO_SEEDIMAGE}:${TAG} + docker push ${REGISTRY_HEADER}${REPO_SEEDIMAGE}:${TAG} .PHONY: chart chart: @@ -130,8 +137,9 @@ chart: cp -rf $(ROOT_DIR)/charts/operator $(ROOT_DIR)/build/operator yq -i '.image.tag = "${TAG}"' $(ROOT_DIR)/build/operator/values.yaml yq -i '.image.repository = "${REPO}"' $(ROOT_DIR)/build/operator/values.yaml - yq -i '.seedImage.tag = "${TAG_SEEDIMAGE}"' $(ROOT_DIR)/build/operator/values.yaml + yq -i '.seedImage.tag = "${TAG}"' $(ROOT_DIR)/build/operator/values.yaml yq -i '.seedImage.repository = "${REPO_SEEDIMAGE}"' $(ROOT_DIR)/build/operator/values.yaml + yq -i '.registry_url = "${REGISTRY_URL}"' $(ROOT_DIR)/build/operator/values.yaml helm package --version ${CHART_VERSION} --app-version ${GIT_TAG} -d $(ROOT_DIR)/build/ $(ROOT_DIR)/build/operator rm -Rf $(ROOT_DIR)/build/operator @@ -170,20 +178,20 @@ setup-full-cluster: build-docker-operator build-docker-seedimage-builder chart s export BRIDGE_IP="172.18.0.1" && \ export CHART=$(CHART) && \ export CONFIG_PATH=$(E2E_CONF_FILE) && \ - kind load docker-image --name $(CLUSTER_NAME) ${REPO}:${TAG} && \ - kind load docker-image --name $(CLUSTER_NAME) ${REPO_SEEDIMAGE}:${TAG} && \ + kind load docker-image --name $(CLUSTER_NAME) ${REGISTRY_HEADER}${REPO}:${TAG} && \ + kind load docker-image --name $(CLUSTER_NAME) ${REGISTRY_HEADER}${REPO_SEEDIMAGE}:${TAG} && \ cd $(ROOT_DIR)/tests && $(GINKGO) -r -v --label-filter="do-nothing" ./e2e kind-e2e-tests: build-docker-operator chart setup-kind export CONFIG_PATH=$(E2E_CONF_FILE) && \ - kind load docker-image --name $(CLUSTER_NAME) ${REPO}:${TAG} + kind load docker-image --name $(CLUSTER_NAME) ${REGISTRY_HEADER}${REPO}:${TAG} $(MAKE) e2e-tests # This builds the docker image, generates the chart, loads the image into the kind cluster and upgrades the chart to latest # useful to test changes into the operator with a running system, without clearing the operator namespace # thus losing any registration/inventories/os CRDs already created reload-operator: build-docker-operator chart - kind load docker-image --name $(CLUSTER_NAME) ${REPO}:${TAG} + kind load docker-image --name $(CLUSTER_NAME) ${REGISTRY_HEADER}${REPO}:${TAG} helm upgrade -n cattle-elemental-system elemental-operator $(CHART) .PHONY: vendor From 2f2d0fd92e639b2ccbf81cc4379d32d1c0a4f921 Mon Sep 17 00:00:00 2001 From: Francesco Giudici Date: Mon, 21 Aug 2023 18:04:16 +0200 Subject: [PATCH 6/8] tests: fix chart workflow update to the newer repo/registry templating. Signed-off-by: Francesco Giudici --- .github/workflows/chart.yaml | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/.github/workflows/chart.yaml b/.github/workflows/chart.yaml index 2e5cd7944..9e42b9fdc 100644 --- a/.github/workflows/chart.yaml +++ b/.github/workflows/chart.yaml @@ -23,7 +23,7 @@ jobs: - name: Build chart for release if: startsWith(github.ref, 'refs/tags/') run: | - REPO=quay.io/costoolkit/elemental-operator REPO_SEEDIMAGE=quay.io/costoolkit/elemental-seedimage TAG=${GITHUB_REF##*/} make chart + REGISTRY_URL=quay.io/costoolkit REPO=elemental-operator REPO_SEEDIMAGE=elemental-seedimage TAG=${GITHUB_REF##*/} make chart - name: Publish chart to release uses: fnkr/github-action-ghr@v1 if: startsWith(github.ref, 'refs/tags/') @@ -45,21 +45,30 @@ jobs: - name: Test chart values if: ${{ !startsWith(github.ref, 'refs/tags/') }} run: | + REGISTRY_URL=$(helm show values ${{ steps.chart.outputs.chart_name }}|yq .registry_url) REPO=$(helm show values ${{ steps.chart.outputs.chart_name }}|yq .image.repository) - TAG=$(helm show values ${{ steps.chart.outputs.chart_name }}|yq .image.tag) - if [ "$REPO" != "quay.io/costoolkit/elemental-operator-ci" ];then + if [ "$REGISTRY_URL" != "quay.io/coostoolkit" ]; then + echo "registry_url on the built chart is not the expected value" + echo "Expected quay.io/coostoolkit but got $REGISTRY_URL" + fi + if [ "$REPO" != "elemental-operator-ci" ];then echo "REPO on the built chart is not the expected value" - echo "Expected quay.io/costoolkit/elemental-operator but got $REPO" + echo "Expected elemental-operator-ci but got $REPO" exit 1 fi - name: Test release chart values if: startsWith(github.ref, 'refs/tags/') run: | + REGISTRY_URL=$(helm show values ${{ steps.chart.outputs.chart_name }}|yq .registry_url)) REPO=$(helm show values ${{ steps.chart.outputs.chart_name }}|yq .image.repository) TAG=$(helm show values ${{ steps.chart.outputs.chart_name }}|yq .image.tag) - if [ "$REPO" != "quay.io/costoolkit/elemental-operator" ];then + if [ "$REGISTRY_URL" != "quay.io/coostoolkit" ]; then + echo "registry_url on the built chart is not the expected value" + echo "Expected quay.io/coostoolkit but got $REGISTRY_URL" + fi + if [ "$REPO" != "elemental-operator" ];then echo "REPO on the built chart is not the expected value" - echo "Expected quay.io/costoolkit/elemental-operator but got $REPO" + echo "Expected elemental-operator but got $REPO" exit 1 fi if [ "$TAG" != "${GITHUB_REF##*/}" ];then From fecae2a19fca599abb31f829ea0d24a479af81e7 Mon Sep 17 00:00:00 2001 From: Francesco Giudici Date: Tue, 22 Aug 2023 19:10:27 +0200 Subject: [PATCH 7/8] tests: fix e2e workflow Signed-off-by: Francesco Giudici --- .github/workflows/e2e.yaml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index bd1aeaf86..be5dc9a8e 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -10,7 +10,8 @@ concurrency: jobs: push-docker: env: - REPO: ttl.sh/elemental-operator-ci + REGISTRY_URL: ttl.sh + REPO: elemental-operator-ci runs-on: ubuntu-latest outputs: chart_name: ${{ steps.chart.outputs.chart_name }} @@ -31,7 +32,7 @@ jobs: uses: docker/metadata-action@v4.1.1 with: images: | - ${{ env.REPO }} + ${{ env.REGISTRY_URL}}/${{ env.REPO }} tags: | type=sha,format=short,prefix=${{ steps.export_tag.outputs.operator_tag }}- - name: Set up Docker Buildx @@ -52,7 +53,7 @@ jobs: COMMITDATE=${{ steps.export_tag.outputs.commit_date }} COMMIT=${{ github.sha }} - name: Make chart - run: REPO=${{ env.REPO }} make chart + run: REPO=${{ env.REPO }} REGISTRY_URL=${{ env.REGISTRY_URL }} make chart - name: Set chart output id: chart run: | From ea19355095909aa0e8c51cd28c4220702ae6432d Mon Sep 17 00:00:00 2001 From: Francesco Giudici Date: Tue, 22 Aug 2023 19:19:23 +0200 Subject: [PATCH 8/8] Charts: sync OBS charts Signed-off-by: Francesco Giudici --- .obs/chartfile/crds/Chart.yaml | 4 ---- .obs/chartfile/operator/Chart.yaml | 7 ++++++- .obs/chartfile/operator/values.yaml | 9 ++++++--- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/.obs/chartfile/crds/Chart.yaml b/.obs/chartfile/crds/Chart.yaml index d4bdfc443..900e7feb5 100644 --- a/.obs/chartfile/crds/Chart.yaml +++ b/.obs/chartfile/crds/Chart.yaml @@ -9,10 +9,6 @@ version: "%VERSION%" appVersion: "%VERSION%" annotations: catalog.cattle.io/certified: rancher - catalog.cattle.io/display-name: Elemental CRDs - catalog.cattle.io/experimental: "true" catalog.cattle.io/namespace: cattle-elemental-system - catalog.cattle.io/os: linux - catalog.cattle.io/provides-gvr: elemental.cattle.io/v1beta1 catalog.cattle.io/release-name: elemental-operator-crds catalog.cattle.io/hidden: true # Hide specific charts. Only use on CRD charts. diff --git a/.obs/chartfile/operator/Chart.yaml b/.obs/chartfile/operator/Chart.yaml index 7eabe6e50..2ea8532dd 100644 --- a/.obs/chartfile/operator/Chart.yaml +++ b/.obs/chartfile/operator/Chart.yaml @@ -9,10 +9,15 @@ icon: https://raw.githubusercontent.com/rancher/elemental/main/logo/icon-element version: "%VERSION%" appVersion: "%VERSION%" annotations: + catalog.cattle.io/auto-install: elemental-crd=match catalog.cattle.io/certified: rancher catalog.cattle.io/display-name: Elemental - catalog.cattle.io/experimental: "true" + catalog.cattle.io/kube-version: '>= 1.23.0-0 < 1.28.0-0' catalog.cattle.io/namespace: cattle-elemental-system catalog.cattle.io/os: linux + catalog.cattle.io/permits-os: linux catalog.cattle.io/provides-gvr: elemental.cattle.io/v1beta1 + catalog.cattle.io/rancher-version: '>= 2.7.0-0 < 2.8.0-0' catalog.cattle.io/release-name: elemental-operator + catalog.cattle.io/scope: management + catalog.cattle.io/type: cluster-tool diff --git a/.obs/chartfile/operator/values.yaml b/.obs/chartfile/operator/values.yaml index 3f148e7d9..c585b28c4 100644 --- a/.obs/chartfile/operator/values.yaml +++ b/.obs/chartfile/operator/values.yaml @@ -1,16 +1,16 @@ image: empty: rancher/pause:3.1 - repository: "%%IMG_REPO%%/rancher/elemental-operator" + repository: "rancher/elemental-operator" tag: "%VERSION%" imagePullPolicy: IfNotPresent seedImage: - repository: "%%IMG_REPO%%/rancher/seedimage-builder" + repository: "rancher/seedimage-builder" tag: "%VERSION%" imagePullPolicy: IfNotPresent channel: - repository: "%%IMG_REPO%%/rancher/elemental-teal-channel" + repository: "rancher/elemental-teal-channel" tag: "%VERSION%" # number of operator replicas to deploy @@ -26,6 +26,9 @@ global: cattle: systemDefaultRegistry: "" +# used only if systemDefaultRegistry is empty +registry_url: "%%IMG_REPO%%" + # enable debug output for operator debug: false