-
-
Notifications
You must be signed in to change notification settings - Fork 106
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
Allow injection of env vars in any deployment #120
Conversation
values.yaml
Outdated
@@ -158,6 +160,9 @@ ingress: | |||
# TODO: Alternatively as part of reorganizing Helm values, consider moving values to existing `st2` and `st2web` sections ? (#14) | |||
secrets: | |||
st2: | |||
st2chatops: |
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.
Any reason this is secrets.st2.st2chatops
instead of secrets.st2chatops
(i.e. why the nesting under st2
)?
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.
Also, any reason not to put the secrets specific to st2chatops under st2chatops (and the same for all other services) instead of aggregating all secrets to a central place?
i.e. instead of
secrets:
st2:
st2chatops:
foo: bar
do
st2chatops:
secrets:
foo: bar
?
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.
Any reason this is
secrets.st2.st2chatops
instead ofsecrets.st2chatops
(i.e. why the nesting underst2
)?
For this part, no particular reason, it's true that it's a bit too verbose.
Also, any reason not to put the secrets specific to st2chatops under st2chatops (and the same for all other services) instead of aggregating all secrets to a central place?
See issue #14 :)
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.
Makes sense. I think it'd be preferable to spread the secrets out into their respective services, but we can tackle that when we tackle #14
Thanks!
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 agree that secrets.st2.st2chatops
looks too verbose and even counter-intuitive.
This also raises some inconsistencies in the context of #119 discussion. I'm thinking about exploring the alternatives for the Helm values definition.
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.
The changes look good to me. I haven't tested them, though..
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.
values.yaml
Outdated
@@ -158,6 +160,9 @@ ingress: | |||
# TODO: Alternatively as part of reorganizing Helm values, consider moving values to existing `st2` and `st2web` sections ? (#14) | |||
secrets: | |||
st2: | |||
st2chatops: |
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 agree that secrets.st2.st2chatops
looks too verbose and even counter-intuitive.
This also raises some inconsistencies in the context of #119 discussion. I'm thinking about exploring the alternatives for the Helm values definition.
templates/secrets_st2chatops.yaml
Outdated
@@ -16,7 +16,7 @@ metadata: | |||
heritage: {{ .Release.Service }} | |||
type: Opaque | |||
data: | |||
{{- range $env, $value := .Values.st2chatops.env }} | |||
{{- range $env, $value := .Values.secrets.st2.st2chatops.env }} |
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 there is at least an agreement about the 💯 need of raw ENV
for every Pod and that's super helpful.
Can we keep raw ENV functionality in this PR to be able to merge it asap, but split the st2chatops
secrets ENV enhancement into another PR?
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.
Awesome start!
I think we might also want to add an env block to the jobs (all the jobs would share the same block).
In values.yaml
, it would be something like:
jobs:
env: {}
# HTTP_PROXY: http://proxy:1234
templates/deployments.yaml
Outdated
{{- if .Values.st2auth.env }} | ||
env: | ||
{{- range $env, $value := .Values.st2auth.env }} | ||
- name: {{ $env | quote }} | ||
value: {{ $value | quote }} | ||
{{- 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 this could be extracted into a helper to avoid some repetition.
So, here it would have:
{{ include "custom-env" .Values.st2auth | indent 8 }}
And then the template would be:
{{- define "custom-env" -}}
{{- if .env }}
env:
{{- range $env, $value := .env }}
- name: {{ $env | quote }}
value: {{ $value | quote }}
{{- end }}
{{- end }}
{{- end -}}
templates/deployments.yaml
Outdated
{{- if .env }} | ||
env: | ||
{{- range $env, $value := .env }} | ||
- name: {{ $env | quote }} | ||
value: {{ $value | quote }} | ||
{{- 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.
And the template here would just be:
{{ include "custom-env" . | indent 8 }}
templates/deployments.yaml
Outdated
{{- range $env, $value := .Values.st2chatops.env }} | ||
- name: {{ $env | quote }} | ||
value: {{ $value | quote }} | ||
{{- 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 I would drop this, and leave the st2chatops env as is (in envFrom[1].secretRef
below).
{{- range $env, $value := .Values.st2chatops.env }} | |
- name: {{ $env | quote }} | |
value: {{ $value | quote }} | |
{{- end }} |
templates/deployments.yaml
Outdated
{{- range $env, $value := .Values.st2client.env }} | ||
- name: {{ $env | quote }} | ||
value: {{ $value | quote }} | ||
{{- 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.
A couple of jobs also have an env:
block already. So, we could split the template into two to accommodate this usage.
{{- define "custom-env-entries" -}}
{{- range $env, $value := .env }}
- name: {{ $env | quote }}
value: {{ $value | quote }}
{{- end }}
{{- end -}}
{{- define "custom-env" -}}
{{- if .env }}
env:
{{ include "custom-env-entries" . }}
{{- end }}
{{- end -}}
Which would make this block be:
{{ include "custom-env-entries" .Values.st2client }}
env: {} | ||
# HTTP_PROXY: http://proxy:1234 |
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.
Nice. I like the commented example. 👍
I want to clear out old PRs by merging them if possible. I think a Changelog entry is the only thing left before merging this. @angrydeveloper what do you think of these changes? |
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.
The changes look really helpful! 👍
Thanks @cognifloyd. I think it's also OK to inject the changelog as well to merge it.
This allows the user to inject any custom env variable in any deployment.
The need was the ability to configure a proxy so that
st2 pack install
doesn't fail when behind said proxy. The env variable needed to be injected in thest2actionrunner
deployments.There is a BC break on
st2chatops
configuration, if secrets are provided, they need to be added tosecrets.st2.st2chatops.env
instead ofst2chatops.env
.This should also closes #119 and partially solves #14.