Reference secrets from base in overlay

628 views Asked by At

Is there any way in Kustomize to reference a secret, which has been generated and is used in my base, to another resource (e.g. Deployment or StatefulSet) in my overlay? I face the problem, that all occurences of the secrets name are replaced by the hashed name only in the base and not in my overlay.

I guess that there is now way around this problem, but maybe someone has a hint for me.

1

There are 1 answers

0
ITChap On BEST ANSWER

You're right that's one of the limitations of the generators (both Secret and ConfigMap): They can only update resources included in their kustomization.yml file. By the way it works even if the resources included themselves include other resources. For example, having a base, overlayA that include the base and overlayB that includes overlayA:

  • any secret generated in the base will update its references on any resources created by the base
  • any secret generated in overlayA will update references in resources created in overlayA and base
  • finally any secret generated in overlayB will update references in base, overlayA and overlayB

Personally, I try to keep all my secrets in the "highest" overlay, since in general they might need to be passed across overlays and are environment dependent anyway.