<p>If you have a PDB that specifies a higher <code>minAvailable</code> than the <code>minReplicas</code> of a HPA, will the number of pods ever reach the lower <code>minReplicas</code>?</p>
<p>Example configs:</p>
<p>PDB</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
  name: frontend-pdb
spec:
  minAvailable: 3 # HERE
  selector:
    matchLabels:
      app: frontend
</code></pre>
<p>HPA</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
  name: frontend-hpa
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: frontend-deployment
  minReplicas: 2 # AND HERE
  maxReplicas: 20
  metrics:
  - type: Resource
    resource:
      name: cpu
      target:
        type: Utilization
        averageUtilization: 65
</code></pre>
<p>I image putting the PDB to a % rather than an absolute would solve this potetial conflict, but I am curious how the two play with each other.</p>

danthegoodman
<p>In your case both objects will be created and value
<code>minAvailable: 3</code> defined in PodDisruptionBudget will have higher priority than <code>minReplicas: 2</code> defined in Deployment.
Conditions defined in PDB are more important. In such case conditions for PDB are met but if autoscaler will try to decrease number of replicas it will be blocked because condition in PDB of minAvailable value will be not met.
You have wrote that you have noticed that when you update a deployment, and you have the PDB <code>minAvailable</code> less than the <code>minReplicas</code> in HPA, the amount of available pods never goes below the HPA. And it is normal because autoscaler take under consideration PDB and if</p>
<pre><code>minReplicas &gt; minAvailable
</code></pre>
<p>so the conditions for PDB are met (minAvailable is critical line so higher value is also proper) so HPA can then take under consideration his conditions and will hit at best minReplicas.</p>
<p>Overall idea of defining <a href="https://kubernetes.io/docs/concepts/workloads/pods/disruptions/#pod-disruption-budgets" rel="nofollow noreferrer">Pod Disruption Budget</a> is to make sure minimum replicas are always working.</p>
<p>While node operation, the drain will halt and wait that all PDBs condition are respected when performing pod eviction. If pods that was evicted would cause a PDB to be invalid would wait till the condition would be valid.</p>
<p><strong>NOTE:</strong></p>
<p>A PDB for a deployment with a single replica will most likely cause the node operation to never succeed.</p>
<p>Read more: <a href="https://stackoverflow.com/questions/63421461/kubernetes-autoscaler-no-downtime-for-deployments-when-downscaling-is-possible">downscaling-kubernetes</a>, <a href="https://stackoverflow.com/questions/63121100/is-pdb-required-for-a-kubernetes-cluster-for-which-hpa-is-defined">hpa-pdb-kubernetes</a>.</p>
