Skip to content
This repository has been archived by the owner on May 16, 2023. It is now read-only.

[logstash] fix ServiceAccount inconsistencies #1581

Merged
merged 1 commit into from
Feb 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions logstash/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,10 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}

{{/*
Use the fullname if the serviceAccount value is not set
*/}}
{{- define "logstash.serviceAccount" -}}
{{- .Values.rbac.serviceAccountName | default (include "logstash.fullname" .) -}}
{{- end -}}
6 changes: 1 addition & 5 deletions logstash/templates/rolebinding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@ metadata:
release: {{ .Release.Name | quote }}
subjects:
- kind: ServiceAccount
{{- if eq .Values.rbac.serviceAccountName "" }}
name: {{ $fullName | quote }}
{{- else }}
name: {{ .Values.rbac.serviceAccountName | quote }}
{{- end }}
name: "{{ template "logstash.serviceAccount" . }}"
namespace: {{ .Release.Namespace | quote }}
roleRef:
kind: Role
Expand Down
6 changes: 1 addition & 5 deletions logstash/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@
apiVersion: v1
kind: ServiceAccount
metadata:
{{- if eq .Values.rbac.serviceAccountName "" }}
name: {{ $fullName | quote }}
{{- else }}
name: {{ .Values.rbac.serviceAccountName | quote }}
{{- end }}
name: "{{ template "logstash.serviceAccount" . }}"
annotations:
{{- with .Values.rbac.serviceAccountAnnotations }}
{{- toYaml . | nindent 4 }}
Expand Down
6 changes: 2 additions & 4 deletions logstash/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,8 @@ spec:
{{- end }}
securityContext:
{{ toYaml .Values.podSecurityContext | indent 8 }}
{{- if .Values.rbac.create }}
serviceAccountName: "{{ template "logstash.fullname" . }}"
{{- else if not (eq .Values.rbac.serviceAccountName "") }}
serviceAccountName: {{ .Values.rbac.serviceAccountName | quote }}
{{- if or .Values.rbac.create .Values.rbac.serviceAccountName }}
serviceAccountName: "{{ template "logstash.serviceAccount" . }}"
{{- end }}
{{- with .Values.tolerations }}
tolerations:
Expand Down