-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for variable replacement in literals #1737
Comments
Dupe of: #318. It would probably be best if you avoided this rabbit hole and just used envsubst instead. |
At this point a real contribution around vars to this project would be a PR that adds loudly to the documentation how broken vars are and encourages folks to consider this responsibility (var handling, any sort of templating at all) outside the scope of kustomize. |
I'm not sure I understand, but I'm not really very deep in any rabbit hole right now. Maybe you can spare some time to explain a bit more to someone who doesn't have as good an understanding of how kustomize works. My reading of #318 was that it is about something different (I did find that one before I opened this issue). Isn't it? It says it's about literals as the value of vars. Maybe it morphed into something else and I didn't spot it. I'm afraid reading the whole of #1620 and #1600 didn't help me either to understand the problem better or solve it. I would appreciate any help anyone can give getting my example to work (i.e. extracting a service name, which is actually needed by another deployment, and has been generated by kustomize, so I don't know what it is in advance). I doubt I can do that with envsubst, but I'm open to being educated. |
Variables are only "bound" in the output resources as a final step after the top level build has finished, even if declared in a child build. What this means is that any variables that are "consumed" by transformers/generators as input that don't have a direct representation in the final output are never substituted. We are preparing a PR which binds variables immediately where the variable is declared, which will only help sin your scenario if you create a separate resources for the transformer and process them as resources first that have the vars you want substituted. |
Here is a transformer we created that does kustomize child level build var substitution. It has some examples. PR just pushed here: #1738 |
@dsyer actually, in your example the literal does get passed through but its not included in the varRefences. You need to create a configuration with a new varReferences that contains the kind 'ConfigMap' and path to your variable.
kustomization.yaml:
|
That was helpful, and I didn't understand your first comment at all, so thanks for taking the time. If anyone else is trying it, I think varReference:
- path: data/MYSQL_HOST
kind: ConfigMap |
@dsyer @bkuschel Have a look at that example. We did withdraw the PRs solving the needs you are describing the day we were told that VAR will be removed altogether from kustomize support. Famous and very simple #506 use case is also solved too: https://github.com/keleustes/kustomize/tree/allinone/examples/issues/issue_0506. Now we are waiting for the "replacement" PR to work, what is interesting it has fundamentally the exact same issue on when to resolve the "replacement/inline": at the local kustomization context or the local. Until then we have to maintain a fork that allows us to do things, not spend ages working around kustomize limitation or have kustomization.yaml which are too big to manage. |
@dsyer sorry for the ramble. Basically secretGenerator will not work for your example. |
@jbrette The variable collision problem is a consequence of the current design, which only declares the binding and doesn’t do the substitution at the child build level, only at the very end. So, which binding to use is not a problem if you substitute the value where the binding is declared and reconcile the values further upstream. (Using name reference substitution, for example) |
Issues go stale after 90d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
Stale issues rot after 30d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
Rotten issues close after 30d of inactivity. Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
@fejta-bot: Closing this issue. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/reopen This project really needs to be removed from kubectl if it is not under active development. |
@tkellen: You can't reopen an issue/PR unless you authored it or you are a collaborator. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Currently, to get an env var to point to a service name, I have to do this (which makes the k8s resource into a template - the famous anti-pattern that no-one wanted but we ended up with anyway):
I also had to create an
env
entry in my Deployment that I didn't really want - I prefer to use a ConfigMap. What I would like is to put that placeholder inkustomization.yaml
via a literal (or similar):The
vars
can even go in the base if I don't want it here.The text was updated successfully, but these errors were encountered: