-
Notifications
You must be signed in to change notification settings - Fork 40k
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
Proposal: Enable purging resources in kubectl apply
#29551
Proposal: Enable purging resources in kubectl apply
#29551
Conversation
We found a Contributor License Agreement for you (the sender of this pull request) and all commit authors, but as best as we can tell these commits were authored by someone else. If that's the case, please add them to this pull request and have them confirm that they're okay with these commits being contributed to Google. If we're mistaken and you did author these commits, just reply here to confirm. |
Re CLA issue: not sure how to add @errordeveloper to this PR. How do you add a person to a PR? |
This CLA check is a bit confusing.. |
kubectl apply --purge-from-namespace -f https://example.com/myapp-part1.json -f https://example.com/myapp-part2.json | ||
``` | ||
|
||
If `myapp1.json` and `myapp2.json` are in the same namespaces and it is explicitly defined, removing either of the URLs from the invocations arguments will result in all the resources that URL has defined to be purged. |
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.
insert -part
here, to reflect what's above
cc @ghodss @kubernetes/kubectl |
@lukemarsden @errordeveloper Commits from multiple contributors will always fail the automated CLA check. |
Agree with general approach here - I think this is the simplest and most consistent way to solve this today. |
We would need to warn about using the generateName field inside of your applied files. |
Great, thanks!
Yes, but we think this is a general problem with apply? We could add a warning if applied files include generateName, however. I take it that your worry is that See also: #1702 (comment) |
It is a general problem, just want to make sure that a user is aware of it On Tue, Jul 26, 2016 at 12:29 PM, Brandon Philips notifications@github.com
|
I've simplified the proposal and updated it to reflect the discussion above. Please take another look: https://github.com/errordeveloper/kubernetes/blob/kubectl-apply-purge-from-namespace/docs/proposals/kubectl-apply-purge-missing-where.md Thanks! |
This is very cool, thanks for the update! Couple questions:
...with the label selector working as expected in all cases. I do think you could make a case that if you do
|
@ghodss good question indeed, sounds like this should be clarified. @lukemarsden I think the title of this PR no longer reflects the current revision of the proposal doc, doesn't it? It's really not so much about purging from namespaces any more. |
@ghodss thanks for the review!
@bgrant0607 not urgent, but do you have any comments on the above? |
kubectl apply
@errordeveloper title fixed, thanks! |
GCE e2e build/test passed for commit 0a014ac. |
|
||
## Interactions with namespaces | ||
|
||
* If no namespace is specified, operate across `default` namespace only. |
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.
Namespace behavior should be the same as all other kubectl commands, which means that namespace comes from the context by default.
|
The usage may look like this (assuming the user uses the convention of labelling apps with the `app` label): | ||
|
||
``` | ||
kubectl apply --purge-missing-where 'app=myapp' -f https://example.com/myapp.json |
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.
Why mash --purge
and the label selector together into a single flag? We have a convention for filtering commands by label selector already.
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.
@bgrant0607 because the label selector is specific to the purge operation. Splitting the purge flag from the label selector, IMO, makes it more dangerous, because presumably --purge without a label selector would delete everything not in the provided manifests. Making --purge require -l would beg the question why not unify them? Furthermore the spelling of --purge-missing-where "condition" reads naturally to explain the semantics of what's happening IMO. --purge -l condition is less clear to new users. Furthermore -l makes sense as a filter on other ops because they are simple ops, like delete - it's obvious what's being filtered. But we're making apply a compound operation: "create some things and delete others", -l on its own isn't sufficiently descriptive to make clear what the label selector applies to (only the deletions). That's why I proposed the combined flag -- it's better UX IMO.
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.
With the original design which was entirely label based, merging the flags certainly had merit. But now that we've introduced namespace as a filter as well, doesn't it break down a little? The filter is by selector, namespace, both or none, so at this point, having the purge flag merged specifically with the label selector doesn't seem to make as much sense.
If the goal is to protect against the danger of the flag, we should add a confirmation step which by default lists all resources which will be deleted and requires user confirmation to continue. Then we can add another flag like --continue
to skip the prompt.
That way we protect against user error while maintaining our consistency of -l
and --namespace
.
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.
@lukemarsden I disagree that the selector should only apply to prune/purge. I'd like to be able to use it to update a subset of the objects.
Also, we need to consider the overall usability of kubectl, not just this command. I prioritize consistency across commands fairly highly, so there's a high bar for departing from established precedent.
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.
@lukemarsden Please do not deviate from conventions established by other commands. |
@lukemarsden Please re-read prior feedback. |
@bgrant0607 @ghodss @smarterclayton thanks for the feedback! I'll address this in another rev of the proposal shortly. |
@lukemarsden Thanks. Another way to look at this: Assume that |
Relevant flags:
I assume that by default the deletion behavior will correspond to |
@lukemarsden Is this proposal still active? I would like to see it finished. |
FYI, there is a WIP implementation here #33075 |
#33075 merged. |
Proposal to resolve #19805
This change is