<p>Context: We have multiple processes that are watching the same feature flag to determine whether a restart is required, and trying to determine if we need to ensure that exactly one process calls <code>kubectl rollout restart</code>.</p>
<p>Suppose <code>n</code> processes simultaneously call <code>kubectl rollout restart</code> on the same deployment, for <code>n &gt; 3</code>.
Which of the following behaviors is expected to happen?</p>
<ol>
<li>The deployment goes down entirely as the overlapping restarts cause different pods to be deleted.</li>
<li>All the restarts eventually run, but they run serially.</li>
<li>Some number of restarts m, where m &lt; n will run serially.</li>
<li>Something else.</li>
</ol>
<p>I have searched around but haven't found documentation about this behavior, so a pointer would be greatly appreciated.</p>

<p>I didn't find the official documentation explaining how Kubernetes will behave as presented in your question.</p>
<p>However, I wrote a script that will spawn the 5 rollout restart command in parallel and used the deployment.yaml below for testing, with rollingUpdate as strategy and maxSurge = maxUnavailable = 1.</p>
<p><strong>deployment.yaml</strong></p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: webapp1
spec:
  strategy:
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 1
    type: RollingUpdate
  replicas: 10
  selector:
    matchLabels:
      app: webapp1
  template:
    metadata:
      labels:
        app: webapp1
    spec:
      containers:
      - name: webapp1
        image: katacoda/docker-http-server:latest
        ports:
        - containerPort: 80
</code></pre>
<p><strong>script.sh</strong></p>
<pre><code>for var in 1..5; do
        kubectl rollout restart deployment webapp1 &gt; /dev/null 2&gt;&amp;1 &amp;
done
</code></pre>
<p>Then executed the script and watched the behavior</p>
<pre><code>    . script.sh; watch -n .5 kubectl get po
</code></pre>
<p>The watch command revealed that the Kubernetes maintained the desired state as commanded by the deployment.yaml. AT no time, fewer than 9 pods were in the Running state. Screenshots were taken few seconds apart</p>
<p><a href="https://i.stack.imgur.com/kAV7h.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kAV7h.png" alt="enter image description here" /></a></p>
<p><a href="https://i.stack.imgur.com/VSRlP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VSRlP.png" alt="enter image description here" /></a></p>
<p>So, from this experiment, I deduce that no matter how many parallel rollout-restarts occur, Kubernetes controller manager is smart enough to still maintain the desired state.</p>
<p>Hence, the expected behavior will be as described in your manifest.</p>
