Helmfile: Unable to matches specified selector() and environment(master), in any helmfile when using Helmfiles

Created on 19 Jun 2019  路  5Comments  路  Source: roboll/helmfile

I'm trying to make my helmfiles DRY

helmfile.yaml

helmfiles:
- apps/99_monitor.yaml

apps/99_monitor.yaml

bases:
- ../common/environments.yaml
- ../common/repositories/kubernetes.yaml
- ../common/helmdefaults.yaml

{{ readFile "../common/templates.yaml" }}

releases:
  - name: gitlab-{{ .Environment.Name }}-branch-fluent-bit
    chart: stable/fluent-bit
    version: ~1.8.0
    values:
      - "../environments/{{ `{{ .Environment.Name }}` }}/gitlab-{{ `{{ .Environment.Name }}` }}-branch-fluent-bit.yaml"
    <<: *default

If I lint charts, using apps/99_monitor.yaml I've no errors:

$ helmfile -e master --log-level debug -f apps/99_monitor.yaml lint                                                      
processing file "99_monitor.yaml" in directory "apps"
changing working directory to "/home/jjmartres/Desktop/deploy/apps"
first-pass rendering starting for "99_monitor.yaml.part.0": inherited=&{master map[] map[]}, overrode=<nil>
first-pass uses: &{master map[] map[]}
first-pass produced: &{master map[] map[]}
first-pass rendering result of "99_monitor.yaml.part.0": {master map[] map[]}
vals:
map[]
defaultVals:[]
second-pass rendering result of "99_monitor.yaml.part.0":
 0: environments:
 1:   master:
 2:   review:
 3: 

merged environment: &{master map[] map[]}
first-pass rendering starting for "99_monitor.yaml.part.1": inherited=&{master map[] map[]}, overrode=<nil>
first-pass uses: &{master map[] map[]}
first-pass produced: &{master map[] map[]}
first-pass rendering result of "99_monitor.yaml.part.1": {master map[] map[]}
vals:
map[]
defaultVals:[]
second-pass rendering result of "99_monitor.yaml.part.1":
 0: repositories:
 1:   - name: kubernetes-charts
 2:     url: https://kubernetes-charts.storage.googleapis.com/
 3: 

merged environment: &{master map[] map[]}
first-pass rendering starting for "99_monitor.yaml.part.2": inherited=&{master map[] map[]}, overrode=<nil>
first-pass uses: &{master map[] map[]}
first-pass produced: &{master map[] map[]}
first-pass rendering result of "99_monitor.yaml.part.2": {master map[] map[]}
vals:
map[]
defaultVals:[]
second-pass rendering result of "99_monitor.yaml.part.2":
 0: helmDefaults:
 1: #  args:
 2: #    - "--debug"
 3: #   Differents contexts: https://www.reddit.com/r/kubernetes/comments/am5mcq/helmfile_how_to_deal_with_different_versions_in/
 4: 

merged environment: &{master map[] map[]}
first-pass rendering starting for "99_monitor.yaml.part.3": inherited=&{master map[] map[]}, overrode=<nil>
first-pass uses: &{master map[] map[]}
could not deduce `environment:` block, configuring only .Environment.Name. error: failed to read 99_monitor.yaml.part.3: reading document at index 1: yaml: unknown anchor 'default' referenced
error in first-pass rendering: result of "99_monitor.yaml.part.3":
 0: 
 1: 
 2: releases:
 3:   - name: gitlab-master-branch-fluent-bit
 4:     chart: stable/fluent-bit
 5:     version: ~1.8.0
 6:     values:
 7:       - "../environments/{{ .Environment.Name }}/gitlab-{{ .Environment.Name }}-branch-fluent-bit.yaml"
 8:     <<: *default
 9: 

first-pass produced: &{master map[] map[]}
first-pass rendering result of "99_monitor.yaml.part.3": {master map[] map[]}
second-pass rendering result of "99_monitor.yaml.part.3":
 0: templates:
 1:   default: &default
 2:     namespace: "gitlab-{{ `{{ .Environment.Name }}` }}-branch"
 3:     atomic: true
 4:     missingFileHandler: Warn
 5:     recreatePods: true
 6:     wait: true
 7: 
 8: 
 9: releases:
10:   - name: gitlab-master-branch-fluent-bit
11:     chart: stable/fluent-bit
12:     version: ~1.8.0
13:     values:
14:       - "../environments/{{ .Environment.Name }}/gitlab-{{ .Environment.Name }}-branch-fluent-bit.yaml"
15:     <<: *default
16: 

merged environment: &{master map[] map[]}
Adding repo kubernetes-charts https://kubernetes-charts.storage.googleapis.com/
exec: helm repo add kubernetes-charts https://kubernetes-charts.storage.googleapis.com/
exec: helm repo add kubernetes-charts https://kubernetes-charts.storage.googleapis.com/: "kubernetes-charts" has been added to your repositories

