I'm looking for a way to restart all the pods of my service. They should restart one by one so the service is always available. The restart should happen when a Python script from a different service is done.
I'm doing this because on the pods I want to restart there is a Gunicorn-server running which needs to reload some data. That only works when the server gets restarted.
The gunicorn service gets started in a Dockerfile:
CMD gunicorn -c gunicorn.conf.py -b :$PORT --preload app:app
But I'm guessing this is not too relevant.
I imagine the solution to be some kind of kubectl command that I can run in the Python script or a hint for a kubectl endpoint, that I couldn't find.
kubectl rollout restart
has landed in Kubernetes v1.15 [1]. This feature is designed for exactly what you are looking to do - a rolling restart of pods.