-
Notifications
You must be signed in to change notification settings - Fork 45
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
chart: add extraEnv to enable secrets injection through secrets operator #514
chart: add extraEnv to enable secrets injection through secrets operator #514
Conversation
I did need to add a toggle in order to bypass the required fields being set in values. I'm open to other approaches if desired, this seemed to be the cleanest way to avoid creating a false secret that wouldn't be used. Per usage, this would enable me to create a chart that embeds nebraska, setting it as a dependency, and providing with it a secrets CRD to be consumed by my secrets operator that pulls my secret from another source. Then, I can inject that secret in
and then I can set the oidc config as follows in order for it to be picked up:
|
Hi @goshlanguage . Some of the code owners in the team have been on vacation but they should be back tomorrow. If you need more details about the style, check out: https://kinvolk.io/docs/nebraska/latest/contributing/ |
Actually, |
Apologies, I now see the bits about the commit messages: I'll see if I can amend these git commit messages. Thanks for your reply |
82c55f9
to
903b71b
Compare
Hey @goshlanguage, Thanks for the PR
An empty array, map is evaluated as The {{- $useGhAuth := eq .Values.config.auth.mode "github" }}
{{- $useOidcAuth := eq .Values.config.auth.mode "oidc" }}
{{- $useDbPassword := not .Values.config.database.passwordExistingSecret.enabled }}
{{- $ownEnv := .Values.ownEnv}}
{{- if and (or $useDbPassword $useOidcAuth $useGhAuth) $ownEnv}}
apiVersion: v1
kind: Secret
metadata:
name: {{ include "nebraska.fullname" . }}
labels:
{{- include "nebraska.labels" . | nindent 4 }}
type: Opaque
data:
{{- if $useDbPassword }}
dbPassword: {{ (tpl .Values.config.database.password .) | b64enc }}
{{- end }}
{{- if $ownEnv }}
{{- if $useOidcAuth }}
oidcClientID: {{ required "A valid 'clientId' is required when using oidc authentication" .Values.config.auth.oidc.clientID | toString | b64enc }}
oidcClientSecret: {{ required "A valid 'clientSecret' is required when using oidc authentication" .Values.config.auth.oidc.clientSecret | toString | b64enc }}
{{- with .Values.config.auth.oidc.sessionAuthKey }}
oidcSessionAuthKey: {{ . | toString | b64enc }}
{{- end }}
{{- with .Values.config.auth.oidc.sessionCryptKey }}
oidcSessionCryptKey: {{ . | toString | b64enc }}
{{- end }}
{{- end }}
{{- if $useGhAuth }}
ghClientSecret: {{ required "A valid 'clientSecret' is required when using github authentication." .Values.config.auth.github.clientSecret | toString | b64enc }}
ghSessionAuthKey: {{ required "A valid 'sessionAuthKey' is required when using github authentication." .Values.config.auth.github.sessionAuthKey | toString | b64enc }}
ghSessionCryptKey: {{ required "A valid 'sessionCryptKey' is required when using github authentication." .Values.config.auth.github.sessionCryptKey | toString | b64enc }}
ghWebhookSecret: {{ required "A valid 'webhookSecret' is required when using github authentication." .Values.config.auth.github.webhookSecret | toString | b64enc }}
{{- end }}
{{- end }}
{{- end }} What do you think? |
I wouldn't mind, but this deviates from a well established idiom/pattern in the community, including but not limited to the dependencies of this very chart. For example, see the bitnami Postgres chart: This is specifically called |
Per using the contents of |
@goshlanguage Can you rebase the PR with the |
Previously, the chart only took a key value map for data that is commonly treated as secret. This patch creates a mechanism that allows users to bring these secrets in with a secrets operator or manually, and define them, setting the relevant environment variables to the value of their secret. This requires a bypass toggle since the charts secret currently requires the secret to be passed in through values.
903b71b
to
90c7a45
Compare
all set, thank you |
Add extraEnv pattern to enable secrets injection through secrets operator
add extraEnv to enable secrets injection through secrets operator. This enables operators to bring their own secrets that don't necessarily conform to the defaults the chart sets, so this chart can be used as a chart dependency or otherwise, for users who need to leverage secrets operators like
onepass-operator
orexternal-secrets
, etc.How to use
Set extraEnv to your desired value(s), ie:
This chart change has been reviewed and tested by templating out the chart with the standard, and with valid spec in the
extraEnv
block with the following command:In the default case, nothing is appended to
env
, and in the case that the preceding example is populated in values, the resulting env spec is:Testing done
Please see above