<p>I am running cluster of 3 nodes, created using kops, on AWS EC2 nodes.
When I run the deployment
<code>kubectl set image deployment.v1.apps/app-web app-web=11122333.dkr.ecr.eu-west-1.amazonaws.com/app:$build_number</code></p>
<p>I get the newly created pod stuck in <code>Pending</code> whilst existing 3 stay in <code>Running</code> mode indefinitely.</p>
<p><code>kubectl describe pod app-web-7b44bb94f6-ftbfg</code> gives:</p>
<pre><code>Warning  FailedScheduling  81s (x11 over 8m25s)  default-scheduler  0/6 nodes are available: 3 node(s) didn't match pod affinity/anti-affinity, 3 node(s) didn't satisfy existing pods anti-affinity rules, 3 node(s) had taint {node-role.kubernetes.io/master: }, that the pod didn't tolerate.
</code></pre>
<p><code>kubectl describe pod app-web-7b44bb94f6-ftbfg</code>
gives</p>
<pre><code>app-web-7b44bb94f6-ftbfg                            0/1     Pending   0          9m15s
app-web-c977b7ff9-6ngr2                             1/1     Running   0          12h
app-web-c977b7ff9-9lj9c                             1/1     Running   0          12h
app-web-c977b7ff9-klrnv                             1/1     Running   0          12h
</code></pre>
<p>I've recently upgraded my  cluster from:</p>
<pre><code># kubectl version --short
Client Version: v1.17.3
Server Version: v1.11.9
</code></pre>
<p>to</p>
<pre><code>Client Version: v1.17.3
Server Version: v1.18.10
</code></pre>
<p>I've had to upgrade my deployment as well.</p>
<pre><code>
apiVersion: apps/v1 # Previously: extensions/v1beta1
kind: Deployment
metadata:
  name: app-web
spec:
  replicas: 3
  selector:  # This selector had to be added once migrated to apps/v1
    matchLabels:
      app: app-web
      role: web
  template:
    metadata:
      labels:
        app: app-web
        role: web
    spec:
      affinity:
        podAntiAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            - labelSelector:
                matchExpressions:
                  - key: app
                    operator: In
                    values:
                      - app-web
              topologyKey: &quot;kubernetes.io/hostname&quot;

</code></pre>
<p>The problem seem to be related to: <code>podAntiAffinity</code>, however it wasn't a problem in a previous version of a Kubernetes. Shall I switch to <code>preferredDuringSchedulingIgnoredDuringExecution</code> instead or perhaps there is another solution to this problem?</p>

Tom Raganowicz
<p>The issue is that the default <code>maxUnavailable</code> for <code>RollingUpdate</code> strategy is <code>25%</code>, which doesn't allow Kubernetes to evict 1 out of 3 pods. I've added this to deployment strategy spec:</p>
<pre><code>  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 1
</code></pre>
<p>and things are back to normal.</p>
<p>I haven't analyzed whether that default <code>25%</code> has changed, since this issue wasn't affecting me in the previous version of the Kubernetes.</p>
