I have a Kustomize v5.0.0 project with the following layout:
├── base
│ ├── kustomization.yaml
│ ├── foo
│ ├── kustomization.yaml
│
│
└── overlay
├── kustomization.yaml
├── foo
├── kustomization.yaml
├── deployment-patch.yaml
In base/kustomization.yaml
I define a HTTP resource and the subdirectory where I have a specific new app for the overall environment. The plan is to add more apps, hence these subdirs:
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- https://raw.githubusercontent.com/acme/myproject/v1.2.3/manifest.yaml
- foo
In base/foo
I define a new manifest such as an ingress that I add to the environment contained within the HTTP resource.
In overlay/kustomization.yaml
I reference the overlay subdirs as such:
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- foo
In overlay/foo/kustomization.yaml
I reference the base and include an environment-specific patch (dev vs. prod etc.). The deployment in question is in the HTTP resource and has a unique name (there is no other deployment with the same name).
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../base/foo
patches:
- target:
kind: Deployment
name: some-unique-name
path: deployment-patch.yaml
- With the HTTP resource defined in the base, it is not loaded when I build the overlay. What is wrong with my setup?
- If I move the HTTP resource into
overlay/kustomization.yaml
and comment out the patch instruction, then I can see the HTTP resource is loaded. However, including the patch gives the error:... failed to find unique target for patch ...
. The deployment information in the patch matches a unique deployment in the HTTP resource viakind
andname
. Why does this fail? Is it because the HTTP resource is defined in thekustomization.yaml
of the parent directory tofoo
? I created the structure I have as I will have multiple overlays for different environments, and in each I will have patches for different applications, each defined in a separate child directory of the overlay directory.