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

feat: add support for multiple helmfile "environments" to be targeted on the CLI #633

Closed
bitsofinfo opened this issue May 31, 2019 · 2 comments

Comments

@bitsofinfo
Copy link
Contributor

Currently I can only do this

helmfile -f myhelmfile.yaml -e myenv1 apply

Would be great to be able to do this, where when multiple are present, they are merged into a single .Environment

helmfile -f myhelmfile.yaml -e app1,cluster1 apply

OR

helmfile -f myhelmfile.yaml -e app1 -e cluster1 apply

Why?

Consider this:

myhelmfile.yaml

bases:
  - environments.yaml
---
releases:
  - name: myapp
    namespace: default
    chart: stable/nginx-ingress
    values:
      -  someArgument: {{.Environment.cluster.name}}
          anotherArgument {{.Environment.app.setting1}}

environments.yaml

environments:
  app1:
    values:
      - app1.yaml
  app2:
    values:
      - app2.yaml
  ...
  app1000:
    values:
      - app1000.yaml
  cluster1:
     values:
       - cluster1.yaml
  cluster2:
     values:
       - cluster2.yaml

I have a handful of clusters, but hundreds of apps. Each release of an app definitely has "helmfile-environment" vars specific to an "app" but some of them while consumed by an app's chart, are more logically grouped and specific to a cluster. Being able to do it this way would let me be a bit more DRY.

CURRENT WORKAROUND

NOTE: currently I can achieve this as similar to the below, it works but not ideal as I have to set an ENV var then use that as a dynamic key to fetch it from a "clusters" dict (i.e. via sprig values)

export CLUSTER_NAME=cluster1; helmfile -f myhelmfile.yaml -e app1 apply

myhelmfile.yaml

bases:
  - environments.yaml
---

{{- $clusterEntry := pick .Environment.Values.clusters (env CLUSTER_NAME) }}
{{- $cluster := values $clusterEntry | first }}

releases:
  - name: myapp
    namespace: default
    chart: stable/nginx-ingress
    values:
      -  someArgument: {{$cluster.name}}
          anotherArgument {{.Environment.app.setting1}}

environments.yaml

environments:
  app1:
    values:
      - app1.yaml
      - allclusters.yaml
  app2:
    values:
      - app2.yaml
      - allclusters.yaml
  ...
  app1000:
    values:
      - app1000.yaml
      - allclusters.yaml
 

allclusters.yaml

clusters:
  cluster1:
     name: xxxxxx
     ...
   cluster2:
     ....

potentially related to #361

@mumoshu
Copy link
Collaborator

mumoshu commented May 31, 2019

@bitsofinfo Thanks!

My understanding is that this use-case can be addressed with the latest proposal made in #361, with:

values:
- allclusters.yaml

environments:
  app1:
    values:
      - app1.yaml
  app2:
    values:
      - app2.yaml
  ...
  app1000:
    values:
      - app1000.yaml

For app1, .Values is allclusters.yaml + app1.yaml, wheres the latter merges into the former.

Am I correct?

@bitsofinfo
Copy link
Contributor Author

perfect, then that will provide basically the same thing! cool

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

2 participants