<p>I am working on an application which is running on the Kubernetes cluster. I want to restart the n number of pods manually in a sequence. Can we do that? Would <code>kubectl scale &lt;options&gt;</code> work here?</p>

Shubham Gupta
<p>The answer is <strong>yes</strong>, you can restart 5 out of 10 pods of a particular deployment. Though it won't be a single command for this.</p>
<p>As you correctly assumed <code>kubectl scale</code> will help you here.</p>
<p>Restart of 5 pods out of 10 contains 2 operations:</p>
<ol>
<li><p>Scaling down the deployment from 10 to 5 pods</p>
<pre><code>kubectl scale deployment deployment-name --replicas=5
</code></pre>
</li>
<li><p>Scaling up the deployment from 5 to 10 pods back:</p>
<pre><code>kubectl scale deployment deployment-name --replicas=10
</code></pre>
</li>
</ol>
<p>Also you can delete exact pods, <code>kube-controller-manager</code> with <code>deployment/replicaset</code> controllers within will make sure that <code>desired</code> state will match the exact state and therefore missing pods will be automatically rescheduled.</p>
<hr />
<p>However following best practice (thanks to @DavidMaze), ideal scenario is restart the whole deployment. This can be done with following command:</p>
<pre><code>kubectl rollout restart deployment deployment-name
</code></pre>
<p>This is safer option and it allows to roll back easily in case of any mistakes/errors.</p>
<p>Also it's possible to restart pods 1 by 1 within the deployment when <code>rollout restart</code> is requested.</p>
<p><code>.spec.strategy.rollingUpdate.maxUnavailable</code> should be set to <code>1</code> which means only 1 pods at most will be unavailable during the restart - <a href="https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#max-unavailable" rel="nofollow noreferrer">reference to max unavailable</a>.</p>
<p><a href="https://kubernetes.io/docs/concepts/workloads/controllers/deployment/" rel="nofollow noreferrer">Kubernetes Deployments</a></p>
