Skip to content
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 --rm flag to kubectl debug to remove debug pod on exit #1681

Open
tksm opened this issue Dec 2, 2024 · 3 comments
Open

Add --rm flag to kubectl debug to remove debug pod on exit #1681

tksm opened this issue Dec 2, 2024 · 3 comments
Labels
kind/feature Categorizes issue or PR as related to a new feature. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one.

Comments

@tksm
Copy link

tksm commented Dec 2, 2024

What would you like to be added:

I would like to add the --rm flag to kubectl debug, similar to the flag in kubectl run and docker run, which allows automatic deletion of the debug pod upon exit. Since ephemeral containers cannot be removed, this flag would only apply when debugging a node or a pod with --copy-to.

I have already opened a PR for this feature, as its implementation is small:
kubernetes/kubernetes#129046

Why is this needed:

kubectl debug -it node is very useful replacement for ssh, but I often forget to remove completed debug pods. These completed pods are generally not useful, and even the official documentation includes a step for "Cleaning up".

$ kubectl get pods
NAME                           READY   STATUS      RESTARTS   AGE
node-debugger-minikube-4gq42   0/1     Completed   0          74s
node-debugger-minikube-8xrvr   0/1     Completed   0          31s
node-debugger-minikube-hscjt   0/1     Completed   0          20s
..
@tksm tksm added the kind/feature Categorizes issue or PR as related to a new feature. label Dec 2, 2024
@k8s-ci-robot k8s-ci-robot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Dec 2, 2024
@k8s-ci-robot
Copy link
Contributor

This issue is currently awaiting triage.

SIG CLI takes a lead on issue triage for this repo, but any Kubernetes member can accept issues by applying the triage/accepted label.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@ardaguclu
Copy link
Member

Although at first sight it looks reasonable, each new flag puts kubectl debug under a risk of unusability that kubectl run already experiences due to plenty of flags. As already stated in the description, this new flag won't work on ephemeral containers anyway. In my opinion, hurting the usability for a new flag far outweighs the benefits we get and we should be reluctant to add this flag.

@tksm
Copy link
Author

tksm commented Dec 2, 2024

Hi, I understand that we should be cautious about adding flags. What do you think about adding a specific label to debug pods instead of introducing a flag? This would at least make cleaning up debug pods easier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants