Kubernetes PodDisruptionBudget Generator

Build a PodDisruptionBudget and find out whether it can actually be satisfied. Give it your replica count and it works out how many pods are evictable, and says so plainly when the answer is none.

Budget
Check it against your workload

Not part of the output. Used to tell you whether this budget can ever be satisfied.

poddisruptionbudget.yaml

updates as you type

    Common mistakes

    These are the ones that fail silently. The config is accepted, nothing raises an error, and the consequence arrives later.

    1. Setting minAvailable equal to the replica count

      No pod can ever be evicted, so a node drain hangs indefinitely and the cluster cannot be upgraded.

      Instead:Leave at least one pod of headroom, or use maxUnavailable: 1.

    2. Creating a PDB for a single-replica deployment

      minAvailable: 1 on one replica blocks every voluntary eviction permanently.

      Instead:Scale to two, or accept the disruption and skip the PDB.

    3. Expecting a PDB to prevent all disruption

      It only covers voluntary evictions. A node failure, an OOM kill or a delete ignores it entirely.

      Instead:It is a drain guard, not an availability guarantee.

    What a PodDisruptionBudget does, and what it does not

    A PDB constrains voluntary disruption only. That means the eviction API, which is what kubectl drain and the cluster autoscaler use. A node crashing, a kubelet dying or a container being OOMKilled ignores it entirely. It is an upgrade-safety object, not an availability guarantee, and reading it as the latter is how people end up with one that cannot be satisfied.

    The deadlock: a budget nothing can ever satisfy

    If the budget requires every replica to stay up, no pod can ever be evicted, so no node running one can ever be drained. kubectl drain does not fail: it retries, indefinitely, printing that it cannot evict. A cluster upgrade stops on that node and a scale-down never completes. The object applies cleanly and the problem surfaces weeks later, to somebody else.

    replicas: 3, minAvailable: 3   -> 0 evictable
    replicas: 3, maxUnavailable: 0 -> 0 evictable
    replicas: 1, minAvailable: 1   -> 0 evictable
    
    kubectl drain node-1
    evicting pod default/api-7d9f
    error when evicting pod "api-7d9f" (will retry):
    Cannot evict pod as it would violate the budget.
    ... forever

    minAvailable does not scale, maxUnavailable does

    A fixed minAvailable is a number, not a ratio. Scale the Deployment down later and the budget silently becomes a drain block without anyone touching the PDB. maxUnavailable is expressed relative to the current replica count, so it keeps meaning the same thing as the workload changes.

    minAvailable: 2
      replicas 5  -> 3 may go down
      replicas 3  -> 1 may go down
      replicas 2  -> 0 may go down   deadlock, silently
    
    maxUnavailable: 1
      replicas 5  -> 1 may go down
      replicas 2  -> 1 may go down
      replicas 1  -> 1 may go down   still drainable

    Percentages round towards availability, both ways

    minAvailable percentages round up and maxUnavailable percentages round down. Both directions make the budget stricter than the arithmetic suggests, which is the safe choice and a surprise if you sized it by dividing.

    replicas: 3
    
    minAvailable: 50%    -> ceil(1.5) = 2 must stay up
                            so only 1 may be evicted
    maxUnavailable: 50%  -> floor(1.5) = 1 may go down
                            same result, different route
    
    replicas: 4
    minAvailable: 75%    -> ceil(3) = 3 must stay up

    A crash-looping pod can block its own replacement

    By default a pod that is running but not Ready cannot be evicted while the budget is unmet, because evicting it would take the count further below the minimum. So a workload stuck in CrashLoopBackOff wedges the drain of the node it is on, which is exactly the moment you want to move it. unhealthyPodEvictionPolicy: AlwaysAllow fixes this, and needs Kubernetes 1.27.

    spec:
      minAvailable: 2
      unhealthyPodEvictionPolicy: AlwaysAllow
    
    # IfHealthyBudget (the default):
    #   unready pods are protected too, so a broken
    #   deployment blocks node maintenance
    # AlwaysAllow:
    #   unready pods can always be evicted, because
    #   they were not serving traffic anyway

    It matches pod labels, and an empty selector is not empty

    The selector must match spec.template.metadata.labels on the workload, not the Deployment's own metadata.labels, which are usually written to look identical. A PDB matching nothing is created without complaint and protects nothing. An empty selector is the opposite problem: under policy/v1 it matches every pod in the namespace, where under the old policy/v1beta1 it matched none.

    kubectl get pdb
    NAME     MIN AVAILABLE   ALLOWED DISRUPTIONS   AGE
    api-pdb  2               0                     5m
                             ^ this is the number
                               that tells you it is
                               about to block a drain
    
    # ALLOWED DISRUPTIONS of 0 on a healthy workload
    # means the budget is already unsatisfiable.

    More kubernetes tools

    Kubernetes YAML Generator Answer a few questions, get a manifest Kubernetes YAML Validator Is this YAML valid, and where is it wrong? Kubernetes Rollout & Probe Timing Restart loops, capacity dips and stuck drains Kubernetes Service Checker Will this Service have any endpoints? Kubernetes Network Policy Viewer What can reach what, and what just broke Kubernetes Manifest Diff What actually changed Kubernetes Resource Calculator What these manifests actually reserve Kubernetes RBAC Viewer Who can actually do what Kubernetes Deployment Generator See the capacity dip before you deploy Kubernetes Service Generator port, targetPort, and which one you meant Kubernetes StatefulSet Generator Stable names, and volumes that outlive you Kubernetes QoS Class Calculator And where you sit in the eviction order Kubernetes Node Capacity Planner Allocatable is not capacity Kubernetes Max Pods per Node Calculator The ENI limit, not the 110 default Kubernetes Label Selector Tester Which key failed, not just that one did Kubernetes Taint & Toleration Tester Tolerations permit, they do not attract Kubernetes Resource Name Validator RFC 1123 subdomain, label, or 1035 Kubernetes Label & Annotation Validator Why your image tag is not a legal label Kubernetes CrashLoopBackOff Guide The status is a timer, not a cause Kubernetes TLS Certificate Decoder When it expires, and what it covers Kubernetes ServiceAccount Token Decoder Bound or legacy, and when it dies Kubernetes imagePullSecret Generator The registry URL nobody gets right Kubernetes cert-manager Certificates Issuer scope, and the rate limit that costs a week Kubernetes Flux HelmRelease Generator With the source it cannot work without Kubernetes Helm Chart Generator Chart.yaml, values, and working templates Kubernetes Argo CD Application Generator The defaults that are off, turned on Kubernetes Ingress Generator pathType, and the TLS secret that fails quietly Kubernetes HPA Generator Why it says unknown and never scales Kubernetes SecurityContext Generator Pod level, container level, and which wins Kubernetes Probe Generator How long it gets to start before liveness kills it Kubernetes PVC Generator Access modes your storage can actually do Kubernetes ResourceQuota Generator And the LimitRange that stops it breaking deploys Kubernetes CronJob Generator The fields that decide whether it runs Kubernetes NetworkPolicy Generator With the DNS rule already in it Kubernetes RBAC Generator And what it actually grants Kubernetes API Deprecation Checker What breaks on the next upgrade Kubernetes Kubeconfig Viewer Read it without handing it to anyone Kubernetes Quantity Parser What 512Mi, 100m and 1e3 actually mean Kubernetes Multi-Document YAML Splitter One file per object, in apply order Kubernetes .env to ConfigMap & Secret Split the credentials out on the way Kubernetes Secret Decoder See what is actually in there Kubernetes Ingress to Gateway API Which annotations silently stop working Kubernetes Manifest Visualizer What points at what, and what points at nothing Kubernetes Patch Tester Which --type, and what it deletes Kubernetes kubectl JSONPath Tester kubectl's dialect, not generic JSONPath Kubernetes Node Affinity Tester Required excludes, preferred only scores Kubernetes Helm Values Diff A missing key is a third value Kubernetes Pod and Service CIDR Fixed at cluster creation Kubernetes Secret Encoder base64 is not encryption Kubernetes API Version Checker Will this apply on that cluster Kubernetes Go Template Tester Go truthiness is not JavaScript's Kubernetes Cluster Cost Estimator At your rates, not a price table Kubernetes Kustomize Build Transformers run in kustomize's order Kubernetes Helm Chart Validator version is SemVer, appVersion is not

    Elsewhere on the site