stable/stackdriver-exporter: Allow setting of pod ServiceAccount name (#15931)

* Allow setting of pod service account name

This makes it possible to use a serviceAccount other than the default.

I need this to aid my use the chart in conjunction with GKE's [Workload
Identity
feature](https://cloud.google.com/kubernetes-engine/docs/how-to/workload-identity)
which requires the use of an annotated service account for pods using
Google APIs.

Signed-off-by: Charlie Egan <charlieegan3@users.noreply.github.com>

* Enable creation of SA

Based on this:
https://helm.sh/docs/chart_best_practices/#role-based-access-control

Made in response to:
https://github.com/helm/charts/pull/15931#issuecomment-515846998

Signed-off-by: Charlie Egan <charlieegan3@users.noreply.github.com>

* Add notes about new variables to readme

Signed-off-by: Charlie Egan <charlieegan3@users.noreply.github.com>
This commit is contained in:
Charlie Egan
2019-07-29 12:42:48 -07:00
committed by Kubernetes Prow Robot
parent a9ce4492c9
commit 780761f5f3
6 changed files with 37 additions and 1 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
apiVersion: v1
description: Stackdriver exporter for Prometheus
name: stackdriver-exporter
version: 1.1.0
version: 1.1.1
appVersion: 0.6.0
home: https://www.stackdriver.com/
sources:
+2
View File
@@ -64,6 +64,8 @@ Parameter | Description
`image.tag` | Container image tag | `v0.6.0`
`image.pullPolicy` | Container image pull policy | `IfNotPresent`
`resources` | Resource requests & limits | `{}`
`serviceAccount.name` | Name of Kubernetes service account to use | `""` (defaults to `default`)
`serviceAccount.create` | Toggle for service account creation | `false`
`service.type` | Type of service to create | `ClusterIP`
`service.httpPort` | Port for the http service | `9255`
`stackdriver.projectId` | GCP Project ID | ``
@@ -30,3 +30,14 @@ Create chart name and version as used by the chart label.
{{- define "stackdriver-exporter.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Create the name of the service account to use
*/}}
{{- define "stackdriver-exporter.serviceAccountName" -}}
{{- if .Values.serviceAccount.create -}}
{{ default (include "stackdriver-exporter.fullname" .) .Values.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.serviceAccount.name }}
{{- end -}}
{{- end -}}
@@ -32,6 +32,7 @@ spec:
affinity:
{{ toYaml .Values.affinity | indent 8 }}
{{- end }}
serviceAccount: {{ template "stackdriver-exporter.serviceAccountName" . }}
restartPolicy: {{ .Values.restartPolicy }}
volumes:
{{- if .Values.stackdriver.serviceAccountSecret }}
@@ -0,0 +1,11 @@
{{- if .Values.serviceAccount.create }}
apiVersion: v1
kind: ServiceAccount
metadata:
labels:
chart: {{ template "stackdriver-exporter.chart" . }}
app: {{ template "stackdriver-exporter.name" . }}
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
name: {{ template "stackdriver-exporter.serviceAccountName" . }}
{{- end -}}
+11
View File
@@ -72,3 +72,14 @@ tolerations: []
# operator: "Equal|Exists"
# value: "value"
# effect: "NoSchedule|PreferNoSchedule|NoExecute(1.6 only)"
## Service Account
##
serviceAccount:
# Specifies whether a ServiceAccount should be created
create: false
# The name of the ServiceAccount to use.
# If not set and create is false, 'default' is used
# If not set and create is true, a name is generated using the fullname template
name: