kustomize: Kustomize resource ordering regression
Describe the bug
In Kubeflow, we are using Kustomize v3.2.0 and want to upgrade to v4.0.5: https://github.com/kubeflow/manifests/issues/1797
However, our deployment failed for v4.0.5, while it succeeded for v3.2.0.
This is what happened:
- In later kustomize versions, it orders Admission Webhooks last. Before, they were first.
- Pods are created before the istio injection webhook, thus they don’t get a sidecar.
- Our apps fail because they haven’t been mutated appropriately.
Regression Background
For reference, here is the original issue and PRs that made these changes: https://github.com/kubernetes-sigs/kustomize/issues/821 https://github.com/kubernetes-sigs/kustomize/pull/1104 https://github.com/kubernetes-sigs/kustomize/pull/2459
Issue #821 presents the following scenario, which led to PR #1104:
- User builds cert-manager kustomization, containing a webhook, a deployment and a CR (simplified).
- Apply webhook and deployment.
- Apply CR.
Step (3) fails because the Deployment has not become ready yet. The solution SHOULD be to retry the apply. PR #1104 solution was to order the webhook last, so that it doesn’t mutate/validate the CR. This is false, as it circumvents logic that the application has explicitly declared should be applied to all relevant resources.
Files that can reproduce the issue
Please see: https://github.com/kubeflow/manifests/blob/v1.3-branch/README.md
which includes the example kustomization we use for Kubeflow components.
- Build the
examplekustomization with kustomizev3.2.0, as per the README. - Build the
examplekustomization with kustomizev4.0.5. You will see the WebhookConfigurations ordered last, which causes the issues.
Proposed Solution
Restore the order of Mutating / Validating Webhooks as it was before PR #1104
Kustomize version
v4.0.5
cc’ing authors of the referenced issues and PRs: @donbowman @mgoltzsche @asadali cc @monopole @Shell32-Natsu @pwittrock
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 21 (21 by maintainers)
the original motivation for this has become somewhat moot since the community has moved away from declarative things and into imperative. e.g. istio no longer supports yaml prometheus et al operators now create their crd dynamically.
this leads to a race condition, you cannot apply a system w/ a yaml doc to install prometheus followed by one that sets up a servicemonitor on some other thing. No ordering can fix this (since the order is correct). and, the system will not reconcile to the desire state (since the servicemonitor is rejected as an unknown type).
What is the solution? I dunno, does one call until kustomize; sleep 1; done ?
Did an issue for option 2 get filed?
ack, thanks.
Here’s a list of ordering changes over the last ~2 years
Mostly insertions (i.e. specifying order for a particular resource where there wasn’t an order before).
MutatingWebhookConfigurationwas moved fromorderFirsttoorderLastabout a year ago in #2459ValidatingWebhookConfigurationwas moved toorderLastabout two years ago in #1104#3803 would move them back to
orderFirst.It’s been pretty stable for a year, so making a change now may have consequences for many users. As discussed above, it’s impossible for kustomize to own the answer to ‘correct’ ordering. So let’s close #3803, and leave
legacyalone.Some other options are:
--reorder noneto suppress this sort, and obey FIFO. This works right now.legacysorter accept configuration from thekustomizationfile. user could specifyorderFirstandorderLastin that file (would need someone to write the PR for this).Where is that promise made? It must be retracted. It’s literally impossible right now to make one ordering that can both deploy a working stack to a cluster and universally works for everyone’s custom resources now and in the future.
Generally one needs a grander mechanism which can apply some things, waits for ready, apply more things, etc. Various things are moving in this direction, and would encapsulate kustomize or some other editor.
Thanks for the input @monopole! About:
This may indeed be the case, but it’s a big change, since it effectively changes the current promise of kustomize to manifests developers. If I understand correctly, the current (default) promise is: don’t care about ordering, kustomize will do it for you.
May I suggest the following:
Thanks! Discussing this on the earliest issue you mentioned #821
People can order their inputs to get the desired output order, which may be the only answer.
There’s no one ordering that makes sense for everyone, since no ordering can take custom resources into account.