Skip to content

Commit

Permalink
feat: add support for podLabels and external service account
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippeVienne committed Aug 13, 2024
1 parent 868be42 commit a6b20be
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 3 deletions.
2 changes: 1 addition & 1 deletion charts/common/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
7 changes: 7 additions & 0 deletions charts/common/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 -}}
8 changes: 7 additions & 1 deletion charts/common/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -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:
Expand Down
4 changes: 3 additions & 1 deletion charts/common/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
3 changes: 3 additions & 0 deletions charts/common/values.test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ lifecycleHooks: {}

podAnnotations: {}

podLabels:
app: "my-app"

revisionHistoryLimit: 2

podSecurityContext:
Expand Down
6 changes: 6 additions & 0 deletions charts/common/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ annotations: {}

podAnnotations: {}

labels: {}

podLabels: {}

revisionHistoryLimit: 2

podSecurityContext: {}
Expand Down Expand Up @@ -168,7 +172,9 @@ volumes: []
volumeMounts: []

serviceAccount:
create: true
annotations: {}
name: ""

cronJobs: []
# - name: my-cronjob
Expand Down

0 comments on commit a6b20be

Please sign in to comment.