<p>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. </p>

<p>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.</p>

<p>The gunicorn service gets started in a Dockerfile:</p>

<pre><code>CMD gunicorn -c gunicorn.conf.py -b :$PORT --preload app:app
</code></pre>

<p>But I'm guessing this is not too relevant.</p>

<p>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.</p>

Florian
<p><code>kubectl rollout restart</code> has landed in Kubernetes v1.15 [1]. This feature is designed for exactly what you are looking to do - a rolling restart of pods.</p>

<p>[1] <a href="https://github.com/kubernetes/kubernetes/issues/13488" rel="nofollow noreferrer">https://github.com/kubernetes/kubernetes/issues/13488</a></p>
