<p>I'd like to configure cluster autoscaler on AKS. When scaling down it fails due to PDB:</p>

<pre><code>I1207 14:24:09.523313       1 cluster.go:95] Fast evaluation: node aks-nodepool1-32797235-0 cannot be removed: no enough pod disruption budget to move kube-system/metrics-server-5cbc77f79f-44f9w
I1207 14:24:09.523413       1 cluster.go:95] Fast evaluation: node aks-nodepool1-32797235-3 cannot be removed: non-daemonset, non-mirrored, non-pdb-assignedkube-system pod present: cluster-autoscaler-84984799fd-22j42
I1207 14:24:09.523438       1 scale_down.go:490] 2 nodes found to be unremovable in simulation, will re-check them at 2018-12-07 14:29:09.231201368 +0000 UTC m=+8976.856144807
</code></pre>

<p>All system pods have <code>minAvailable: 1</code> PDB assigned manually. I can imagine that this is not working for PODs with only a single replica like the <code>metrics-server</code>:</p>

<pre><code>❯ k get nodes -o wide
NAME                       STATUS   ROLES   AGE   VERSION   INTERNAL-IP   EXTERNAL-IP   OS-IMAGE             KERNEL-VERSION      CONTAINER-RUNTIME
aks-nodepool1-32797235-0   Ready    agent   4h    v1.11.4   10.240.0.4    &lt;none&gt;        Ubuntu 16.04.5 LTS   4.15.0-1030-azure   docker://3.0.1
aks-nodepool1-32797235-3   Ready    agent   4h    v1.11.4   10.240.0.6    &lt;none&gt;        Ubuntu 16.04.5 LTS   4.15.0-1030-azure   docker://3.0.1

❯ ks get pods -o wide
NAME                                    READY   STATUS    RESTARTS   AGE   IP            NODE                       NOMINATED NODE
cluster-autoscaler-84984799fd-22j42     1/1     Running   0          2h    10.244.1.5    aks-nodepool1-32797235-3   &lt;none&gt;
heapster-5d6f9b846c-g7qb8               2/2     Running   0          1h    10.244.0.16   aks-nodepool1-32797235-0   &lt;none&gt;
kube-dns-v20-598f8b78ff-8pshc           4/4     Running   0          3h    10.244.1.4    aks-nodepool1-32797235-3   &lt;none&gt;
kube-dns-v20-598f8b78ff-plfv8           4/4     Running   0          1h    10.244.0.15   aks-nodepool1-32797235-0   &lt;none&gt;
kube-proxy-fjvjv                        1/1     Running   0          1h    10.240.0.6    aks-nodepool1-32797235-3   &lt;none&gt;
kube-proxy-szr8z                        1/1     Running   0          1h    10.240.0.4    aks-nodepool1-32797235-0   &lt;none&gt;
kube-svc-redirect-2rhvg                 2/2     Running   0          4h    10.240.0.4    aks-nodepool1-32797235-0   &lt;none&gt;
kube-svc-redirect-r2m4r                 2/2     Running   0          4h    10.240.0.6    aks-nodepool1-32797235-3   &lt;none&gt;
kubernetes-dashboard-68f468887f-c8p78   1/1     Running   0          4h    10.244.0.7    aks-nodepool1-32797235-0   &lt;none&gt;
metrics-server-5cbc77f79f-44f9w         1/1     Running   0          4h    10.244.0.3    aks-nodepool1-32797235-0   &lt;none&gt;
tiller-deploy-57f988f854-z9qln          1/1     Running   0          4h    10.244.0.8    aks-nodepool1-32797235-0   &lt;none&gt;
tunnelfront-7cf9d447f9-56g7k            1/1     Running   0          4h    10.244.0.2    aks-nodepool1-32797235-0   &lt;none&gt;
</code></pre>

<p>What needs be changed (number of replicas? PDB configuration?) for down-scaling to work?</p>

andig
<p>Basically, this is an administration issues when draining nodes that are configured by PDB ( Pod Disruption Budget )  </p>

<p>This is because the evictions are forced to respect the PDB you specify</p>

<p>you have two options:</p>

<p>Either force the hand:</p>

<pre><code>kubectl drain foo --force --grace-period=0
</code></pre>

<p>you can check other options from the doc -> <a href="https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#drain" rel="nofollow noreferrer">https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#drain</a></p>

<p>or use the eviction api:</p>

<pre><code>{
  "apiVersion": "policy/v1beta1",
  "kind": "Eviction",
  "metadata": {
    "name": "quux",
    "namespace": "default"
  }
}
</code></pre>

<p>Anyhow, the drain or the eviction api attempts delete on pod to let them be scheduled elswhere before completely draining the node </p>

<p>As mentioned in the docs:</p>

<p>the API can respond in one of three ways:</p>

<ol>
<li>If the eviction is granted, then the pod is deleted just as if you had sent a DELETE request to the pod’s URL and you get back 200 OK.</li>
<li>If the current state of affairs wouldn’t allow an eviction by the rules set forth in the budget, you get back 429 Too Many Requests. This is typically used for generic rate limiting of any requests</li>
<li>If there is some kind of misconfiguration, like multiple budgets pointing at the same pod, you will get 500 Internal Server Error.</li>
</ol>

<p>For a given eviction request, there are two cases:</p>

<ol>
<li><p>There is no budget that matches this pod. In this case, the server always returns 200 OK.</p></li>
<li><p>There is at least one budget. In this case, any of the three above responses may apply.</p></li>
</ol>

<p>If it gets stuck then you might need to do it manually </p>

<p>you can read me <a href="https://kubernetes.io/docs/tasks/administer-cluster/safely-drain-node/" rel="nofollow noreferrer">here</a> or <a href="https://banzaicloud.com/blog/drain/" rel="nofollow noreferrer">here</a> </p>
