How to delete the pod for one time task in kubernetes automatically?

Viewed 7966

In order to check status, I started the busybox in kubernetes using interactive shell.

$ kubectl run -i --tty busybox --image=busybox --restart=Never -- sh
/ # exit
$ kubectl run -i --tty busybox --image=busybox --restart=Never -- sh
Error from server (AlreadyExists): pods "busybox" already exists

When I exit from the shell, I expect the pod will be deleted as well. While it exists there in completed status.

$ kubectl get pods -a
NAME                     READY     STATUS      RESTARTS   AGE
busybox                  0/1       Completed   0          58m

I have to delete the pod, it is annoying.

DO we have simple parameter I can use to ask k8s to delete the pod for this one task job ?

1 Answers
Related