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

How to deal with different versions in different environment? #460

Closed
tonsV2 opened this issue Feb 2, 2019 · 9 comments
Closed

How to deal with different versions in different environment? #460

tonsV2 opened this issue Feb 2, 2019 · 9 comments

Comments

@tonsV2
Copy link

tonsV2 commented Feb 2, 2019

I found it difficult dealing with different versions across different environments

I've came up with the following but I'd love to see someone come up with something simpler.

helmfile.yaml:

environments:
  dev:
    values:
      - env/dev.yaml
  prod:
    values:
      - env/prod.yaml

releases:
  - name: some-name
    namespace: some-namespace
    chart: some/thing
    version: {{ index .Environment.Values.version "some-name" }}

env/dev.yaml:

version:
  some-name: "0.1"

env/prod.yaml:

version:
  some-name: "1.0"

Please let me know what you think.

@manics
Copy link
Contributor

manics commented Feb 4, 2019

I used something similar so that I could override values for dev vs production environments:

    values:
      - values/jupyterhub-config.yaml
    {{ range .Environment.Values.jupyterhub_public_overrides }}
      - {{ . }}
    {{ end }}

https://github.com/IDR/k8s-analysis-deploy/blob/2019.01.30/helmfile.yaml#L104
jupyterhub_public_overrides is [] for production.

What would be nice is if index .Environment.Values could take a default, so helmfile.yml could contain the full production config, with only the dev overrides needing to be defined, e.g.:

  • {{ index .Environment.Values.version "some-name" | default "1.0" }}
  • {{ range .Environment.Values.jupyterhub_public_overrides | default nil }}

At the moment this fails if the values aren't defined:

error during helmfile.yaml parsing: template: stringTemplate:34:25: executing "stringTemplate" at <.Environment.Values....>: map has no entry for key "jupyterhub_staging_overrides"

@tonsV2
Copy link
Author

tonsV2 commented Feb 4, 2019

So jupyterhub_public_overrides is defined in an environment specific values file as a list of files? But, in your case, empty for production? Could you elaborate a bit more, sorry for being a bit slow.

@manics
Copy link
Contributor

manics commented Feb 4, 2019

I've got two environments with separate values files in that git repo: https://github.com/IDR/k8s-analysis-deploy/blob/2019.01.30/helmfile.yaml#L237

@ingvarch
Copy link

ingvarch commented Mar 9, 2019

Any updates? I have the same issue.

@sgandon
Copy link
Contributor

sgandon commented Mar 27, 2019

I guess this would be more simpler with this request developped : #359

@mumoshu
Copy link
Collaborator

mumoshu commented Mar 29, 2019

@manics

What would be nice is if index .Environment.Values could take a default, so helmfile.yml could contain the full production config, with only the dev overrides needing to be defined

Would #465 resolve your issue? With #465, I believe you can write it like:

# Instead of: {{ index .Environment.Values.version "some-name" | default "1.0" }}

{{ .Environment.Values | get "version.some-name" "1.0" }}

@mumoshu
Copy link
Collaborator

mumoshu commented Mar 29, 2019

@tonsV2 @ingvarch Hey!

Can I boil this issue down to "We need a less verbose way to achieve defaulting for environment values"?

In that case,

Do you think we can resolve this after either or both of them are addressed?

mumoshu added a commit to mumoshu/helmfile that referenced this issue Mar 29, 2019
`get` is now able to take one more optional argument, that is used as the default value when the value for the key does not exist.

Resolves roboll#465
Fixes roboll#427
Fixes roboll#357
Ref roboll#460
mumoshu added a commit to mumoshu/helmfile that referenced this issue Mar 29, 2019
`get` is now able to take one more optional argument, that is used as the default value when the value for the key does not exist.

Resolves roboll#465
Fixes roboll#427
Fixes roboll#357
Ref roboll#460
mumoshu added a commit that referenced this issue Mar 29, 2019
`get` is now able to take one more optional argument, that is used as the default value when the value for the key does not exist.

Resolves #465
Fixes #427
Fixes #357
Ref #460
@mumoshu
Copy link
Collaborator

mumoshu commented May 29, 2019

FYI #359 has been finally implemented via #621

@mumoshu
Copy link
Collaborator

mumoshu commented May 29, 2019

Closing this as resolved because all the suggested solutions are implemented. Please feel free to reopen if necessary!

@mumoshu mumoshu closed this as completed May 29, 2019
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

No branches or pull requests

5 participants