-
Notifications
You must be signed in to change notification settings - Fork 27
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
Support envfrom secret #94
base: main
Are you sure you want to change the base?
Conversation
liangliangma seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank very much for the contribution @futurelm!
There are some conflicts with the main branch, could you solve them please? Also, I might be mistaken but it seems that README was not generated with helm-docs: please give the contribution guide a look.
Also, I left a couple of notes, and would love to hear your thoughts
{{- $fullName := include "pyroscope.fullname" . -}} | ||
{{- if .Values.env }} | ||
env: | ||
{{- range $k, $v := .Values.env }} | ||
- name: {{ $k }} | ||
value: {{ $v }} | ||
{{- end }} | ||
{{- if .Values.envFrom }} | ||
{{- range $key, $val := .Values.envFrom }} | ||
- name: {{ $key }} | ||
valueFrom: | ||
secretKeyRef: | ||
name: {{ $fullName }}-env-secret | ||
key: {{ $val }} | ||
{{- end }} | ||
{{- end }} | ||
{{- end }} | ||
{{- if empty .Values.env }} | ||
{{- if .Values.envFrom }} | ||
env: | ||
{{- range $key, $val := .Values.envFrom }} | ||
- name: {{ $key }} | ||
valueFrom: | ||
secretKeyRef: | ||
name: {{ $fullName }}-env-secret | ||
key: {{ $val }} | ||
{{- end }} | ||
{{- end }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think envFrom
might be misleading as there is k8s directive with the same name already that works slightly differently. Please consider changing .Values.envFrom
to .Values.envVars
.
Also, it might be better to require a user to provide the full structure rather than forcing them to use predefined secret names like pyroscope-env-secret
and to not limit them to secretKeyRef
env var source (there are three more of them)
For example (I did't test it):
values.yaml
:
env:
KEY: value
envVars:
- name: SECRET_USERNAME
valueFrom:
secretKeyRef:
name: mysecret
key: username
optional: false
- name: SECRET_PASSWORD
valueFrom:
secretKeyRef:
name: mysecret
key: password
optional: true
deployment.yaml
:
{{- if or .Values.env .Values.envVars }}
env:
{{- range $k, $v := .Values.env }}
- name: {{ $k }}
value: {{ $v }}
{{- end }}
{{- with .Values.envVars }}
{{- toYaml . | indent 12 }} # Not sure about indent
{{- end }}
{{- end }}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, it is better to not limit them to secretKeyRefenv var source, i will update to use toYaml
@@ -191,6 +191,8 @@ extraVolumeMounts: [] | |||
# -- Extra environment variables | |||
env: {} | |||
|
|||
envFrom: {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be great to have a comment here explaining users the difference with env
and which option is preferable in a particular case (e.g if one wants to protect sensitive variables)
pass env variables use secret
https://pyroscope.slack.com/archives/C01FJRYENPQ/p1668486401890059
similar open issue: #41