Skip to content

Commit

Permalink
Make the service account optional
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanprodan committed Dec 18, 2018
1 parent 0735919 commit e4ea4f3
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 12 deletions.
18 changes: 14 additions & 4 deletions charts/flagger/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "flagger.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Expand the name of the chart.
*/}}
Expand All @@ -25,8 +31,12 @@ If release name contains chart name it will be used as a full name.
{{- end -}}

{{/*
Create chart name and version as used by the chart label.
Create the name of the service account to use
*/}}
{{- define "flagger.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- define "flagger.serviceAccountName" -}}
{{- if .Values.serviceAccount.create -}}
{{ default (include "flagger.fullname" .) .Values.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.serviceAccount.name }}
{{- end -}}
{{- end -}}
13 changes: 8 additions & 5 deletions charts/flagger/templates/account.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
{{- if .Values.serviceAccount.create }}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ template "flagger.name" . }}
name: {{ template "flagger.serviceAccountName" . }}
labels:
app: {{ template "flagger.name" . }}
chart: {{ template "flagger.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
helm.sh/chart: {{ template "flagger.chart" . }}
app.kubernetes.io/name: {{ template "flagger.name" . }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/version: {{ .Chart.AppVersion }}
{{- end }}
4 changes: 2 additions & 2 deletions charts/flagger/templates/rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ roleRef:
kind: ClusterRole
name: {{ template "flagger.fullname" . }}
subjects:
- name: {{ template "flagger.name" . }}
namespace: {{ .Release.Namespace | quote }}
- name: {{ template "flagger.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
kind: ServiceAccount
{{- end }}
10 changes: 9 additions & 1 deletion charts/flagger/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,18 @@ slack:
# incoming webhook https://api.slack.com/incoming-webhooks
url:

crd:
serviceAccount:
# serviceAccount.create: Whether to create a service account or not
create: true
# serviceAccount.name: The name of the service account to create or use
name: ""

rbac:
# rbac.create: `true` if rbac resources should be created
create: true

crd:
# crd.create: `true` if custom resource definitions should be created
create: true

nameOverride: ""
Expand Down

0 comments on commit e4ea4f3

Please sign in to comment.