Skip to content

Commit

Permalink
feat(helm): add option to create a service account and specify a defa…
Browse files Browse the repository at this point in the history
…ult user id in securityContext (#815)
  • Loading branch information
AndreZiviani authored Sep 23, 2021
1 parent 6fd15f1 commit b93598e
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 6 deletions.
2 changes: 1 addition & 1 deletion helm/akhq/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v1
appVersion: "0.18.0"
description: Kafka GUI for Apache Kafka to manage topics, topics data, consumers group, schema registry, connect and more...
name: akhq
version: 0.2.2
version: 0.2.3
keywords:
- kafka
- confluent
Expand Down
11 changes: 11 additions & 0 deletions helm/akhq/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,14 @@ Create chart name and version as used by the chart label.
{{- define "akhq.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create the name of the service account to use
*/}}
{{- define "akhq.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "akhq.fullname" .) .Values.serviceAccountName }}
{{- else }}
{{- default "default" .Values.serviceAccountName }}
{{- end }}
{{- end }}
4 changes: 1 addition & 3 deletions helm/akhq/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ spec:
securityContext:
{{ toYaml .Values.securityContext | nindent 8 }}
{{- end }}
{{- if .Values.serviceAccountName }}
serviceAccountName: {{ .Values.serviceAccountName }}
{{- end }}
serviceAccountName: {{ include "akhq.serviceAccountName" . }}
{{- if .Values.initContainers }}
initContainers:
{{- range $key, $value := .Values.initContainers }}
Expand Down
15 changes: 15 additions & 0 deletions helm/akhq/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{{- if .Values.serviceAccount.create }}
apiVersion: v1
kind: ServiceAccount
metadata:
labels:
app.kubernetes.io/name: {{ include "akhq.name" . }}
helm.sh/chart: {{ include "akhq.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{ toYaml . | indent 4 }}
{{- end }}
name: {{ include "akhq.serviceAccountName" . }}
{{- end }}
10 changes: 8 additions & 2 deletions helm/akhq/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ extraVolumeMounts: []

# Specify ServiceAccount for pod
serviceAccountName: null
serviceAccount:
create: false
#annotations:
# eks.amazonaws.com/role-arn: arn:aws:iam::123456789000:role/iam-role-name-here

# Add your own init container or uncomment and modify the example.
initContainers: {}
Expand All @@ -73,13 +77,15 @@ initContainers: {}
# - mountPath: /tmp
# name: certs

securityContext: {}
securityContext:
fsGroup: 1000
runAsGroup: 1000
runAsUser: 1000
# capabilities:
# drop:
# - ALL
# # readOnlyRootFilesystem: true
# runAsNonRoot: true
# runAsUser: 1000

service:
enabled: true
Expand Down

0 comments on commit b93598e

Please sign in to comment.