<p>We have an AKS cluster and sometimes we end up with an issue where a deployment needs a restart (e.g. cached data has been updated and we want to refresh it or there is corrupt cache data we want to refresh).</p>
<p>I've been using the approach of scaling the deployment to 0 and then scaling it back up using the commands below:</p>
<pre><code>kubectl scale deployments/&lt;deploymentName&gt; --replicas=0
kubectl scale deployments/&lt;deploymentName&gt; --replicas=1
</code></pre>
<p>This does what I expect it to do, but it feels hacky and it means we're not running any deployments while this process is taking place.</p>
<p>What's a better approach to doing this? For either a specific deployment and for all the deployments?</p>

Matthew van Boheemen
<p>If you have a strategy of <code>RollingUpdate</code> on your deployments you can delete the pods in order to replace the pod and refresh it.</p>
<p>About the RollingUpdate strategy:</p>
<blockquote>
<p>Users expect applications to be available all the time and developers
are expected to deploy new versions of them several times a day. In
Kubernetes this is done with rolling updates. Rolling updates allow
Deployments' update to take place with zero downtime by incrementally
updating Pods instances with new ones.</p>
</blockquote>
<p>RollingUpdate config:</p>
<pre><code>spec:
  strategy:
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 0
    type: RollingUpdate
</code></pre>
<p><code>maxSurge</code> specifies the maximum number of Pods that can be created over the desired number of Pods.</p>
<p><code>maxUnavailable</code> specifies the maximum number of Pods that can be unavailable during the update process.</p>
<p>Delete the pod:</p>
<pre><code>kubectl delete pod &lt;pod-name&gt;
</code></pre>
<p>Edit:</p>
<p>Also, you can rollout the deployment, which will restart the pod but will create a new revision of the deployment as well.</p>
<p>Ex: <code>kubectl rollout restart deployments/&lt;deployment-name&gt;</code></p>
