<p>That's what I do:</p>
<ol>
<li>Deploy a stateful set. The pod will always exit with an error to provoke a failing pod in status <code>CrashLoopBackOff</code>: <code>kubectl apply -f error.yaml</code></li>
<li>Change error.yaml (<code>echo a</code> =&gt; <code>echo b</code>) and redeploy stateful set: <code>kubectl apply -f error.yaml</code></li>
<li>Pod keeps the error status and will not immediately redeploy but wait until the pod is restarted after some time.</li>
</ol>
<p><strong>Requesting pod status:</strong></p>
<pre><code>$ kubectl get pod errordemo-0
NAME          READY   STATUS             RESTARTS   AGE
errordemo-0   0/1     CrashLoopBackOff   15         59m
</code></pre>
<p><strong>error.yaml</strong></p>
<pre><code>apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: errordemo
  labels:
    app.kubernetes.io/name: errordemo
spec:
  serviceName: errordemo
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/name: errordemo
  template:
    metadata:
      labels:
        app.kubernetes.io/name: errordemo
    spec:
      containers:
        - name: demox
          image: busybox:1.28.2
          command: ['sh', '-c', 'echo a; sleep 5; exit 1']
      terminationGracePeriodSeconds: 1
</code></pre>
<p><strong>Questions</strong></p>
<p>How can I achieve an immediate redeploy even if the pod has an error status?
I found out these solutions but I would like to have a single command to achieve that (In real life I'm using helm and I just want to call <code>helm upgrade</code> for my deployments):</p>
<ul>
<li>Kill the pod before the redeploy</li>
<li>Scale down before the redeploy</li>
<li>Delete the statefulset before the redeploy</li>
</ul>
<p>Why doesn't kubernetes redeploy the pod at once?</p>
<ul>
<li>In my demo example I have to wait until kubernetes tries to restart the pod after waiting some time.</li>
<li>A pod with no error (e.g. <code>echo a; sleep 10000;</code>) will be restarted immediately. That's why I set <code>terminationGracePeriodSeconds: 1</code></li>
<li>But in my real deployments (where I use helm) I also encountered the case that the pods are never redeployed. Unfortunately I cannot reproduce this behaviour in a simple example.</li>
</ul>

<p>You could set <code>spec.podManagementPolicy: &quot;Parallel&quot;</code></p>
<blockquote>
<p><a href="https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#parallel-pod-management" rel="nofollow noreferrer">Parallel pod management</a> tells the StatefulSet controller to launch or terminate all Pods in parallel, and not to wait for Pods to become Running and Ready or completely terminated prior to launching or terminating another Pod.</p>
</blockquote>
<p>Remember that the default podManagementPolicy is <code>OrderedReady</code></p>
<blockquote>
<p><a href="https://kubernetes.io/docs/tutorials/stateful-application/basic-stateful-set/#orderedready-pod-management" rel="nofollow noreferrer">OrderedReady pod management</a> is the default for StatefulSets. It tells the StatefulSet controller to respect the ordering guarantees demonstrated above</p>
</blockquote>
<p>And if your application requires ordered update then there is nothing you can do.</p>
