From f6f10aa9224ecd5035b2e66ac951906c6577663d Mon Sep 17 00:00:00 2001 From: David Schmidt Date: Tue, 27 Aug 2024 10:06:36 +0200 Subject: [PATCH] feat(image registry): Use helm templates --- charts/datahub/Chart.yaml | 2 +- .../templates/deployment.yaml | 3 +- .../templates/deployment.yaml | 3 +- .../datahub-gms/templates/deployment.yaml | 3 +- .../templates/cron.yaml | 3 +- .../templates/deployment.yaml | 3 +- .../templates/deployment.yaml | 3 +- charts/datahub/templates/_helpers.tpl | 42 ++++++++++++++++++- .../templates/datahub-upgrade/_upgrade.tpl | 16 +++++++ .../datahub-cleanup-job-template.yml | 3 +- .../datahub-nocode-migration-job.yml | 3 +- .../datahub-restore-indices-job-template.yml | 3 +- .../datahub-system-update-job.yml | 6 +-- .../templates/elasticsearch-setup-job.yml | 3 +- charts/datahub/templates/kafka-setup-job.yml | 3 +- charts/datahub/templates/mysql-setup-job.yml | 3 +- .../templates/postgresql-setup-job.yml | 3 +- 17 files changed, 73 insertions(+), 32 deletions(-) diff --git a/charts/datahub/Chart.yaml b/charts/datahub/Chart.yaml index 1a47b48e5..1b6e45940 100644 --- a/charts/datahub/Chart.yaml +++ b/charts/datahub/Chart.yaml @@ -4,7 +4,7 @@ description: A Helm chart for DataHub type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. -version: 0.4.22 +version: 0.4.23 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. appVersion: 0.14.0.2 diff --git a/charts/datahub/subcharts/acryl-datahub-actions/templates/deployment.yaml b/charts/datahub/subcharts/acryl-datahub-actions/templates/deployment.yaml index 9194244a7..fbef0919f 100644 --- a/charts/datahub/subcharts/acryl-datahub-actions/templates/deployment.yaml +++ b/charts/datahub/subcharts/acryl-datahub-actions/templates/deployment.yaml @@ -64,8 +64,7 @@ spec: - name: {{ .Chart.Name }} securityContext: {{- toYaml .Values.securityContext | nindent 12 }} - {{- $registry := .Values.global.imageRegistry | default .Values.image.registry -}} - image: "{{ $registry }}/{{ .Values.image.repository }}:{{ .Values.image.tag }}" + image: {{ include "datahub.image" . }} imagePullPolicy: {{ .Values.image.pullPolicy }} ports: - name: http diff --git a/charts/datahub/subcharts/datahub-frontend/templates/deployment.yaml b/charts/datahub/subcharts/datahub-frontend/templates/deployment.yaml index 6b2dfdf8e..d2a61d2b2 100644 --- a/charts/datahub/subcharts/datahub-frontend/templates/deployment.yaml +++ b/charts/datahub/subcharts/datahub-frontend/templates/deployment.yaml @@ -66,8 +66,7 @@ spec: - name: {{ .Chart.Name }} securityContext: {{- toYaml .Values.securityContext | nindent 12 }} - {{- $registry := .Values.global.imageRegistry | default .Values.image.registry -}} - image: "{{ $registry }}/{{ .Values.image.repository }}:{{ required "Global or specific tag is required" (.Values.image.tag | default .Values.global.datahub.version) }}" + image: {{ include "datahub.image" . }} imagePullPolicy: {{ .Values.image.pullPolicy }} {{- if .Values.image.command }} command: {{ .Values.image.command | toRawJson }} diff --git a/charts/datahub/subcharts/datahub-gms/templates/deployment.yaml b/charts/datahub/subcharts/datahub-gms/templates/deployment.yaml index c2d7110a7..5882a0846 100644 --- a/charts/datahub/subcharts/datahub-gms/templates/deployment.yaml +++ b/charts/datahub/subcharts/datahub-gms/templates/deployment.yaml @@ -70,8 +70,7 @@ spec: - name: {{ .Chart.Name }} securityContext: {{- toYaml .Values.securityContext | nindent 12 }} - {{- $registry := .Values.global.imageRegistry | default .Values.image.registry -}} - image: "{{ $registry }}/{{ .Values.image.repository }}:{{ required "Global or specific tag is required" (.Values.image.tag | default .Values.global.datahub.version) }}" + image: {{ include "datahub.image" . }} imagePullPolicy: {{ .Values.image.pullPolicy }} {{- if .Values.image.command }} command: {{ .Values.image.command | toRawJson }} diff --git a/charts/datahub/subcharts/datahub-ingestion-cron/templates/cron.yaml b/charts/datahub/subcharts/datahub-ingestion-cron/templates/cron.yaml index 497d4d0ca..d59ee07d5 100644 --- a/charts/datahub/subcharts/datahub-ingestion-cron/templates/cron.yaml +++ b/charts/datahub/subcharts/datahub-ingestion-cron/templates/cron.yaml @@ -42,8 +42,7 @@ spec: {{- toYaml $.Values.podSecurityContext | nindent 12 }} containers: - name: {{ $jobName }}-crawler - {{- $registry := .Values.global.imageRegistry | default .Values.image.registry -}} - image: "{{ $registry }}/{{ $.Values.image.repository }}:{{ required "Global or specific tag is required" ($.Values.image.tag | default $.Values.global.datahub.version) }}" + image: {{ include "datahub.image" . }} imagePullPolicy: {{ $.Values.image.pullPolicy }} volumeMounts: - name: recipe diff --git a/charts/datahub/subcharts/datahub-mae-consumer/templates/deployment.yaml b/charts/datahub/subcharts/datahub-mae-consumer/templates/deployment.yaml index eaa9211de..91d7c38b7 100644 --- a/charts/datahub/subcharts/datahub-mae-consumer/templates/deployment.yaml +++ b/charts/datahub/subcharts/datahub-mae-consumer/templates/deployment.yaml @@ -61,8 +61,7 @@ spec: - name: {{ .Chart.Name }} securityContext: {{- toYaml .Values.securityContext | nindent 12 }} - {{- $registry := .Values.global.imageRegistry | default .Values.image.registry -}} - image: "{{ $registry }}/{{ .Values.image.repository }}:{{ required "Global or specific tag is required" (.Values.image.tag | default .Values.global.datahub.version) }}" + image: {{ include "datahub.image" . }} imagePullPolicy: {{ .Values.image.pullPolicy }} {{- if .Values.image.command }} command: {{ .Values.image.command | toRawJson }} diff --git a/charts/datahub/subcharts/datahub-mce-consumer/templates/deployment.yaml b/charts/datahub/subcharts/datahub-mce-consumer/templates/deployment.yaml index 89f014fdc..6ecf4115a 100644 --- a/charts/datahub/subcharts/datahub-mce-consumer/templates/deployment.yaml +++ b/charts/datahub/subcharts/datahub-mce-consumer/templates/deployment.yaml @@ -65,8 +65,7 @@ spec: - name: {{ .Chart.Name }} securityContext: {{- toYaml .Values.securityContext | nindent 12 }} - {{- $registry := .Values.global.imageRegistry | default .Values.image.registry -}} - image: "{{ $registry }}/{{ .Values.image.repository }}:{{ required "Global or specific tag is required" (.Values.image.tag | default .Values.global.datahub.version) }}" + image: {{ include "datahub.image" . }} imagePullPolicy: {{ .Values.image.pullPolicy }} {{- if .Values.image.command }} command: {{ .Values.image.command | toRawJson }} diff --git a/charts/datahub/templates/_helpers.tpl b/charts/datahub/templates/_helpers.tpl index e8be3a430..04e535d24 100644 --- a/charts/datahub/templates/_helpers.tpl +++ b/charts/datahub/templates/_helpers.tpl @@ -71,4 +71,44 @@ Return the appropriate apiVersion for cronjob. {{- else -}} {{- print "batch/v1beta1" -}} {{- end -}} -{{- end -}} \ No newline at end of file +{{- end -}} + +{{/* +Create general image registry, name and tag +*/}} +{{- define "datahub.image" -}} +{{- $registry := .Values.global.imageRegistry | default .Values.image.registry -}} +{{ $registry }}/{{ .Values.image.repository }}:{{ required "Global or specific tag is required" (.Values.image.tag | default .Values.global.datahub.version) -}} +{{- end -}} + +{{/* +Create image registry, name and tag for elasticsearch setup job +*/}} +{{- define "elasticsearchSetupJob.image" -}} +{{- $registry := .Values.global.imageRegistry | default .Values.elasticsearchSetupJob.image.registry -}} +{{ $registry }}/{{ .Values.elasticsearchSetupJob.image.repository }}:{{ required "Global or specific tag is required" (.Values.elasticsearchSetupJob.image.tag | default .Values.global.datahub.version) -}} +{{- end -}} + +{{/* +Create image registry, name and tag for kafka setup job +*/}} +{{- define "kafkaSetupJob.image" -}} +{{- $registry := .Values.global.imageRegistry | default .Values.kafkaSetupJob.image.registry -}} +{{ $registry }}/{{ .Values.kafkaSetupJob.image.repository }}:{{ required "Global or specific tag is required" (.Values.kafkaSetupJob.image.tag | default .Values.global.datahub.version) -}} +{{- end -}} + +{{/* +Create image registry, name and tag for mysql setup job +*/}} +{{- define "mysqlSetupJob.image" -}} +{{- $registry := .Values.global.imageRegistry | default .Values.mysqlSetupJob.image.registry -}} +{{ $registry }}/{{ .Values.mysqlSetupJob.image.repository }}:{{ required "Global or specific tag is required" (.Values.mysqlSetupJob.image.tag | default .Values.global.datahub.version) -}} +{{- end -}} + +{{/* +Create image registry, name and tag for postgres setup job +*/}} +{{- define "postgresqlSetupJob.image" -}} +{{- $registry := .Values.global.imageRegistry | default .Values.postgresqlSetupJob.image.registry -}} +{{ $registry }}/{{ .Values.postgresqlSetupJob.image.repository }}:{{ required "Global or specific tag is required" (.Values.postgresqlSetupJob.image.tag | default .Values.global.datahub.version) -}} +{{- end -}} diff --git a/charts/datahub/templates/datahub-upgrade/_upgrade.tpl b/charts/datahub/templates/datahub-upgrade/_upgrade.tpl index a4921c78f..0d1056432 100644 --- a/charts/datahub/templates/datahub-upgrade/_upgrade.tpl +++ b/charts/datahub/templates/datahub-upgrade/_upgrade.tpl @@ -144,3 +144,19 @@ Return the env variables for upgrade jobs value: {{ .datahub_upgrade_history_topic_name }} {{- end }} {{- end -}} + +{{/* +Create image registry, name and tag for datahub upgrade jobs +*/}} +{{- define "datahubUpgrade.image" -}} +{{- $registry := .Values.global.imageRegistry | default .Values.datahubUpgrade.image.registry -}} +{{ $registry }}/{{ .Values.datahubUpgrade.image.repository }}:{{ required "Global or specific tag is required" (.Values.datahubUpgrade.image.tag | default .Values.global.datahub.version) -}} +{{- end -}} + +{{/* +Create image registry, name and tag for datahub system update job +*/}} +{{- define "datahubSystemUpdate.image" -}} +{{- $registry := .Values.global.imageRegistry | default .Values.datahubSystemUpdate.image.registry -}} +{{ $registry }}/{{ .Values.datahubSystemUpdate.image.repository }}:{{ required "Global or specific tag is required" (.Values.datahubSystemUpdate.image.tag | default .Values.global.datahub.version) -}} +{{- end -}} diff --git a/charts/datahub/templates/datahub-upgrade/datahub-cleanup-job-template.yml b/charts/datahub/templates/datahub-upgrade/datahub-cleanup-job-template.yml index 95e369c3c..3abae541d 100644 --- a/charts/datahub/templates/datahub-upgrade/datahub-cleanup-job-template.yml +++ b/charts/datahub/templates/datahub-upgrade/datahub-cleanup-job-template.yml @@ -54,8 +54,7 @@ spec: {{- end }} containers: - name: datahub-upgrade-job - {{- $registry := .Values.global.imageRegistry | default .Values.datahubUpgrade.image.registry -}} - image: "{{ $registry }}/{{ .Values.datahubUpgrade.image.repository }}:{{ required "Global or specific tag is required" (.Values.datahubUpgrade.image.tag | default .Values.global.datahub.version) }}" + image: {{ include "datahubUpgrade.image" . }} imagePullPolicy: {{ .Values.datahubUpgrade.image.pullPolicy | default "IfNotPresent" }} {{- if .Values.datahubUpgrade.cleanupJob.image.command }} command: {{ .Values.datahubUpgrade.cleanupJob.image.command | toRawJson }} diff --git a/charts/datahub/templates/datahub-upgrade/datahub-nocode-migration-job.yml b/charts/datahub/templates/datahub-upgrade/datahub-nocode-migration-job.yml index 4e12f53b3..f3968976b 100644 --- a/charts/datahub/templates/datahub-upgrade/datahub-nocode-migration-job.yml +++ b/charts/datahub/templates/datahub-upgrade/datahub-nocode-migration-job.yml @@ -55,8 +55,7 @@ spec: {{- end }} containers: - name: datahub-upgrade-job - {{- $registry := .Values.global.imageRegistry | default .Values.datahubUpgrade.image.registry -}} - image: "{{ $registry }}/{{ .Values.datahubUpgrade.image.repository }}:{{ required "Global or specific tag is required" ($.Values.datahubUpgrade.image.tag | default .Values.global.datahub.version) }}" + image: {{ include "datahubUpgrade.image" . }} imagePullPolicy: {{ .Values.datahubUpgrade.image.pullPolicy | default "IfNotPresent" }} {{- if .Values.datahubUpgrade.noCodeDataMigration.image.command }} command: {{ .Values.datahubUpgrade.noCodeDataMigration.image.command | toRawJson }} diff --git a/charts/datahub/templates/datahub-upgrade/datahub-restore-indices-job-template.yml b/charts/datahub/templates/datahub-upgrade/datahub-restore-indices-job-template.yml index 23eb73960..0350a25b0 100644 --- a/charts/datahub/templates/datahub-upgrade/datahub-restore-indices-job-template.yml +++ b/charts/datahub/templates/datahub-upgrade/datahub-restore-indices-job-template.yml @@ -60,8 +60,7 @@ spec: {{- end }} containers: - name: datahub-upgrade-job - {{- $registry := .Values.global.imageRegistry | default .Values.datahubUpgrade.image.registry -}} - image: "{{ $registry }}/{{ .Values.datahubUpgrade.image.repository }}:{{ required "Global or specific tag is required" (.Values.datahubUpgrade.image.tag | default .Values.global.datahub.version) }}" + image: {{ include "datahubUpgrade.image" . }} imagePullPolicy: {{ .Values.datahubUpgrade.image.pullPolicy | default "IfNotPresent" }} {{- if .Values.datahubUpgrade.restoreIndices.image.command }} command: {{ .Values.datahubUpgrade.restoreIndices.image.command | toRawJson }} diff --git a/charts/datahub/templates/datahub-upgrade/datahub-system-update-job.yml b/charts/datahub/templates/datahub-upgrade/datahub-system-update-job.yml index 322abdcb4..a44416efa 100644 --- a/charts/datahub/templates/datahub-upgrade/datahub-system-update-job.yml +++ b/charts/datahub/templates/datahub-upgrade/datahub-system-update-job.yml @@ -55,8 +55,7 @@ spec: {{- end }} containers: - name: datahub-system-update-job - {{- $registry := .Values.global.imageRegistry | default .Values.datahubSystemUpdate.image.registry -}} - image: "{{ $registry }}/{{ .Values.datahubSystemUpdate.image.repository }}:{{ required "Global or specific tag is required" (.Values.datahubSystemUpdate.image.tag | default .Values.global.datahub.version) }}" + image: {{ include "datahubSystemUpdate.image" . }} imagePullPolicy: {{ .Values.datahubSystemUpdate.image.pullPolicy | default "IfNotPresent" }} {{- if .Values.datahubSystemUpdate.image.command }} command: {{ .Values.datahubSystemUpdate.image.command | toRawJson }} @@ -223,8 +222,7 @@ spec: {{- end }} containers: - name: datahub-system-update-job - {{- $registry := .Values.global.imageRegistry | default .Values.datahubSystemUpdate.image.registry -}} - image: "{{ $registry }}/{{ .Values.datahubSystemUpdate.image.repository }}:{{ required "Global or specific tag is required" (.Values.datahubSystemUpdate.image.tag | default .Values.global.datahub.version) }}" + image: {{ include "datahubSystemUpdate.image" . }} imagePullPolicy: {{ .Values.datahubSystemUpdate.image.pullPolicy | default "IfNotPresent" }} {{- if .Values.datahubSystemUpdate.image.command }} command: {{ .Values.datahubSystemUpdate.image.command | toRawJson }} diff --git a/charts/datahub/templates/elasticsearch-setup-job.yml b/charts/datahub/templates/elasticsearch-setup-job.yml index e8dfba457..ccc8d5b0d 100644 --- a/charts/datahub/templates/elasticsearch-setup-job.yml +++ b/charts/datahub/templates/elasticsearch-setup-job.yml @@ -49,8 +49,7 @@ spec: {{- end }} containers: - name: elasticsearch-setup-job - {{- $registry := .Values.global.imageRegistry | default .Values.elasticsearchSetupJob.image.registry -}} - image: "{{ $registry }}/{{ .Values.elasticsearchSetupJob.image.repository }}:{{ required "Global or specific tag is required" ( .Values.elasticsearchSetupJob.image.tag | default .Values.global.datahub.version) }}" + image: {{ include "elasticsearchSetupJob.image" . }} imagePullPolicy: {{ .Values.elasticsearchSetupJob.image.pullPolicy | default "IfNotPresent" }} {{- if .Values.elasticsearchSetupJob.image.command }} command: {{ .Values.elasticsearchSetupJob.image.command | toRawJson }} diff --git a/charts/datahub/templates/kafka-setup-job.yml b/charts/datahub/templates/kafka-setup-job.yml index a168aaf98..11cc19575 100644 --- a/charts/datahub/templates/kafka-setup-job.yml +++ b/charts/datahub/templates/kafka-setup-job.yml @@ -55,8 +55,7 @@ spec: {{- end }} containers: - name: kafka-setup-job - {{- $registry := .Values.global.imageRegistry | default .Values.kafkaSetupJob.image.registry -}} - image: "{{ $registry }}/{{ .Values.kafkaSetupJob.image.repository }}:{{ required "Global or specific tag is required" ( .Values.kafkaSetupJob.image.tag | default .Values.global.datahub.version) }}" + image: {{ include "kafkaSetupJob.image" . }} imagePullPolicy: {{ .Values.kafkaSetupJob.image.pullPolicy | default "IfNotPresent" }} {{- if .Values.kafkaSetupJob.image.command }} command: {{ .Values.kafkaSetupJob.image.command | toRawJson }} diff --git a/charts/datahub/templates/mysql-setup-job.yml b/charts/datahub/templates/mysql-setup-job.yml index d31c0db2c..04cf4cc6f 100644 --- a/charts/datahub/templates/mysql-setup-job.yml +++ b/charts/datahub/templates/mysql-setup-job.yml @@ -49,8 +49,7 @@ spec: {{- end }} containers: - name: mysql-setup-job - {{- $registry := .Values.global.imageRegistry | default .Values.mysqlSetupJob.image.registry -}} - image: "{{ $registry }}/{{ .Values.mysqlSetupJob.image.repository }}:{{ required "Global or specific tag is required" ( .Values.mysqlSetupJob.image.tag | default .Values.global.datahub.version) }}" + image: {{ include "mysqlSetupJob.image" . }} imagePullPolicy: {{ .Values.mysqlSetupJob.image.pullPolicy | default "IfNotPresent" }} {{- if .Values.mysqlSetupJob.image.command }} command: {{ .Values.mysqlSetupJob.image.command | toRawJson }} diff --git a/charts/datahub/templates/postgresql-setup-job.yml b/charts/datahub/templates/postgresql-setup-job.yml index 55db3a79f..8ffa2022c 100644 --- a/charts/datahub/templates/postgresql-setup-job.yml +++ b/charts/datahub/templates/postgresql-setup-job.yml @@ -49,8 +49,7 @@ spec: {{- end }} containers: - name: postgresql-setup-job - {{- $registry := .Values.global.imageRegistry | default .Values.postgresqlSetupJob.image.registry -}} - image: "{{ $registry }}/{{ .Values.postgresqlSetupJob.image.repository }}:{{ required "Global or specific tag is required" (.Values.postgresqlSetupJob.image.tag | default .Values.global.datahub.version) }}" + image: {{ include "postgresqlSetupJob.image" . }} imagePullPolicy: {{ .Values.postgresqlSetupJob.image.pullPolicy | default "Always" }} {{- if .Values.postgresqlSetupJob.image.command }} command: {{ .Values.postgresqlSetupJob.image.command | toRawJson }}