"kubernetes-charts" has been added to your repositories

Updating repo
exec: helm repo update
exec: helm repo update: Hang tight while we grab the latest from your chart repositories...
...Skip local chart repository
...Successfully got an update from the "anasen" chart repository
...Successfully got an update from the "gitlab" chart repository
...Successfully got an update from the "kubernetes-charts" chart repository
...Successfully got an update from the "stable" chart repository
...Successfully got an update from the "bitnami" chart repository
Update Complete.

Hang tight while we grab the latest from your chart repositories...
...Skip local chart repository
...Successfully got an update from the "anasen" chart repository
...Successfully got an update from the "gitlab" chart repository
...Successfully got an update from the "kubernetes-charts" chart repository
...Successfully got an update from the "stable" chart repository
...Successfully got an update from the "bitnami" chart repository
Update Complete.

worker 1/1 started
Fetching stable/fluent-bit
exec: helm fetch stable/fluent-bit --version ~1.8.0 --untar --untardir /tmp/085914238/gitlab-master-branch-fluent-bit/~1.8.0/stable/fluent-bit
exec: helm fetch stable/fluent-bit --version ~1.8.0 --untar --untardir /tmp/085914238/gitlab-master-branch-fluent-bit/~1.8.0/stable/fluent-bit: 
worker 1/1 finished
successfully generated the value file at ../environments/master/gitlab-master-branch-fluent-bit.yaml. produced:
backend:
  type: es
  es:
    host: elasticsearch-client.namespace.svc.cluster.local
    port: 9200
    index: master_branch
    logstash_prefix: master_branch

Linting /tmp/085914238/gitlab-master-branch-fluent-bit/~1.8.0/stable/fluent-bit/fluent-bit
exec: helm lint /tmp/085914238/gitlab-master-branch-fluent-bit/~1.8.0/stable/fluent-bit/fluent-bit --namespace gitlab-{{ .Environment.Name }}-branch --values /tmp/values179823557
exec: helm lint /tmp/085914238/gitlab-master-branch-fluent-bit/~1.8.0/stable/fluent-bit/fluent-bit --namespace gitlab-{{ .Environment.Name }}-branch --values /tmp/values179823557: ==> Linting /tmp/085914238/gitlab-master-branch-fluent-bit/~1.8.0/stable/fluent-bit/fluent-bit
Lint OK

1 chart(s) linted, no failures

==> Linting /tmp/085914238/gitlab-master-branch-fluent-bit/~1.8.0/stable/fluent-bit/fluent-bit
Lint OK

1 chart(s) linted, no failures

But If I lint charts using helmfile.yaml I got the following error:

$ helmfile -e master --log-level debug lint       
processing file "helmfile.yaml" in directory "."
first-pass rendering starting for "helmfile.yaml.part.0": inherited=&{master map[] map[]}, overrode=<nil>
first-pass uses: &{master map[] map[]}
first-pass produced: &{master map[] map[]}
first-pass rendering result of "helmfile.yaml.part.0": {master map[] map[]}
vals:
map[]
defaultVals:[]
second-pass rendering result of "helmfile.yaml.part.0":
 0: helmfiles:
 1: - ./apps/99_monitor.yaml
 2: 

err: no releases found that matches specified selector() and environment(master), in any helmfile

What's going wrong ?

Most helpful comment

I found a bug that is causing helmfile to return the confusing error. It should emit in ./helmfile.yaml: failed to read helmfile.yaml: environment "master" is not defined, which will make it more obvious. I'll submit a PR for that shortly.

Do you think we need to fix somewhere else, like allowing subhelmfiles-only helmfile.yaml to omit environments?

All 5 comments

@jjmartres Ah, good catch! I believe it's complaining because the helmfile.yaml misses master environment. n the meantime, could you add environments to helmfile.yaml as well as the subhelmfile?

I found a bug that is causing helmfile to return the confusing error. It should emit in ./helmfile.yaml: failed to read helmfile.yaml: environment "master" is not defined, which will make it more obvious. I'll submit a PR for that shortly.

Do you think we need to fix somewhere else, like allowing subhelmfiles-only helmfile.yaml to omit environments?

I am seeing the same issue. My setup is similar to the above except bases only includes two files e.g.

bases:
- ../common/environments.yaml
- ../common/helmdefaults.yaml

I've found if I remove helmdefaults.yaml from the list of bases it works.

I was seeing this issue when the paths to bases was incorrect and it couldn't find anything to deploy.

seems like release name should be equal to chart name, if you put something different in a chart key you'll get above error

  • name: test
    chart: charts/test
Was this page helpful?
0 / 5 - 0 ratings

Related issues

cilerler picture cilerler  路  4Comments

mumoshu picture mumoshu  路  4Comments

RafalMaleska picture RafalMaleska  路  3Comments

madAndroid picture madAndroid  路  3Comments

marianogg9 picture marianogg9  路  3Comments