Skip to content

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

Closed
@tksm

Description

@tksm

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
..

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/featureCategorizes issue or PR as related to a new feature.needs-triageIndicates an issue or PR lacks a `triage/foo` label and requires one.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions