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

Support envfrom secret #94

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

futurelm
Copy link

pass env variables use secret
https://pyroscope.slack.com/archives/C01FJRYENPQ/p1668486401890059

similar open issue: #41

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


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.

Copy link
Member

@kolesnikovae kolesnikovae left a 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

Comment on lines +40 to +67
{{- $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 }}
Copy link
Member

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 secretKeyRefenv 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 }}

Copy link
Author

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: {}
Copy link
Member

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)

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.

3 participants