Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the option to opt out of service account token automounting #89

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
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ spec:
labels:
{{- include "kubernetes-secret-generator.selectorLabels" . | nindent 8 }}
spec:
{{- if hasKey .Values "automountServiceAccountToken" }}
Copy link
Member

Choose a reason for hiding this comment

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

Since automountServiceAccountToken is always defined in the values.yml (albeit with an empty value), this will always be true; maybe remove the empty default value from the values.yml, or test if it was explicitly set to false, instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hasKey returns false if the value is empty and nothing will get output to the manifests.

Copy link
Member

Choose a reason for hiding this comment

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

A helm template call (Helm v3.13.1) with default values generates the following manifest code in my case:

$ helm template ./deploy/helm-chart/kubernetes-secret-generator
[...]
    spec:
      automountServiceAccountToken:

      serviceAccountName: release-name-kubernetes-secret-generator
      securityContext:
        {}
[...]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, my bad, I got mixed up with a similar PR I had on another repo...

You're right, that's what gets generated. Which should be fine: if the user does not override the value, the k8s default will be used.

automountServiceAccountToken: {{ .Values.automountServiceAccountToken }}
{{- end }}
{{- if .Values.priorityClassName }}
priorityClassName: {{ .Values.priorityClassName | quote}}
{{- end }}
Expand Down Expand Up @@ -67,6 +70,7 @@ spec:
value: {{ .Values.useMetricsService | quote }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumeMounts: {{ .Values.volumeMounts | toYaml | nindent 12 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
Expand All @@ -79,3 +83,4 @@ spec:
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
volumes: {{ .Values.volumes | toYaml | nindent 8 }}
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
{{- if hasKey .Values.serviceAccount "automountServiceAccountToken" }}
automountServiceAccountToken: {{ .Values.serviceAccount.automountServiceAccountToken }}
{{- end }}
metadata:
name: {{ include "kubernetes-secret-generator.serviceAccountName" . }}
labels:
Expand Down
7 changes: 7 additions & 0 deletions deploy/helm-chart/kubernetes-secret-generator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ nameOverride: ""
fullnameOverride: ""
deploymentStrategy: "Recreate"

automountServiceAccountToken:

serviceAccount:
automountServiceAccountToken:
# Specifies whether a service account should be created
create: true
# The name of the service account to use.
Expand Down Expand Up @@ -66,6 +69,10 @@ watchNamespace: ""

useMetricsService: false

volumeMounts: []

volumes: []
martin-helmich marked this conversation as resolved.
Show resolved Hide resolved

# RBAC parameteres
# https://kubernetes.io/docs/reference/access-authn-authz/rbac/
rbac:
Expand Down
Loading