-
Notifications
You must be signed in to change notification settings - Fork 169
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
Add server-side apply mode #651
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the server-side the default in kubectl (from 1.22)? If not, can we make it optional on Tanka too?
It's intended to be a general replacement for any client-side apply, but I don't know of any active plans to make it the default for kubectl in particular. I've moved it to be an optional field in spec.json, still defaulting to the normal apply. |
docs/docs/server-side-apply.md
Outdated
many can be found before an apply with the `validate` | ||
[diff strategy](/diff-strategy). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR already looks great.
It may be a little out-of-scope but I was wondering whether we should make this consistent for both diff and apply.
tk diff
could also honor the applyStrategy
option if set in spec.json and it could have a CLI flag (replacing diff-strategy=validate): tk diff --diff-strategy=native --server-side
(native is the default strategy)
@julienduchesne do you think this makes sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think --diff-strategy=validate
should be renamed (or aliased) to --diff-strategy=server
, that would be consistent enough IMO. Having both a --server-side
and a --(diff|apply)-strategy
might get confusing.
Also, the diffStrategy
and applyStrategy
settings are nice since you can toggle them independently in the spec (someone may wish to apply server-side but do a simple diff, or vice-versa, server-side sometimes has a weird behavior)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would add the --apply-strategy
flag for consistency between apply
and diff
. Other than that, this PR looks great!
docs/docs/server-side-apply.md
Outdated
many can be found before an apply with the `validate` | ||
[diff strategy](/diff-strategy). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think --diff-strategy=validate
should be renamed (or aliased) to --diff-strategy=server
, that would be consistent enough IMO. Having both a --server-side
and a --(diff|apply)-strategy
might get confusing.
Also, the diffStrategy
and applyStrategy
settings are nice since you can toggle them independently in the spec (someone may wish to apply server-side but do a simple diff, or vice-versa, server-side sometimes has a weird behavior)
@julienduchesne @Duologic I ended up adding a 4th distinct diff mode called I also added the |
Hi, this MR would solve a lot of issue for us too, when can we expect it to land in master ? |
The changes look good to me overall (I'd like to look more in-depth though) |
7502209
to
dfbd174
Compare
Hi!
OMG yes, finally! Before doing an in-depth code review, I got some general questions.
|
I think I can answer those
The output is very different between a bare diff and
That would be kind of breaking. For our own workflows, we'd have to explicitely disable it to get more readable diffs. Also, server-side diff will break on certain manifests that diff and apply just fine in non server-side mode |
Hi, any progress on this ? |
I've been using this for a while without issue and would still like to see it get merged. If that last commit to fix pruning complicates things, I can split it out into a separate PR. |
Hi, is there any progress on this? it would be quite useful for us to have this feature |
Sorry for the lack of communication on this @smuth4. The other PR sneaked by due it being much smaller. If you still need the config attributes, feel free to rebase and @ me, I'll be sure to take a look this time |
1 similar comment
Sorry for the lack of communication on this @smuth4. The other PR sneaked by due it being much smaller. If you still need the config attributes, feel free to rebase and @ me, I'll be sure to take a look this time |
I much prefer @smuth4 approach, as it's much more sustainable re: future kubectl apply/diff args, totally fine to rollback #695 (the sooner the better). |
Also mark the field manager as being tanka
Also add --diff-strategy flag to `apply`
Thanks for the responses, I've rebased it with the flag rolled back, and if it gets rolled back separately I don't mind rebasing again. @julienduchesne I think this is pretty much ready for review. There might be room for improvement in cases where a Edit: Immediately after typing that, I realized that I'm incorrect, it would be a problem for anyone who wants to use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright! Let's try this out! Thanks for your work @smuth4!
Aside from all the benefits listed elsewhere, this would fix issues like prometheus-operator/kube-prometheus#1511.
While testing I did find that it's not entirely a clean conversion when working with objects that have already been applied client-side. Non-functional formatting differences (e.g. "1024Mi" vs "1Gi") or missing default fields will cause the apply to fail and report that it has a field management conflict with "kubectl-client-side-apply". Once a server-side apply succeeds (either by recreating the object or by using
--force-conflicts
) everything works as expected, just wanted to mention it since it was a bit surprising.I also kept the code simple as a POC, if desired I can make it a flag similar to
--diff-strategy
.