Open wking opened 2 years ago
@wking: This issue is currently awaiting triage.
If a SIG or subproject determines this is a relevant issue, they will accept it by applying the triage/accepted
label and provide further guidance.
The triage/accepted
label can be added by org members by writing /triage accepted
in a comment.
/sig cli
This was discussed in sig-cli, and the outcome was that this should be adopted by community first as a kubectl krew plugin.
Luckily, it seems there is such a plugin called evict-pod, which has some recognition already: https://github.com/rajatjindal/kubectl-evict-pod.
The repo seems active, but it is missing some features for parametrizing the eviction (most notably gracePeriodSeconds
). Hopefully, it should be easy to add by contributing to the repo.
I think this is a kubectl feature request, albeit one we don't plan to prioritize.
/transfer kubectl
We would like to see some community demand and interest before considering upstreaming a plugin with this functionality. Please react to the top level issue with a :+1: if you come across this and agree.
I would be very interested by this feature š, here is why:
We run stateful workloads on K8S: typically, a cluster of 3 pods. And our failure tolerance is: loosing 1 pod is ok, but not 2. Sometimes, we need to manually "restart" one precise pod (and not the others), because of a malfunction of that pod.
So our current procedure is :
kubectl get pods -l ...
or using monitoring dashboardkubectl delete pod/xxxxxx-i
But of course, this process is dangerous, because of "race condition": => another pod can be deleted (for another reason, cf below) between step 1 & 2 => so, the manual deletion will remove a 2nd pod at the same time => incident š¢
Examples of situation that can create this "race condition":
With the proposed feature, our procedure would be simply:
kubectl evict pod/xxxxxx-i
So, it's now safe (and simpler, but not the objective here) š
I'd one day like to be able to evict pods by label. That could arrive first in the plugin, or be something that we implement in-tree.
Other plausible enhancements that build on this basic idea:
kubectl evict pod --namespace app1 --field-selector spec.nodeName=broken-node.example
kubectl evict pod --all-namespaces -l foo=bar --max-disruptions=2
kubectl evict pods/foo pods/bar pods/wibble --grace-period=180
The Kubernetes project currently lacks enough contributors to adequately respond to all issues.
This bot triages un-triaged issues according to the following rules:
lifecycle/stale
is appliedlifecycle/stale
was applied, lifecycle/rotten
is appliedlifecycle/rotten
was applied, the issue is closedYou can:
/remove-lifecycle stale
/close
Please send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle stale
The Kubernetes project currently lacks enough contributors to adequately respond to all issues.
This bot triages un-triaged issues according to the following rules:
lifecycle/stale
is appliedlifecycle/stale
was applied, lifecycle/rotten
is appliedlifecycle/rotten
was applied, the issue is closedYou can:
/remove-lifecycle stale
/close
Please send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle stale
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues.
This bot triages un-triaged issues according to the following rules:
lifecycle/stale
is appliedlifecycle/stale
was applied, lifecycle/rotten
is appliedlifecycle/rotten
was applied, the issue is closedYou can:
/remove-lifecycle rotten
/close
Please send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle rotten
What would you like to be added?
A
kubectl evict ...
subcommand or similar syntactic sugar around the eviction API.Why is this needed?
Using the delete API is convenient, but dangerous. For example:
Leaves an OpenShift cluster temporarily without monitoring. It's safer to use the eviction API to respect PodDisruptionBudgets, like:
However, that's a bit of a mouthful, and requires a here-doc and duplicating the pod name. It might be possible to add
--subresource
to thecreate
subcommand to support something like:But that would likely bump into the current guards that enforce redundant information between the URI path and the Eviction resource. It's not clear to me why the eviction handler can't backfill missing Eviction resource information like the
name
from the path information, or really, why the eviction handler cannot default the entire Eviction resource when the caller doesn't need to set explicit delete options. Possibly kubernetes/kubernetes#53185 touches on this, although I haven't wrapped my head around that yet.Or, instead of trying to make
create
more flexible, we could grow a new subcommand likeevict
just for the eviction subresource.But it would be nice to make the safer eviction API more convenient, so folks didn't have to decide between safety and convenience when bumping pods.
There is at least one existing plugin implementation here.