How to make sure that the script is run from only one of the PODs of all replicas?

5/20/2020

Our product is running on Kubernetes/Docker.

I have a POD which will be running multiple replicas. There is a script in the POD which will be run after POD start. The script needs the main process in the POD to be running.

The problem is the script should be run only from one POD. With multiple replicas the script will be run multiple times. How to make sure that the script is run from only one of the PODs of all replicas? Thanks Chandra

-- Chandu
kubernetes
pod

1 Answer

5/20/2020

It's not possible to run script from only one replica of a pod. Use cronjob for such usecase.

-- Arghya Sadhu
Source: StackOverflow