Skip to content

Commit

Permalink
shortlink-common: add ServiceAccount
Browse files Browse the repository at this point in the history
Signed-off-by: Victor Login <batazor111@gmail.com>
  • Loading branch information
batazor committed Jan 1, 2023
1 parent beb8183 commit 177975a
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 14 deletions.
2 changes: 1 addition & 1 deletion ops/Helm/shortlink-common/Chart.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ dependencies:
repository: https://charts.bitnami.com/bitnami
version: 2.2.2
digest: sha256:76e63a2ff3b4cb7676c9fc2a5c36d5c0d9564b5fe96a4ec7dcc53c2a73e723de
generated: "2023-01-01T13:32:20.902655+06:00"
generated: "2023-01-01T15:33:42.256432+06:00"
2 changes: 1 addition & 1 deletion ops/Helm/shortlink-common/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2 # The chart API version (requir
appVersion: "1.0.0" # The version of the app that this contains (optional)
name: shortlink-common # The name of the chart (required)
description: Shortlink common templates # A single-sentence description of this project (optional)
version: 0.2.12 # A SemVer 2 version (required)
version: 0.2.13 # A SemVer 2 version (required)
kubeVersion: ">= 1.22.0 || >= v1.22.0-0" # A SemVer range of compatible Kubernetes versions (optional)
keywords:
- shortlink
Expand Down
11 changes: 0 additions & 11 deletions ops/Helm/shortlink-common/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,3 @@ app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
app.kubernetes.io/part-of: shortlink
track: stable
{{- end -}}

{{/*
Create the name of the service account to use
*/}}
{{- define "helpers.serviceAccountName" -}}
{{- if .Values.serviceAccount.create -}}
{{ default (include "helpers.fullname" .) .Values.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.serviceAccount.name }}
{{- end -}}
{{- end -}}
33 changes: 33 additions & 0 deletions ops/Helm/shortlink-common/templates/_serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{{/* vim: set filetype=mustache: */}}

{{/*
Create the name of the service account to use
*/}}
{{- define "shortlink-common.serviceAccountName" -}}
{{- if .Values.serviceAccount.create -}}
{{ default (include "helpers.fullname" .) .Values.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.serviceAccount.name }}
{{- end -}}
{{- end -}}

{{- define "shortlink-common.ServiceAccount" }}
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ template "shortlink-common.serviceAccountName" . }}
labels: {{ include "helpers.labels" . | nindent 4 }}
{{- if .Values.commonLabels }}
{{- include "common.tplvalues.render" (dict "value" .Values.commonLabels "context" $) | nindent 4 }}
{{- end }}
annotations:
{{- if .Values.commonAnnotations }}
{{- include "common.tplvalues.render" (dict "value" .Values.commonAnnotations "context" $) | nindent 4 }}
{{- end }}
{{- if .Values.serviceAccount.annotations }}
{{- include "common.tplvalues.render" (dict "value" .Values.serviceAccount.annotations "context" $) | nindent 4 }}
{{- end }}
automountServiceAccountToken: {{ .Values.serviceAccount.automountServiceAccountToken }}
{{- end -}}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ spec:
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ template "helpers.serviceAccountName" . }}
serviceAccountName: {{ template "shortlink-common.serviceAccountName" . }}
securityContext:
# -- fsGroup is the group ID associated with the container
fsGroup: 1000
Expand Down

0 comments on commit 177975a

Please sign in to comment.