Possible to terminate pod from Within the pod?

I know you can terminate pod from “outside” with runpodctl- but are there any options for a pod to self-terminate, triggered by its own docker image? Or, am I approaching this wrong and ‘best practice’ is to have your pods giving status updates back to and being managed by a script on your main PC w/ runpodctl?
Solution:
One of them is RUNPOD_POD_ID which you can use to remove/terminate/kill the pod.
Jump to solution
12 Replies
Marcus
Marcus4mo ago
runpodctl remove pod $RUNPOD_POD_ID
runpodctl remove pod $RUNPOD_POD_ID
Madiator2011
Madiator20114mo ago
yes with runpodctl
Quicksilver
Quicksilver4mo ago
A bit of a whacky idea, but what about installing runpodctl on the pod, and calling it from inside the pod, through maybe subprocess. This may be completely wrong tho
Madiator2011 (Work)
runpodctl is preinstalled on all pods 🙂 No need for manual install
RollyPolly
RollyPollyOP4mo ago
in addition to whatever custom docker image you mount on it? Are you then able to, from a pod; read its own ID and have it kill itself?
Marcus
Marcus4mo ago
Yes Read what I said above
runpodctl remove pod $RUNPOD_POD_ID
runpodctl remove pod $RUNPOD_POD_ID
RunPod automatically injects some environment variables into a pod, with a RUNPOD_ prefix.
Solution
Marcus
Marcus4mo ago
One of them is RUNPOD_POD_ID which you can use to remove/terminate/kill the pod.
RollyPolly
RollyPollyOP4mo ago
I see! Thanks for the clarification, I was under the assumption the ID wasnt accessible from within the pod, that it was just some handle for runpodctl to manage it from one layer above
Marcus
Marcus4mo ago
Pod environment variables | RunPod Documentation
Configure and manage your pods with these essential environment variables, including pod ID, API key, host name, GPU and CPU count, public IP, SSH port, data center ID, volume ID, CUDA version, current working directory, PyTorch version, and public SSH key.
Marcus
Marcus4mo ago
The template just needs to export the environment variables in order for them to be accessible everywhere, many do but not all.
RollyPolly
RollyPollyOP4mo ago
I'm using my own DIY docker image, not a template, but that shouldn't be too hard to figure and add in
Want results from more Discord servers?
Add your server