From 590d83bf2cc2e8e01d467436f1f0b2be76e88f5f Mon Sep 17 00:00:00 2001 From: Niklas Date: Fri, 25 Oct 2024 11:59:29 +0200 Subject: [PATCH 1/7] #33 Use ces-container-registries as imagePullSecrets to support multiple private registries --- CHANGELOG.md | 2 ++ k8s/helm/templates/deployment.yaml | 4 ++++ k8s/helm/templates/garbage-collection-manager-cronjob.yaml | 4 ++++ k8s/helm/templates/k8s-backup-operator-additional-images.yaml | 0 k8s/helm/values.yaml | 3 +++ 5 files changed, 13 insertions(+) delete mode 100644 k8s/helm/templates/k8s-backup-operator-additional-images.yaml diff --git a/CHANGELOG.md b/CHANGELOG.md index ae2a39f..c2c52b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Changed +- [#33] Make imagePullSecrets configurable via helm values and use `ces-container-registries` as default. ## [v1.0.0] - 2024-10-18 ### Changed diff --git a/k8s/helm/templates/deployment.yaml b/k8s/helm/templates/deployment.yaml index 25b94e3..2aeb1c8 100644 --- a/k8s/helm/templates/deployment.yaml +++ b/k8s/helm/templates/deployment.yaml @@ -17,6 +17,10 @@ spec: annotations: kubectl.kubernetes.io/default-container: manager spec: + {{- with .Values.global.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} containers: - args: - --secure-listen-address=0.0.0.0:8443 diff --git a/k8s/helm/templates/garbage-collection-manager-cronjob.yaml b/k8s/helm/templates/garbage-collection-manager-cronjob.yaml index f7556f9..141334b 100644 --- a/k8s/helm/templates/garbage-collection-manager-cronjob.yaml +++ b/k8s/helm/templates/garbage-collection-manager-cronjob.yaml @@ -16,6 +16,10 @@ spec: labels: {{- include "k8s-backup-operator.selectorLabels" . | nindent 12 }} spec: + {{- with .Values.global.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} containers: - args: - gc diff --git a/k8s/helm/templates/k8s-backup-operator-additional-images.yaml b/k8s/helm/templates/k8s-backup-operator-additional-images.yaml deleted file mode 100644 index e69de29..0000000 diff --git a/k8s/helm/values.yaml b/k8s/helm/values.yaml index a2aec47..9df6a42 100644 --- a/k8s/helm/values.yaml +++ b/k8s/helm/values.yaml @@ -1,3 +1,6 @@ +global: + imagePullSecrets: + - name: "ces-container-registries" retention: strategy: keepAll garbageCollectionCron: "0 * * * *" From 8b8bbecd4f1a89d618ef360a1ad6572447a37721 Mon Sep 17 00:00:00 2001 From: Niklas Date: Fri, 25 Oct 2024 13:03:59 +0200 Subject: [PATCH 2/7] #33 Refactor structure of images in values yaml and fix patch templates. --- k8s/helm/component-patch-tpl.yaml | 6 ++++-- k8s/helm/templates/deployment.yaml | 4 ++-- k8s/helm/templates/garbage-collection-manager-cronjob.yaml | 2 +- k8s/helm/values.yaml | 4 +++- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/k8s/helm/component-patch-tpl.yaml b/k8s/helm/component-patch-tpl.yaml index d3b221d..ead4139 100644 --- a/k8s/helm/component-patch-tpl.yaml +++ b/k8s/helm/component-patch-tpl.yaml @@ -7,9 +7,11 @@ patches: values.yaml: kubeRbacProxy: image: - repository: "{{ registryFrom .images.kubeRbacProxy }}/{{ repositoryFrom .images.kubeRbacProxy }}" + registry: "{{ registryFrom .images.kubeRbacProxy }}" + repository: "{{ repositoryFrom .images.kubeRbacProxy }}" tag: "{{ tagFrom .images.kubeRbacProxy }}" manager: image: - repository: "{{ registryFrom .images.backupOperator }}/{{ repositoryFrom .images.backupOperator }}" + registry: "{{ registryFrom .images.backupOperator }}" + repository: "{{ repositoryFrom .images.backupOperator }}" tag: "{{ tagFrom .images.backupOperator }}" diff --git a/k8s/helm/templates/deployment.yaml b/k8s/helm/templates/deployment.yaml index 2aeb1c8..1ee7fe1 100644 --- a/k8s/helm/templates/deployment.yaml +++ b/k8s/helm/templates/deployment.yaml @@ -26,7 +26,7 @@ spec: - --secure-listen-address=0.0.0.0:8443 - --upstream=http://127.0.0.1:8080/ - --v=0 - image: {{ .Values.kubeRbacProxy.image.repository }}:{{ .Values.kubeRbacProxy.image.tag }} + image: "{{ .Values.kubeRbacProxy.image.registry }}/{{ .Values.kubeRbacProxy.image.repository }}:{{ .Values.kubeRbacProxy.image.tag }}" name: kube-rbac-proxy ports: - containerPort: 8443 @@ -52,7 +52,7 @@ spec: valueFrom: fieldRef: fieldPath: metadata.namespace - image: {{ .Values.manager.image.repository }}:{{ .Values.manager.image.tag }} + image: "{{ .Values.manager.image.registry }}/{{ .Values.manager.image.repository }}:{{ .Values.manager.image.tag }}" imagePullPolicy: {{ .Values.manager.imagePullPolicy | default "IfNotPresent" }} livenessProbe: httpGet: diff --git a/k8s/helm/templates/garbage-collection-manager-cronjob.yaml b/k8s/helm/templates/garbage-collection-manager-cronjob.yaml index 141334b..f019b97 100644 --- a/k8s/helm/templates/garbage-collection-manager-cronjob.yaml +++ b/k8s/helm/templates/garbage-collection-manager-cronjob.yaml @@ -33,7 +33,7 @@ spec: valueFrom: fieldRef: fieldPath: metadata.namespace - image: {{ .Values.manager.image.repository }}:{{ .Values.manager.image.tag }} + image: "{{ .Values.manager.image.registry }}/{{ .Values.manager.image.repository }}:{{ .Values.manager.image.tag }}" imagePullPolicy: {{ .Values.manager.imagePullPolicy }} name: garbage-collector resources: diff --git a/k8s/helm/values.yaml b/k8s/helm/values.yaml index 9df6a42..1f65348 100644 --- a/k8s/helm/values.yaml +++ b/k8s/helm/values.yaml @@ -6,7 +6,8 @@ retention: garbageCollectionCron: "0 * * * *" kubeRbacProxy: image: - repository: gcr.io/kubebuilder/kube-rbac-proxy + registry: gcr.io + repository: kubebuilder/kube-rbac-proxy tag: v0.14.1 resources: limits: @@ -20,6 +21,7 @@ manager: stage: production logLevel: info image: + registry: docker.io repository: cloudogu/k8s-backup-operator tag: 1.0.0 imagePullPolicy: IfNotPresent From 5f6857dac523c53153126e5c1d11ecb961e55801 Mon Sep 17 00:00:00 2001 From: Jeremias Weber Date: Fri, 25 Oct 2024 17:02:10 +0200 Subject: [PATCH 3/7] #33 split image registry and repo for development --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 5650c65..ba60921 100644 --- a/Makefile +++ b/Makefile @@ -53,7 +53,8 @@ helm-values-update-image-version: $(BINARY_YQ) helm-values-replace-image-repo: $(BINARY_YQ) @if [[ ${STAGE} == "development" ]]; then \ echo "Setting dev image repo in target values.yaml!" ;\ - $(BINARY_YQ) -i e ".manager.image.repository=\"${IMAGE_DEV}\"" "${K8S_COMPONENT_TARGET_VALUES}" ;\ + $(BINARY_YQ) -i e ".manager.image.registry=\"$(shell echo '${IMAGE_DEV}' | sed 's/\([^\/]*\)\/\(.*\)/\1/')\"" ${K8S_COMPONENT_TARGET_VALUES} ;\ + $(BINARY_YQ) -i e ".manager.image.repository=\"$(shell echo '${IMAGE_DEV}' | sed 's/\([^\/]*\)\/\(.*\)/\2/')\"" ${K8S_COMPONENT_TARGET_VALUES} ;\ fi .PHONY: template-stage From 620cfc05be0890b60a97630806764a76510dfb97 Mon Sep 17 00:00:00 2001 From: Jeremias Weber Date: Mon, 28 Oct 2024 10:16:15 +0100 Subject: [PATCH 4/7] #33 Update makefiles and build lib --- Jenkinsfile | 2 +- Makefile | 2 +- build/make/build.mk | 2 +- build/make/k8s-dogu.tpl | 2 +- build/make/static-analysis.mk | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index ec74f33..0e5852b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,6 +1,6 @@ #!groovy -@Library('github.com/cloudogu/ces-build-lib@2.3.0') +@Library('github.com/cloudogu/ces-build-lib@3.0.0') import com.cloudogu.ces.cesbuildlib.* // Creating necessary git objects diff --git a/Makefile b/Makefile index ba60921..32ea662 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ VERSION=1.0.0 IMAGE=cloudogu/${ARTIFACT_ID}:${VERSION} GOTAG?=1.23 LINT_VERSION=v1.61.0 -MAKEFILES_VERSION=9.2.1 +MAKEFILES_VERSION=9.3.2 STAGE?=production ADDITIONAL_CLEAN=dist-clean diff --git a/build/make/build.mk b/build/make/build.mk index 857c11d..d3581de 100644 --- a/build/make/build.mk +++ b/build/make/build.mk @@ -3,7 +3,7 @@ ADDITIONAL_LDFLAGS?=-extldflags -static LDFLAGS?=-ldflags "$(ADDITIONAL_LDFLAGS) -X main.Version=$(VERSION) -X main.CommitID=$(COMMIT_ID)" GOIMAGE?=golang -GOTAG?=1.22 +GOTAG?=1.23 GOOS?=linux GOARCH?=amd64 PRE_COMPILE?= diff --git a/build/make/k8s-dogu.tpl b/build/make/k8s-dogu.tpl index 296da65..91e2bb2 100644 --- a/build/make/k8s-dogu.tpl +++ b/build/make/k8s-dogu.tpl @@ -1,4 +1,4 @@ -apiVersion: k8s.cloudogu.com/v1 +apiVersion: k8s.cloudogu.com/v2 kind: Dogu metadata: name: NAME diff --git a/build/make/static-analysis.mk b/build/make/static-analysis.mk index 0ed0de3..00c406f 100644 --- a/build/make/static-analysis.mk +++ b/build/make/static-analysis.mk @@ -2,12 +2,12 @@ STATIC_ANALYSIS_DIR=$(TARGET_DIR)/static-analysis GOIMAGE?=golang -GOTAG?=1.22 +GOTAG?=1.23 CUSTOM_GO_MOUNT?=-v /tmp:/tmp REVIEW_DOG=$(TMP_DIR)/bin/reviewdog LINT=$(TMP_DIR)/bin/golangci-lint -LINT_VERSION?=v1.58.2 +LINT_VERSION?=v1.61.0 # ignore tests and mocks LINTFLAGS=--tests=false --exclude-files="^.*_mock.go$$" --exclude-files="^.*/mock.*.go$$" --timeout 10m --issues-exit-code 0 ADDITIONAL_LINTER=-E bodyclose -E containedctx -E contextcheck -E decorder -E dupl -E errname -E forcetypeassert -E funlen -E unparam From 29cfd30f72f66e16f0b87474f574a37eda98addf Mon Sep 17 00:00:00 2001 From: Jeremias Weber Date: Mon, 28 Oct 2024 11:10:58 +0100 Subject: [PATCH 5/7] #33 Fix image pull secrets in garbage collector --- k8s/helm/templates/garbage-collection-manager-cronjob.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/k8s/helm/templates/garbage-collection-manager-cronjob.yaml b/k8s/helm/templates/garbage-collection-manager-cronjob.yaml index f019b97..3123307 100644 --- a/k8s/helm/templates/garbage-collection-manager-cronjob.yaml +++ b/k8s/helm/templates/garbage-collection-manager-cronjob.yaml @@ -18,7 +18,7 @@ spec: spec: {{- with .Values.global.imagePullSecrets }} imagePullSecrets: - {{- toYaml . | nindent 8 }} + {{- toYaml . | nindent 10 }} {{- end }} containers: - args: From c85f40222d4d1ce800fe6b1a23edccaefd77c964 Mon Sep 17 00:00:00 2001 From: Jeremias Weber Date: Mon, 28 Oct 2024 14:50:37 +0100 Subject: [PATCH 6/7] Bump version --- Dockerfile | 2 +- Makefile | 2 +- k8s/helm/component-patch-tpl.yaml | 2 +- k8s/helm/values.yaml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 9b9be92..c259fad 100644 --- a/Dockerfile +++ b/Dockerfile @@ -34,7 +34,7 @@ RUN make compile-generic FROM gcr.io/distroless/static:nonroot LABEL maintainer="hello@cloudogu.com" \ NAME="k8s-backup-operator" \ - VERSION="1.0.0" + VERSION="1.1.0" WORKDIR / COPY --from=builder /workspace/target/k8s-backup-operator . diff --git a/Makefile b/Makefile index 32ea662..324a707 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ # Set these to the desired values ARTIFACT_ID=k8s-backup-operator -VERSION=1.0.0 +VERSION=1.1.0 IMAGE=cloudogu/${ARTIFACT_ID}:${VERSION} GOTAG?=1.23 LINT_VERSION=v1.61.0 diff --git a/k8s/helm/component-patch-tpl.yaml b/k8s/helm/component-patch-tpl.yaml index ead4139..ee678a5 100644 --- a/k8s/helm/component-patch-tpl.yaml +++ b/k8s/helm/component-patch-tpl.yaml @@ -1,7 +1,7 @@ apiVersion: v1 values: images: - backupOperator: cloudogu/k8s-backup-operator:1.0.0 + backupOperator: cloudogu/k8s-backup-operator:1.1.0 kubeRbacProxy: gcr.io/kubebuilder/kube-rbac-proxy:v0.14.1 patches: values.yaml: diff --git a/k8s/helm/values.yaml b/k8s/helm/values.yaml index 1f65348..9a48eac 100644 --- a/k8s/helm/values.yaml +++ b/k8s/helm/values.yaml @@ -23,7 +23,7 @@ manager: image: registry: docker.io repository: cloudogu/k8s-backup-operator - tag: 1.0.0 + tag: 1.1.0 imagePullPolicy: IfNotPresent resources: limits: From efdfa9ab04d893c6ad5eb4ee6143c3703e720275 Mon Sep 17 00:00:00 2001 From: Jeremias Weber Date: Mon, 28 Oct 2024 14:50:42 +0100 Subject: [PATCH 7/7] Update changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c2c52b9..7a1a821 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] + +## [v1.1.0] - 2024-10-28 ### Changed - [#33] Make imagePullSecrets configurable via helm values and use `ces-container-registries` as default.