Skip to content
Open
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
6 changes: 3 additions & 3 deletions charts/common/templates/_podSpec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ imagePullSecrets:
{{- end }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 2 }}
{{- if .Values.serviceAccount }}
serviceAccountName: {{ .Values.serviceAccount }}
{{- if .Values.serviceAccount.create -}}
serviceAccountName: {{ .Values.serviceAccount.name | quote }}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

There's an inconsistency in how the service account name is determined. Here, serviceAccountName is set to .Values.serviceAccount.name. However, in charts/common/templates/_serviceaccount.yaml, the service account resource is created with a default name (include "onechart.fullname" .) if .Values.serviceAccount.name is not provided.

If serviceAccount.create is true but serviceAccount.name is empty, a new service account will be created with a generated name, but the pod will be configured to use an empty-named service account, which will fall back to the default service account in the namespace. This will cause the pod to not use the service account created for it.

To ensure the pod uses the correct service account, the logic for determining the name should be consistent. You should use the same default value here.

serviceAccountName: {{ .Values.serviceAccount.name | default (include "onechart.fullname" .) | quote }}

{{- end }}
initContainers:
{{- range .Values.initContainers }}
Expand Down Expand Up @@ -80,4 +80,4 @@ affinity:
tolerations:
{{- toYaml . | nindent 2 }}
{{- end }}
{{- end }}
{{- end }}