From 6a841e9e84c277c1181a57ac644690033e51d5f0 Mon Sep 17 00:00:00 2001 From: sg Date: Wed, 14 Aug 2024 12:22:36 +0100 Subject: [PATCH 1/2] allow overriding image names --- .../deduplication-db-migrations/chart/Chart.yaml | 4 ++-- .../chart/templates/_helpers.tpl | 14 ++++++++++++++ .../chart/templates/migrations-job.yaml | 2 +- .../deduplication-db-migrations/chart/values.yaml | 5 ++++- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/deploy/deduplication-db-migrations/chart/Chart.yaml b/deploy/deduplication-db-migrations/chart/Chart.yaml index 0bfb82ffc..d1fdcc550 100644 --- a/deploy/deduplication-db-migrations/chart/Chart.yaml +++ b/deploy/deduplication-db-migrations/chart/Chart.yaml @@ -4,5 +4,5 @@ description: | A Helm chart for Kubernetes containing the dracon migrations needed for the deduplication component to run. Please check the documentation for more information here: https://github.com/ocurity/dracon/blob/main/docs/migrations.md type: application -version: 0.23.0 -appVersion: v0.23.0 +version: 0.34.0 +appVersion: v0.34.0 diff --git a/deploy/deduplication-db-migrations/chart/templates/_helpers.tpl b/deploy/deduplication-db-migrations/chart/templates/_helpers.tpl index 4b8ff75b2..22487f907 100644 --- a/deploy/deduplication-db-migrations/chart/templates/_helpers.tpl +++ b/deploy/deduplication-db-migrations/chart/templates/_helpers.tpl @@ -60,3 +60,17 @@ Create the name of the service account to use {{- default "default" .Values.serviceAccount.name }} {{- end }} {{- end }} + + +{{/* +Create the name of the service account to use +*/}} + +{{- define "deduplication_db_migrations.imageName" -}} +{{- if .Values.deduplication_db_migrations.image.repository }} +{{- printf "%s:%s" .Values.deduplication_db_migrations.image.repository (.Values.image.tag | default .Chart.AppVersion )}} +{{- else }} +{{- printf "%s/%s:%s" (.Values.image.registry | default "ghcr.io/ocurity/dracon") "draconctl" (.Values.image.tag | default .Chart.AppVersion )}} +{{- end }} +{{- end }} + diff --git a/deploy/deduplication-db-migrations/chart/templates/migrations-job.yaml b/deploy/deduplication-db-migrations/chart/templates/migrations-job.yaml index 311d26513..57947c9b7 100644 --- a/deploy/deduplication-db-migrations/chart/templates/migrations-job.yaml +++ b/deploy/deduplication-db-migrations/chart/templates/migrations-job.yaml @@ -21,7 +21,7 @@ spec: containers: - name: deduplication-db-migrations # image.tag is set because you can't do helm upgrade and set the chart AppVersion manually - image: "{{ default "ghcr.io/ocurity/dracon" .Values.image.registry }}/draconctl:{{ default .Chart.AppVersion .Values.image.tag }}" + image: "{{ include "deduplication_db_migrations.imageName" . }}" imagePullPolicy: {{ .Values.image.pullPolicy }} env: - name: DRACONCTL_MIGRATIONS_PATH diff --git a/deploy/deduplication-db-migrations/chart/values.yaml b/deploy/deduplication-db-migrations/chart/values.yaml index c594c5262..ecb445a1f 100644 --- a/deploy/deduplication-db-migrations/chart/values.yaml +++ b/deploy/deduplication-db-migrations/chart/values.yaml @@ -3,10 +3,13 @@ # image to use for applying the migrations image: - # registry to use for all + # registry to use for all registry: "" pullPolicy: Always + # repository is an alternative to image, it overrides both the registry and the name of the image + repository: "" + serviceAccount: create: false From e28ca36634ed9edeeaab69425bb8c3df2c434851 Mon Sep 17 00:00:00 2001 From: sg Date: Wed, 14 Aug 2024 12:22:53 +0100 Subject: [PATCH 2/2] make the migrations role optional --- .../chart/templates/migrations-role.yaml | 2 ++ .../chart/templates/migrations-rolebinding.yaml | 2 ++ deploy/deduplication-db-migrations/chart/values.yaml | 1 + 3 files changed, 5 insertions(+) diff --git a/deploy/deduplication-db-migrations/chart/templates/migrations-role.yaml b/deploy/deduplication-db-migrations/chart/templates/migrations-role.yaml index 817f5f2cc..52e09d28d 100644 --- a/deploy/deduplication-db-migrations/chart/templates/migrations-role.yaml +++ b/deploy/deduplication-db-migrations/chart/templates/migrations-role.yaml @@ -1,3 +1,4 @@ +{{ if .Values.create_role }} apiVersion: rbac.authorization.k8s.io/v1 kind: Role metadata: @@ -14,3 +15,4 @@ rules: - create - delete - update +{{ end }} diff --git a/deploy/deduplication-db-migrations/chart/templates/migrations-rolebinding.yaml b/deploy/deduplication-db-migrations/chart/templates/migrations-rolebinding.yaml index 0fd6bf796..6001393c6 100644 --- a/deploy/deduplication-db-migrations/chart/templates/migrations-rolebinding.yaml +++ b/deploy/deduplication-db-migrations/chart/templates/migrations-rolebinding.yaml @@ -1,3 +1,4 @@ +{{ if .Values.create_role }} apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: @@ -9,3 +10,4 @@ roleRef: subjects: - kind: ServiceAccount name: {{ include "deduplication_db_migrations.fullname" . }} +{{ end }} diff --git a/deploy/deduplication-db-migrations/chart/values.yaml b/deploy/deduplication-db-migrations/chart/values.yaml index ecb445a1f..9a4fe269d 100644 --- a/deploy/deduplication-db-migrations/chart/values.yaml +++ b/deploy/deduplication-db-migrations/chart/values.yaml @@ -13,5 +13,6 @@ image: serviceAccount: create: false +create_role: true enabled: true resources: {}