diff --git a/charts/base/templates/job.yml b/charts/base/templates/job.yml index 2982a2f..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: @@ -30,6 +30,9 @@ spec: {{- end }} {{- end }} spec: + {{- 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 7ff33c4..d865154 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.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ .Values.job.name }} + labels: + {{- include "base.labels" . | nindent 4 }} + {{- with .Values.job.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- 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: {}