-
Notifications
You must be signed in to change notification settings - Fork 893
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
Can't compose generated Kustomizations - due to use of vars #1007
Comments
Issue Label Bot is not confident enough to auto-label this issue. |
Related issue: /issues/774 |
This is one of the disadvantages of vars as noted in: kubernetes-sigs/kustomize#2052 Our biggest use case for vars is for substituting namespace and clusterDomain into virtual services (example). As suggested in kubernetes-sigs/kustomize#205 using creating plugins for virtual services might be a better long term option. We could define a VirtualService transformer similar to the built in image transformer A custom transformer would allow users to add a virtualServices section to their kustomization.yaml files to change hosts; e.g.
|
After renaming all vars to be unique across kustomizations, I am seeing now that the same problem exists with configMapGenerator, too. Multiple kustomizations declare a configMapGenerator called "parameters", but the content is different among all of them! I don't understand how this is supposed to work? How can Kubeflow generate the same resource twice, with different content, and still have a predictable result? Example error:
|
This is a bug in how our kustomize manifests are structured right now. The way our kustomize manifests are structured doesn't support composing the individual applications. This works because the params configMapGenerator is doing client side (using kustomize) substitution of vars into manifests. So it doesn't depend on the config map being unique across applications. There's ongoing work to clean this up. I'll send out a doc this week or next about fixing some of our patterns. There's an example PR: #962 |
Anyone interested in exploring a custom transformer/plugin to replace virtual services? Maybe take a look at the example replacement transformer |
kpt setters might provide another option for making it easy for folks to change the cluster domain. Is it possible to use kpt setters in a manner compatible with people still using global vars? i.e. could we just set the default value for the setter to "$(clusterDomain)" so that people using kpt setters can change it easily. |
@kkasravi what is "this" referring to? Is it kpt setters for clusterDomain?
We currently have two use cases for vars
For the second use case vars seem like an ok solution. Since the var is local to the package we can just give it a unique enough name so it is unlikely to conflict with vars from other packages. For #1 I think kpt setters might be a better solution then vars. I suspect we will likely go the route of using kpt setters on GCP as kpt is becoming a standard tool for GCP (e.g. you can install it with gcloud). But I don't intend to mandate the use of kpt. If your curious I've been experimenting with deploying KF using kpt on GCP here |
An alternate to kpt is kustomize functions which are invoked like |
Here is one nice use of kustomize functions |
Thanks @kkasravi any solution which requires running a docker image or installing a plugin (".so") seems less preferable to me than a method which just relies on out of box functionality in stock tools like kustomize or kpt.
Right now I think we only have 1-2 global vars see here
Both of which are used to configure virtual services like so I'd like to get rid of those 2 dependencies on global vars. For clusterDomain this feels like a really good use case for kpt setters
Note: There is a new (backwards compatible) way of creating setters in kpt that is more powerful https://googlecontainertools.github.io/kpt/guides/producer/substitutions/ For namespace, I'm not really sure that needs to be a global var. It looks like in that case we are just using vars to do trick kustomize into substituting namespace into a field kustomize isn't normally aware of. I think in that case we can just make the var names unique enough per package (e.g. "jupyter-web-app-namespace") so they won't conflict when applications are composed. |
It looks like another use case for global vars is |
Issue-Label Bot is automatically applying the labels:
Please mark this comment with 👍 or 👎 to give our bot feedback! |
@kkasravi Have you had a chance to check whether we can easily add KPT annotations that are backwards compatible with vars substitutions? |
It looks like kustomize on master now has an alpha I haven't checked if this functionality has made it into any of the existing releases. It does not appear to be in kustomize 3.2.1
|
@kkasravi You were right about It looks like |
Closing this out because there is no clear work remaining. I think we might still need to figure out a better solution for clusterDomain and namespace. Lets file a separate more specific issue for that if need be. |
Due to the use of "vars" in the generated kustomizations, it's not possible to compose the generated kustomizations together in order to use
kubectl -k
to deploy the whole thing plus additional variant info like env-specific stuff. If you do, errors such as "var clusterDomain already encountered" and "error: found 2 resId matches for var {project ~G_v1_ConfigMap {data.project}} (unable to disambiguate)" occur.Can all use of vars be removed to prevent this issue?
I am new to Kustomize, so I may be misunderstanding how this stuff should work. But, the var problem is making it difficult to figure out how to maintain kustomizations in source control with additional layers for environment-specific stuff.
kfctl
by itself doesn't provide any mechanism for user-level additions/changes, without manually modifying the output every time it's regenerated (not desirable). It seems like for now I may have to maintain a separate kustomization.yaml for each generated kustomization, so that I can apply a shared base and/or any env-specific config. I guess this means that if I have 36 generated kustomizations, that I need to have36 * (env count)
individual kustomization files to provide env-specific concerns? If so, this is not a very practical approach.The text was updated successfully, but these errors were encountered: