-1

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
  1. With the HTTP resource defined in the base, it is not loaded when I build the overlay. What is wrong with my setup?
  2. 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 via kind and name. Why does this fail? Is it because the HTTP resource is defined in the kustomization.yaml of the parent directory to foo? 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.
Boon
  • 1,073
  • 1
  • 16
  • 42
  • This sort of question is a lot easier to answer if it includes a [mcve]. Use real data, rather than fake/obfuscated links. If you can't show the actual repository, then create one (or a gist!) with sample data sufficient to reproduce the problem. – larsks Mar 28 '23 at 16:22

1 Answers1

0

You're including the remote http://... resource in base/kustomization.yaml, but in overlay/foo/kustomization.yaml you are explicitly including ../../base/foo...so you completely bybass ../../base/kustomization.yaml.

That's why you don't see the remote resource in your output.

larsks
  • 277,717
  • 41
  • 399
  • 399