Home > Enterprise >  will python script running inside a kubernetes pod exit if my laptop/system turned off
will python script running inside a kubernetes pod exit if my laptop/system turned off

Time:09-29

I am running a python script inside a kubernetes pod with kubectl exec -it bash.Its a long running script which might take a day to complete.i executed the python script from my laptop inside the kubernetes pod. If i close my laptop,will the script stop running inside the pod?

CodePudding user response:

If you are running Kubernetes on Cloud, the script will continue until it is finished succefully or throws an error even if you close your laptop,

Othewise, if you are running local Kubernetes Cluster, for example: with minikube, cluster will shut down and so is your script

CodePudding user response:

It's not possible to know the answer without at least the following information:

  • laptop OS (including distribution and version)
  • whether your k8s is running directly on your laptop or on remote hardware

I'll assume you're running linux. If you are running a productive k8s locally on your laptop (in which case, why?), then you likely have to change the settings in your desktop environment, or temporarily disable acpid, or your virtualised cluster will cease to exist when the power turns off. All of the former is completely dependent on your hardware and software.

If the process is running remotely (on other hardware), turning off your laptop will not make a difference to the running script. Read the man page for kubectl-exec:

-i, --stdin=false
    Pass stdin to the container

-t, --tty=false
    Stdin is a TTY

The arguments for an interactive shell are just about mapping stdin to the container; kubectl won't kill your remote process if your laptop turns off, loses network connectivity etc.

  • Related