Skip to content

Instantly share code, notes, and snippets.

@seanorama
Last active August 20, 2022 03:51
Show Gist options
  • Save seanorama/7640609952b6999b23b761678d226784 to your computer and use it in GitHub Desktop.
Save seanorama/7640609952b6999b23b761678d226784 to your computer and use it in GitHub Desktop.
helmfile `jsonPatches` does not work with packaged (e.g. tgz) charts

helmfile jsonPatches does not work with packaged (e.g. tgz) charts

It fails for local file-system or remote packaged charts, but they return different errors (see below).

The errors appear to be from chartify.

It works if the package is extracted and chart used from the directory: chart: ./datadog/.

Steps to reproduce

Using local and packaged chart:

$ wget https://github.com/DataDog/helm-charts/releases/download/datadog-2.37.4/datadog-2.37.4.tgz

$ helmfile list ## or any other command: template, diff, ...
processing file "helmfile.yaml" in directory "."
changing working directory to "/Users/seanroberts/Projects/SRE/compute-monitoring-k8s-live/compute-monitoring-dev/cdp-saas-monitoring/datadog"
first-pass rendering starting for "helmfile.yaml.part.0": inherited=&{default map[] map[]}, overrode=<nil>
first-pass uses: &{default map[] map[]}
first-pass rendering output of "helmfile.yaml.part.0":
 0: releases:
 1: - name: test
 2:   namespace: test
 3:   chart: ./datadog-2.37.4.tgz
 6:   jsonPatches:
 7:     - target:
 8:         kind: ServiceAccount
 9:         name: test-datadog
10:       patch:
11:         - op: add
12:           path: /metadata/annotations
13:           value:
14:             foo: bar
15:
16:

first-pass produced: &{default map[] map[]}
first-pass rendering result of "helmfile.yaml.part.0": {default map[] map[]}
vals:
map[]
defaultVals:[]
second-pass rendering result of "helmfile.yaml.part.0":
 0: releases:
 1: - name: test
 2:   namespace: test
 3:   chart: ./datadog-2.37.4.tgz
 6:   jsonPatches:
 7:     - target:
 8:         kind: ServiceAccount
 9:         name: test-datadog
10:       patch:
11:         - op: add
12:           path: /metadata/annotations
13:           value:
14:             foo: bar
15:
16:

merged environment: &{default map[] map[]}
helm:kIzDc> v3.9.3+g414ff28
Chartify process for datadog-2.37.4.tgz
Removed /var/folders/qq/fsd4t7296kb7gykt3q473zzm0000gn/T/helmfile97982197/test-test-values-5779b9fcd9
err: [stat datadog-2.37.4.tgz/kustomization.yaml: not a directory]
changing working directory back to "/Users/seanroberts/Projects/SRE/compute-monitoring-k8s-live/compute-monitoring-dev/cdp-saas-monitoring/datadog"
Error: in ./helmfile.yaml: [stat datadog-2.37.4.tgz/kustomization.yaml: not a directory]
in ./helmfile.yaml: [stat datadog-2.37.4.tgz/kustomization.yaml: not a directory]

Using remote (http, s3, repo) and packaged chart:

$ helmfile --debug list
processing file "helmfile.yaml" in directory "."
changing working directory to "/Users/seanroberts/Projects/SRE/compute-monitoring-k8s-live/compute-monitoring-dev/cdp-saas-monitoring/datadog"
first-pass rendering starting for "helmfile.yaml.part.0": inherited=&{default map[] map[]}, overrode=<nil>
first-pass uses: &{default map[] map[]}
first-pass rendering output of "helmfile.yaml.part.0":
 0: releases:
 1: - name: test
 2:   namespace: test
 4:   chart: https://github.com/DataDog/helm-charts/releases/download/datadog-2.37.4/datadog-2.37.4.tgz
 6:   jsonPatches:
 7:     - target:
 8:         kind: ServiceAccount
 9:         name: test-datadog
10:       patch:
11:         - op: add
12:           path: /metadata/annotations
13:           value:
14:             foo: bar
15:
16:

first-pass produced: &{default map[] map[]}
first-pass rendering result of "helmfile.yaml.part.0": {default map[] map[]}
vals:
map[]
defaultVals:[]
second-pass rendering result of "helmfile.yaml.part.0":
 0: releases:
 1: - name: test
 2:   namespace: test
 4:   chart: https://github.com/DataDog/helm-charts/releases/download/datadog-2.37.4/datadog-2.37.4.tgz
 6:   jsonPatches:
 7:     - target:
 8:         kind: ServiceAccount
 9:         name: test-datadog
10:       patch:
11:         - op: add
12:           path: /metadata/annotations
13:           value:
14:             foo: bar
15:
16:

merged environment: &{default map[] map[]}
helm:HQRpz> v3.9.3+g414ff28
Chartify process for https:/github.com/DataDog/helm-charts/releases/download/datadog-2.37.4/datadog-2.37.4.tgz
running helm fetch https://github.com/DataDog/helm-charts/releases/download/datadog-2.37.4/datadog-2.37.4.tgz --untar -d /var/folders/qq/fsd4t7296kb7gykt3q473zzm0000gn/T/chartify3730535978/test/test
Removed /var/folders/qq/fsd4t7296kb7gykt3q473zzm0000gn/T/helmfile4201925598/test-test-values-64b7588948
err: [1 additional files found in temp direcotry. This is very strange]
changing working directory back to "/Users/seanroberts/Projects/SRE/compute-monitoring-k8s-live/compute-monitoring-dev/cdp-saas-monitoring/datadog"
Error: in ./helmfile.yaml: [1 additional files found in temp direcotry. This is very strange]
in ./helmfile.yaml: [1 additional files found in temp direcotry. This is very strange]

Expected behavior

It works if extracted to a directory:

$ tar -xzf datadog-2.37.4.tgz
$ releases:
- name: test
  namespace: test
  chart: ./datadog/
  jsonPatches:
    - target:
        kind: ServiceAccount
        name: test-datadog
      patch:
        - op: add
          path: /metadata/annotations
          value:
            foo: bar

$ helmfile list
NAME	NAMESPACE	ENABLED	INSTALLED	LABELS	CHART     	VERSION
test	test     	true   	true     	      	./datadog/

And works if used from a repo:

$ cat helmfile.yaml
repositories:
- name: datadog
  url: https://helm.datadoghq.com

releases:
- name: test
  namespace: test
  chart: datadog/datadog
  jsonPatches:
    - target:
        kind: ServiceAccount
        name: test-datadog
      patch:
        - op: add
          path: /metadata/annotations
          value:
            foo: bar

$ helmfile list
NAME	NAMESPACE	ENABLED	INSTALLED	LABELS	CHART          	VERSION
test	test     	true   	true     	      	datadog/datadog

Or if jsonPatches is removed, the error does not occur under any scenario:

$ cat helmfile.yaml
releases:
- name: test
  namespace: test
  chart: ./datadog-2.37.4.tgz

$ helmfile list
NAME	NAMESPACE	ENABLED	INSTALLED	LABELS	CHART               	VERSION
test	test     	true   	true     	      	./datadog-2.37.4.tgz
releases:
- name: test
namespace: test
chart: ./datadog-2.37.4.tgz
jsonPatches:
- target:
kind: ServiceAccount
name: test-datadog
patch:
- op: add
path: /metadata/annotations
value:
foo: bar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment