kustomize: HelmChartInflationGenerator does not work when building outside kustomization dir

Describe the bug

In kustomization 3.9.1 it is not possible to use HelmChartInflationGenerator when building outside files’ dir.

Files that can reproduce the issue

# kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
generators:
  - generators.yaml
# generators.yaml
apiVersion: builtin
kind: HelmChartInflationGenerator
metadata:
  name: xxx
chartName: ingress-nginx
chartRepoUrl: https://kubernetes.github.io/ingress-nginx
values: myvalues.yaml
# myvalues.yaml
nameOverride: foobar

Expected output

kustomize build should indeed render this chart as it does when invoked in kustomization.yaml’s dir

Actual output

kustomize build kusto
Error: Error: open myvalues.yaml: no such file or directory
: failed to run command helm template /tmp/kustomize-448884726/chart/ingress-nginx --values myvalues.yaml

Kustomize version

3.9.1

Platform

linux

Thank you, regards!

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 2
  • Comments: 17 (4 by maintainers)

Most upvoted comments

it does not seems a proper solution to me, in fact --help tell me

To generate the resources specified in 'someDir/kustomization.yaml', run

  kustomize build someDir

The default argument to 'build' is '.' (the current working directory).

so, apart this broken contract, anything that use kustomize as an internal tool (let’s say, argocd), cannot properly use it because workdir is a temporary repo clone whose path we can easily reconstruct by hardcoding it

metadata:
  name: xxx
chartName: ingress-nginx
chartRepoUrl: https://kubernetes.github.io/ingress-nginx
# FIXME: upstream bug
values: /tmp/git@github.com_xxx/foo/bar/baz/anotherdir/yeah_complex/monorepo/staging/values-default.yaml

I don’t think I have to tell you how much this is lame. In fact I’m not doing that, baking a custom argocd image instead with a wrapper.sh that chdir to the first build argument, it’s just a letdown to adopt a tool with such a sloppy QA and it raises many doubts about the goodness of this adoption choice. But who I am at the end 🤷‍♂️ 😃

Ah, also since a relative path does indeed work when kustomize is invoked in the same dir, your answer is probably incorrect either cases. But thank you anyway…

Will take a look.

it obviously does no satisfy the case where you have a base which generate from helm and then you want to last-mile kustomize in overlays, there’s no way to accomplish that ATM

Another quirk I think could definitely related to this bug: I have a base where I inflate some helm charts, keeping overlays to do last mile modifications:

oggei@cane $  tree
.
├── base
│   ├── ingress-generator.yaml
│   ├── kustomization.yaml
│   ├── values-cs.yaml
│   ├── values-default.yaml
│   └── values-nlb.yaml
└── prod-1
    └── kustomization.yaml

so base/kustomization.yaml has:

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
generators:
  - ingress-generator.yaml

with all the stuff, and prod-1/kustomization.yaml only has:

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../base

Now if i build base, everything goes as expected, but if I try to build prod-1:

oggei@cane $  kustomize build prod-1
Error: accumulating resources: 2 errors occurred:
        * accumulateFile error: "accumulating resources from '../base': '/home/oggei/dev/[REDACTED]/applications/nginx-ingress-controller/base' must resolve to a file"
        * accumulateDirector error: "recursed accumulation of path '/home/oggei/dev/[REDACTED]/applications/nginx-ingress-controller/base': Error: open values-default.yaml: no such file or directory\n: failed to run command helm template default /tmp/kustomize-809617376/chart/ingress-nginx --namespace ingress --values values-default.yaml"

If I copy values file in prod-1, then build works, but definitely defeat the design all these shenanigans are intended to support 😃

HTH, ciao!