skip to content
Alvin Lucillo

Throwaway pod not deleted

/ 1 min read

When you use the command below and the pod still exists even after exiting its shell, it’s because you’re missing --restart=Never. That argument defaults to Always when not provided, causing the creation of a new controller that keeps the pod running (depending on the kubectl version). The argument --rm ensures that the pod is deleted, however, if the command below fails for some reason, that delete argument won’t run because the delete step is never reached, so the controller will keep the pod alive. To make sure it’s explicitly disposable, add --restart=Never

k run test --image=busybox --rm -it -- sh

Correct command:

k run test --image=busybox --rm -it --restart=Never -- sh