0

I am trying to run kustomize command in a directory which has an overlay kustomization.yaml

When I run kubectl kustomize edit set namespace test in that dir, I get

error: specify one path to kustomization.yaml

Whilst when I run kustomize edit set namespace test, it works.

So the problem is when I run use kustomize from kubectl.

Kubectl version is v1.24.2, which has Kustomize Version: v4.5.4

and separately installed Kustomize binary version is v4.5.5

saurabh_garg
  • 86
  • 1
  • 7
  • I feel that `kubectl kustomize` doesn't include all commands of `kustomize` but i didn't find any source/documentation confirming this – saurabh_garg Jul 15 '22 at 16:04

1 Answers1

0

I suspect kubectl kustomize doesn't support sub commands. You should instead create your kustomization.yaml file and simply run kubectl kustomize to generate your manifests. If I recall correctly, until a couple of years ago, the kustomize project was available as a go module which allowed the kubectl developers to include it in their projects and make use of its capabilities. Later, it was moved to the state of being a stand-alone project and no longer offered as a module for developers, and there was no motive to duplicate the efforts by reimplementing the kustomize functionality in programs. Perhaps that's why it was never fully integrated into kubectl and many other projects that try to use it.

Notice that the error says specify one path to kustomization.yaml. This means the command is interpreting your sub command as a path.

You san simply provide this as:

kubectl kustomize <dir of kustomization.yaml>

You can read more about the command and supported flags here.

Note that if you are running kustomize on a directory structure, you will require a kustomization.yaml file in every subdir.

zer0
  • 2,153
  • 10
  • 12
  • So I am already in the overlay directory which has `kustomization.yaml` and then running `kubectl kustomize`. The linked document says "If DIR is omitted, '.' is assumed.", then why it's not honoring it. whilst at the same time `kustomize` works. – saurabh_garg Jul 15 '22 at 15:57
  • Does this directory have any other directories in it? – zer0 Jul 15 '22 at 16:25
  • no, Just `kustomization.yaml` and a json file – saurabh_garg Jul 15 '22 at 16:28
  • Check my updated answer. – zer0 Jul 15 '22 at 16:32
  • Yeah, I also suspect that this might be the case. Though I didn't find any source to confirm this – saurabh_garg Jul 18 '22 at 05:58
  • [here](https://kubernetes.io/docs/reference/kubectl/) is a docs reference that talks about this. THis should confirm it, what other source are you looking for? These are updated official docs for `kubectl kustomize`. – zer0 Jul 18 '22 at 15:36