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

Conversation

gilles-gosuin
Copy link
Contributor

  • Allow the service account token automounting feature to be disabled on both the ServiceAccount itself and the Pod
  • Allow for arbitrary volumes to be mounted in the Pod, so that the service account token can be manually injected into the Pod

…llow for volumes to be mountedd to mount the token manually
@gilles-gosuin gilles-gosuin force-pushed the opt-out-service-account-token-automounting branch from 0bf3702 to fab9ecb Compare October 24, 2023 13:56
@@ -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.

Copy link
Member

@martin-helmich martin-helmich left a comment

Choose a reason for hiding this comment

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

Sorry this took a while. 🙏 LGTM now 👍

@martin-helmich martin-helmich merged commit f2ee137 into mittwald:master Dec 22, 2023
4 checks passed
@martin-helmich martin-helmich linked an issue Dec 22, 2023 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add the option to opt out of service account token automounting
2 participants