Skip to content

Conversation

@y-rabie
Copy link
Contributor

@y-rabie y-rabie commented Sep 9, 2025

This adds a new key binding Ctrl+v for pod eviction. I think it's useful to have that functionality as a form of less dangerous deletion in restricted environments.

There is no kubectl command for it, but there are some plugins arounds such as: (https://github.com/rajatjindal/kubectl-evict-pod and https://github.com/ueokande/kubectl-evict). Using one of these kubectl plugins within a k9s binding plugin however won't make multi-selection available for eviction, and the user will be restricted to evict pod one by one.

Since this is a somewhat safe operation, I've opted not to have a confirmation dialog for it similar to kill. But I'm open to having it.

@y-rabie y-rabie force-pushed the add-pod-eviction branch 2 times, most recently from e3ac2db to f84fb57 Compare September 9, 2025 23:17
Copy link
Owner

@derailed derailed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@y-rabie Nice addition!

}

if err := evictable.Evict(context.Background(), path); err != nil {
if strings.Contains(err.Error(), "violate") {
Copy link
Owner

@derailed derailed Sep 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be best if Evict returns a sentinel error that we can test against via errors.Is vs looking for a string

if err := evictable.Evict(context.Background(), path); err != nil {
if strings.Contains(err.Error(), "violate") {
// If the error is due to PDB violation, don't attempt to evict the rest of the selection.
pdbViolation = true
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems a bit inconsistent. If a pod eviction failed on pdb we don't process the rest of the batch. But if there is any other eviction issue we continue. I think we should be consistent here i.e we either stop processing the batch or do our best to continue processing and report back which evictions failed and why.

I also think this should be confirmed pod evictions could yield service disruption which could break workloads especially if we fail to reschedule...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems a bit inconsistent. If a pod eviction failed on pdb we don't process the rest of the batch. But if there is any other eviction issue we continue. I think we should be consistent here i.e we either stop processing the batch or do our best to continue processing and report back which evictions failed and why.

It just seemed reasonable that for PDB violation error, we need to stop, since we know the rest will fail as well. For other errors, I accounted for the fact that the error might be transient, and so other pods may succeed eviction.

I'm okay however with being consistent, and I think not trying the rest of the batch is best.

@derailed derailed added the needs-tlc Pr needs additional updates label Sep 16, 2025
Signed-off-by: y-rabie <youssef.rabie@procore.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-tlc Pr needs additional updates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants