'How to share resources/patches with multiple overlays using kustomize?

I have a kube-prometheus deployed to multiple environments using kustomize.

kube-prometheus is a base and each environment is an overlay. Let's say I want to deploy dashboards to overlays, which means I need to deploy the same ConfigMaps and the same patch to each overlay.

Ideally, I want to avoid changing the base as it is declared outside of my repo and to keep things DRY and not to copy the same configs all over the place.

Is there a way to achieve this?

Folder structure:

/base/
     /kube-prometheus/
/overlays/
     /qa/       <--- 
     /dev/      <--- I want to share resources+patches between those
     /staging/  <---



Solution 1:[1]

In your main kustomization, or some top-level overlay, you should be able to call for a common folder or repository.

Have you tried something like this:

resources:
  - github.com/project/repo?ref=x.y.z

If this doesn't answer your question, could you please edit your post and give us some context?

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 SYN