Merging remote kustomize resources

Hi,

I’ve been refactoring my repositories with the intention of segregating what can be public and what shouldn’t and I’ve hit a wall. I’m trying to split up my k8 manifests or extract parts of them into a private repository.

I’ve been attempting to do this using Kustomize’s remote feature where I would have a remote resource or patch that would modify the root manifests. However, with either strategy I can’t seem to get them to work.

With the strategy where I have remote patches the setup looks like this.

kubernetes/apps/app1/kustomize.yaml (public.git)

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
  - deployment.yaml
  - https://github.com/<username>/private.git/kubernetes/apps/app1

kubernetes/apps/app1/kustomize.yaml (private.git)

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

patches:
  - path: deployment.patch.yaml

With this method I get the error “failed to find unique target for patch”

With the method where I have a remote resource, this is the setup

kubernetes/apps/app1/kustomize.yaml (public.git)

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
  - deployment.yaml
  - https://github.com/<username>/private.git/kubernetes/apps/app1

kubernetes/apps/app1/kustomize.yaml (private.git)

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
  - deployment.yaml

With this method I get the error “may not add resource with an already registered id”

Both of these errors are leading me to think that for remote resources, the remote resource itself is treated and processed as an isolated kustomize build.

If there’s a better way to achieve what I’m attempting feel free to suggest it.

Thanks.

1 Like