From 64c0a1fdbb15fe2a370c828d9891a549784d16dd Mon Sep 17 00:00:00 2001 From: Sarhad Date: Tue, 15 Oct 2024 11:35:38 +0400 Subject: [PATCH 1/4] feat(DMVP-5177): Add job service account support --- charts/base/templates/job.yml | 3 ++- charts/base/templates/serviceaccount.yaml | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/charts/base/templates/job.yml b/charts/base/templates/job.yml index 2982a2f..f8ee92d 100644 --- a/charts/base/templates/job.yml +++ b/charts/base/templates/job.yml @@ -18,7 +18,7 @@ spec: template: metadata: annotations: - configmap: "{{ .Values.config | toYaml | sha256sum | trunc 8 }}" + configmap: "{{ .Values.config | toYaml | sha256sum | trunc 8 }}" {{- with .Values.podAnnotations }} {{- toYaml . | nindent 8 }} {{- end }} @@ -30,6 +30,7 @@ spec: {{- end }} {{- end }} spec: + serviceAccountName: {{ .Values.job.name}} containers: - name: {{ .Values.job.name | default (include "base.fullname" .) }} image: "{{ .Values.job.image.repository }}:{{ .Values.job.image.tag | default .Chart.AppVersion }}" diff --git a/charts/base/templates/serviceaccount.yaml b/charts/base/templates/serviceaccount.yaml index 7ff33c4..c25d942 100644 --- a/charts/base/templates/serviceaccount.yaml +++ b/charts/base/templates/serviceaccount.yaml @@ -10,3 +10,17 @@ metadata: {{- toYaml . | nindent 4 }} {{- end }} {{- end }} + +--- +{{- if .Values.job.serviceAccount -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ .Values.job.name }} + labels: + {{- include "base.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} From 62af1375c8d7ffcaf44e4fb4f889039cf455694f Mon Sep 17 00:00:00 2001 From: Sarhad Date: Tue, 15 Oct 2024 13:47:42 +0400 Subject: [PATCH 2/4] job annotations --- charts/base/templates/job.yml | 6 ++++-- charts/base/templates/serviceaccount.yaml | 4 ++-- charts/base/values.yaml | 6 ++++++ 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/charts/base/templates/job.yml b/charts/base/templates/job.yml index f8ee92d..846fb7f 100644 --- a/charts/base/templates/job.yml +++ b/charts/base/templates/job.yml @@ -18,7 +18,7 @@ spec: template: metadata: annotations: - configmap: "{{ .Values.config | toYaml | sha256sum | trunc 8 }}" + configmap: "{{ .Values.config | toYaml | sha256sum | tránc 8 }}" {{- with .Values.podAnnotations }} {{- toYaml . | nindent 8 }} {{- end }} @@ -30,7 +30,9 @@ spec: {{- end }} {{- end }} spec: - serviceAccountName: {{ .Values.job.name}} + {{- if .Values.job.serviceAccount.create }} + serviceAccountName: {{ .Values.job.name }} + {{- end }} containers: - name: {{ .Values.job.name | default (include "base.fullname" .) }} image: "{{ .Values.job.image.repository }}:{{ .Values.job.image.tag | default .Chart.AppVersion }}" diff --git a/charts/base/templates/serviceaccount.yaml b/charts/base/templates/serviceaccount.yaml index c25d942..d865154 100644 --- a/charts/base/templates/serviceaccount.yaml +++ b/charts/base/templates/serviceaccount.yaml @@ -12,14 +12,14 @@ metadata: {{- end }} --- -{{- if .Values.job.serviceAccount -}} +{{- if .Values.job.serviceAccount.create -}} apiVersion: v1 kind: ServiceAccount metadata: name: {{ .Values.job.name }} labels: {{- include "base.labels" . | nindent 4 }} - {{- with .Values.serviceAccount.annotations }} + {{- with .Values.job.serviceAccount.annotations }} annotations: {{- toYaml . | nindent 4 }} {{- end }} diff --git a/charts/base/values.yaml b/charts/base/values.yaml index 0706b17..6247629 100644 --- a/charts/base/values.yaml +++ b/charts/base/values.yaml @@ -45,6 +45,12 @@ serviceAccount: # If not set and create is true, a name is generated using the fullname template name: "" +job: + serviceAccount: + create: false + annotations: {} + + podAnnotations: {} podSecurityContext: {} From ff81331e0b4ef85c4a89eddcb13edef8f78245ea Mon Sep 17 00:00:00 2001 From: Sarhad Date: Tue, 15 Oct 2024 14:42:20 +0400 Subject: [PATCH 3/4] job annotations --- charts/base/templates/job.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/base/templates/job.yml b/charts/base/templates/job.yml index 846fb7f..128dbdb 100644 --- a/charts/base/templates/job.yml +++ b/charts/base/templates/job.yml @@ -18,7 +18,7 @@ spec: template: metadata: annotations: - configmap: "{{ .Values.config | toYaml | sha256sum | tránc 8 }}" + configmap: "{{ .Values.config | toYaml | sha256sum | trunc 8 }}" {{- with .Values.podAnnotations }} {{- toYaml . | nindent 8 }} {{- end }} From 98f142b93b9d9e19adc22879a0634e477c5a64d2 Mon Sep 17 00:00:00 2001 From: Sarhad Date: Tue, 15 Oct 2024 15:21:05 +0400 Subject: [PATCH 4/4] changed condition --- charts/base/templates/job.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/charts/base/templates/job.yml b/charts/base/templates/job.yml index 128dbdb..2502cc0 100644 --- a/charts/base/templates/job.yml +++ b/charts/base/templates/job.yml @@ -1,4 +1,4 @@ -{{- if .Values.job -}} +{{- if .Values.job.image -}} apiVersion: batch/v1 kind: Job metadata: @@ -18,7 +18,7 @@ spec: template: metadata: annotations: - configmap: "{{ .Values.config | toYaml | sha256sum | trunc 8 }}" + configmap: "{{ .Values.config | toYaml | sha256sum | trunc 8 }}" {{- with .Values.podAnnotations }} {{- toYaml . | nindent 8 }} {{- end }}