<p>I was trying to implement the pdb in kubernetes for our application. but I am confused with How the PDB and HPA are together related or If rolling update strategy is defined is there any dependency with PDB ?</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: pdbtest
  namespace: test-fix
  labels:
    app: pdbtest
    environment: dev
spec:
  replicas: 4
  strategy:
    type: &quot;RollingUpdate&quot;
    rollingUpdate:
      maxSurge: 25%
      maxUnavailable: 25%
  selector:
    matchLabels:
      app: pdbtest
  template:
    metadata:
      labels:
        app: pdbtest
        environment: dev
    spec:
      containers:
        - name: pdbtest
          image: nginx
          imagePullPolicy: &quot;Always&quot;
          ports:
            - name: http
              containerPort: 8080
              protocol: TCP
          resources:
            requests:
              memory: 256Mi
              cpu: 0.2
            limits:
              memory: 2048Mi
              cpu: 1
          env:
          - name: APPLICATIONNAME
            value: pdbtest
      nodeSelector:
        agentpool: devpool01



apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
  name: pdbtest
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: pdbtest
  maxReplicas: 6
  minReplicas: 4
  metrics:
  - type: Resource
    resource:
      name: cpu
      target:
        type: Utilization
        averageUtilization: 80




apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
  labels:
    app: pdbtest
  name: pdbtest
  namespace: test-fix
spec:
  minAvailable: 4
  selector:
    matchLabels:
      app: pdbtest
</code></pre>
<p>In order to test the pdb behavior , I just tried to delete multiple pods, But what i expected is, pdb will block the deletion of the pods as its expected 4 replicas always available as per the pdb, but actually  4new pods are getting created.</p>
<p>So would like to understand
How pdb works? whether its applicable for deleting pods/deployments or rolling update?
How the PDB related to HPA. if we are planning for a pdb with minAvailable property, then what value for the minAvailable in PDB will be considered ? (is it same as hpa minpods or it should be less than the minpods in HPA)?
Will PDB have impact on new release rolling update?
How PDB is different from Rolling Update strategy?</p>

Vowneee
<p>If you read the <a href="https://kubernetes.io/docs/concepts/workloads/pods/disruptions/" rel="nofollow noreferrer">documentation</a>, you find a disclaimer that is applicable to your test scenario.</p>
<blockquote>
<p><strong>Caution</strong>: Not all voluntary disruptions are constrained by Pod Disruption Budgets. For example, deleting deployments or pods bypasses Pod Disruption Budgets.</p>
</blockquote>
<p>That's why you could delete it. Apart from that, it's different from min replicas of an HPA in that it will provide protection against disruptions, in <em>certain</em> scenarios. For example, when you drain a node.</p>
<p>For your test, you could create a deployment with 6 replicas and create a disruption budget of 4 pods. Finally, try to update the deployment to a replica count of 2.</p>
