diff --git a/charts/common/Chart.yaml b/charts/common/Chart.yaml index 45059b4..a2dca47 100644 --- a/charts/common/Chart.yaml +++ b/charts/common/Chart.yaml @@ -2,5 +2,5 @@ apiVersion: v2 name: common description: Opinated Helm chart for deploying applications to Kubernetes type: application -version: 1.0.17 +version: 1.0.18 appVersion: "v0.1.0" diff --git a/charts/common/templates/_helpers.tpl b/charts/common/templates/_helpers.tpl index d26da38..0431cf8 100644 --- a/charts/common/templates/_helpers.tpl +++ b/charts/common/templates/_helpers.tpl @@ -69,3 +69,10 @@ Return the proper Common image {{- end -}} {{- printf "%s%s%s" $repositoryName $separator $tag -}} {{- end -}} + +{{/* +Service Account Name +*/}} +{{- define "common.serviceAccountName" -}} +{{- default (include "common.fullname" .) .Values.serviceAccount.name -}} +{{- end -}} \ No newline at end of file diff --git a/charts/common/templates/deployment.yaml b/charts/common/templates/deployment.yaml index 893f809..a532d8e 100644 --- a/charts/common/templates/deployment.yaml +++ b/charts/common/templates/deployment.yaml @@ -4,6 +4,9 @@ metadata: name: {{ include "common.fullname" . }} labels: {{- include "common.labels" . | nindent 4 }} + {{- range $key, $value := .Values.labels }} + {{ $key }}: {{ $value | quote }} + {{- end }} {{- with .Values.annotations }} annotations: {{- toYaml . | nindent 4 }} @@ -28,12 +31,15 @@ spec: {{- end }} labels: {{- include "common.selectorLabels" $ | nindent 8 }} + {{- range $key, $value := .Values.podLabels }} + {{ $key }}: {{ $value | quote }} + {{- end }} spec: {{- with .Values.image.pullSecrets }} imagePullSecrets: {{- toYaml . | nindent 8 }} {{- end }} - serviceAccountName: {{ include "common.fullname" . }} + serviceAccountName: {{ include "common.serviceAccountName" . }} securityContext: {{- toYaml .Values.podSecurityContext | nindent 8 }} containers: diff --git a/charts/common/templates/serviceaccount.yaml b/charts/common/templates/serviceaccount.yaml index 2d180fc..500604c 100644 --- a/charts/common/templates/serviceaccount.yaml +++ b/charts/common/templates/serviceaccount.yaml @@ -1,10 +1,12 @@ +{{- if .Values.serviceAccount.create }} apiVersion: v1 kind: ServiceAccount metadata: - name: {{ include "common.fullname" . }} + name: {{ include "common.serviceAccountName" . }} labels: {{- include "common.labels" . | nindent 4 }} {{- with .Values.serviceAccount.annotations }} annotations: {{- toYaml . | nindent 4 }} {{- end }} +{{- end }} diff --git a/charts/common/values.test.yaml b/charts/common/values.test.yaml index d259a2f..9d4b85f 100644 --- a/charts/common/values.test.yaml +++ b/charts/common/values.test.yaml @@ -25,6 +25,9 @@ lifecycleHooks: {} podAnnotations: {} +podLabels: + app: "my-app" + revisionHistoryLimit: 2 podSecurityContext: diff --git a/charts/common/values.yaml b/charts/common/values.yaml index c986843..574d858 100644 --- a/charts/common/values.yaml +++ b/charts/common/values.yaml @@ -26,6 +26,10 @@ annotations: {} podAnnotations: {} +labels: {} + +podLabels: {} + revisionHistoryLimit: 2 podSecurityContext: {} @@ -168,7 +172,9 @@ volumes: [] volumeMounts: [] serviceAccount: + create: true annotations: {} + name: "" cronJobs: [] # - name: my-cronjob