Multiplayer agent harness for work.
chart: run pods as a configurable service account (#1122)
Jack Decker133a8fbf28e5
diff --git a/deploy/helm/templates/_helpers.tpl b/deploy/helm/templates/_helpers.tplindex 33eae44e1..f00de7d1f 100644--- a/deploy/helm/templates/_helpers.tpl+++ b/deploy/helm/templates/_helpers.tpl@@ -36,3 +36,11 @@ app.kubernetes.io/managed-by: {{ .Release.Service }}app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}{{- end }}{{- end -}}++{{- define "qm.serviceAccountName" -}}+{{- if .Values.serviceAccount.create -}}+{{- default (include "qm.fullname" .) .Values.serviceAccount.name -}}+{{- else -}}+{{- default "default" .Values.serviceAccount.name -}}+{{- end -}}+{{- end -}}diff --git a/deploy/helm/templates/deployment.yaml b/deploy/helm/templates/deployment.yamlindex 6e80e5633..fd098b535 100644--- a/deploy/helm/templates/deployment.yaml+++ b/deploy/helm/templates/deployment.yaml@@ -32,6 +32,7 @@ spec:imagePullSecrets:{{- toYaml . | nindent 8 }}{{- end }}+ serviceAccountName: {{ include "qm.serviceAccountName" $root }}containers:- name: {{ $name }}image: "{{ $root.Values.image.repository }}{{ $root.Values.image.separator | default "/" }}{{ $svc.image }}:{{ $svc.tag | default $root.Values.image.tag | default $root.Chart.AppVersion }}"@@ -93,31 +94,24 @@ spec:{{- $_ := set $wired "ADMIN_BASE_PATH" "/admin" }}{{- $_ := set $wired "ADMIN_ENABLED" (ternary "1" "0" (index $root.Values.services "admin").enabled) }}{{- end }}- {{- if or $wired $root.Values.env $svc.env }}+ {{- $componentEnv := deepCopy ($svc.env | default dict) }}+ {{- $component := "" }}+ {{- if eq $name "portal" }}{{- $component = "auth" }}{{- end }}+ {{- if eq $name "web-ui" }}{{- $component = "admin" }}{{- end }}+ {{- if and $component (index $root.Values.services $component).enabled }}+ {{- range $k, $v := (index $root.Values.services $component).env }}+ {{- if ne $k "PORT" }}+ {{- if and (hasKey $componentEnv $k) (ne (toString (index $componentEnv $k)) (toString $v)) }}+ {{- fail (printf "Conflicting %s settings in %s and %s" $k $name $component) }}+ {{- end }}+ {{- $_ := set $componentEnv $k $v }}+ {{- end }}+ {{- end }}+ {{- end }}+ {{- $env := mergeOverwrite (deepCopy $wired) (deepCopy ($root.Values.env | default dict)) $componentEnv }}+ {{- if $env }}env:- {{- range $k, $v := $wired }}- - name: {{ $k }}- value: {{ $v | quote }}- {{- end }}- {{- range $k, $v := $root.Values.env }}- - name: {{ $k }}- value: {{ $v | quote }}- {{- end }}- {{- $componentEnv := deepCopy ($svc.env | default dict) }}- {{- $component := "" }}- {{- if eq $name "portal" }}{{- $component = "auth" }}{{- end }}- {{- if eq $name "web-ui" }}{{- $component = "admin" }}{{- end }}- {{- if and $component (index $root.Values.services $component).enabled }}- {{- range $k, $v := (index $root.Values.services $component).env }}- {{- if ne $k "PORT" }}- {{- if and (hasKey $componentEnv $k) (ne (toString (index $componentEnv $k)) (toString $v)) }}- {{- fail (printf "Conflicting %s settings in %s and %s" $k $name $component) }}- {{- end }}- {{- $_ := set $componentEnv $k $v }}- {{- end }}- {{- end }}- {{- end }}- {{- range $k, $v := $componentEnv }}+ {{- range $k, $v := $env }}- name: {{ $k }}value: {{ $v | quote }}{{- end }}diff --git a/deploy/helm/templates/serviceaccount.yaml b/deploy/helm/templates/serviceaccount.yamlnew file mode 100644index 000000000..c0d7731b6--- /dev/null+++ b/deploy/helm/templates/serviceaccount.yaml@@ -0,0 +1,12 @@+{{- if .Values.serviceAccount.create }}+apiVersion: v1+kind: ServiceAccount+metadata:+ name: {{ include "qm.serviceAccountName" . }}+ labels:+ {{- include "qm.labels" . | nindent 4 }}+ {{- with .Values.serviceAccount.annotations }}+ annotations:+ {{- toYaml . | nindent 4 }}+ {{- end }}+{{- end }}diff --git a/deploy/helm/values.yaml b/deploy/helm/values.yamlindex b8c56dfa2..31b7f1495 100644--- a/deploy/helm/values.yaml+++ b/deploy/helm/values.yaml@@ -6,6 +6,11 @@ image:imagePullSecrets: []+serviceAccount:+ create: false+ name: ""+ annotations: {}+nameOverride: ""fullnameOverride: ""