{"data":{"slug":"github-google-skills-skills-cloud-gke-unprotected-statefulset-98e90694a918","title":"Audit and Fix GKE StatefulSet PDB Mismatches","summary":"This skill audits GKE StatefulSets for missing or mismatched PodDisruptionBudgets (PDBs) and proposes fixes to prevent disruptions during node drains. It does not modify resources or state, and the user must apply any fixes themselves.","url":"https:\/\/skillshunter.net\/skills\/github-google-skills-skills-cloud-gke-unprotected-statefulset-98e90694a918","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/github-google-skills-skills-cloud-gke-unprotected-statefulset-98e90694a918","markdown_url":"https:\/\/skillshunter.net\/skills\/github-google-skills-skills-cloud-gke-unprotected-statefulset-98e90694a918.md","download_url":"https:\/\/skillshunter.net\/skills\/github-google-skills-skills-cloud-gke-unprotected-statefulset-98e90694a918\/download","category":{"slug":"software-development","name":"Software & Development"},"editor_note":"Before executing any command, ensure that the Google Cloud CLI is installed and initialized, the `container.googleapis.com` and `recommender.googleapis.com` APIs are enabled, and the project has an active Cloud Billing account. Configure `kubectl` credentials for the cluster using the provided documentation. If the cluster belongs to a Managed Airflow environment, do not propose workload or PDB changes.","instructions":"---\nname: gke-unprotected-statefulset\nmetadata:\n  version: \"1.0.0\"\n  category: Containers\ndescription: >-\n  Audits, detects, and proposes fixes for GKE StatefulSets that lack a matching\n  PodDisruptionBudget (PDB) to prevent simultaneous Pod evictions during\n  voluntary node drains (GKE insight subtype PDB_UNPROTECTED_STATEFULSET). Use\n  when investigating the PDB_UNPROTECTED_STATEFULSET insight, checking whether\n  GKE StatefulSets have a matching PDB, or proposing fixes for selector\n  mismatches where an existing PDB does not match the StatefulSet's\n  .spec.selector. Don't use for existing PDBs that allow zero disruptions or\n  block node drains (PDB_UNPERMISSIVE), general probe and PDB setup unrelated\n  to this insight (use gke-reliability), upgrade planning (use gke-upgrades),\n  Pods stuck in Pending (use gke-workload-troubleshooting), node autoscaling or\n  capacity stockouts (use gke-cluster-autoscaler), ComputeClass configuration\n  (use gke-compute-classes), or general Kubernetes manifest generation (use\n  gke-manifest-generation).\n---\n\n# GKE unprotected StatefulSet skill\n\nUse this skill to find, verify, and propose fixes for GKE `StatefulSet`\nworkloads lacking a matching `PodDisruptionBudget` (PDB), subtype\n`PDB_UNPROTECTED_STATEFULSET`. Without a matching PDB, voluntary node drains can\ntake down all Pods at once or drop a stateful app below quorum; a zero-budget\nPDB triggers `PDB_UNPERMISSIVE`, which GKE violates after one hour (see\n[When GKE identifies workloads with vulnerability to disruption](https:\/\/docs.cloud.google.com\/kubernetes-engine\/docs\/how-to\/workload-disruption-readiness.md.txt)\nand \"Dealing with disruptions\" and \"Pod disruption budgets\" in\n[Disruptions](https:\/\/kubernetes.io\/docs\/concepts\/workloads\/pods\/disruptions\/)).\n\n> **Read-only rule**: Run read-only diagnostic commands only. Never drain,\n> delete, or re-create nodes, create or modify Kubernetes resources, dismiss or\n> change insight or recommendation state, or run any other command that changes\n> the cluster or project. Give the user any fix to apply themselves.\n\n## Usage attribution\n\n**MUST READ**: Before executing any `gcloud`, REST API, or MCP command, read and\nfollow [Usage Attribution](references\/attribution.md).\n\n## Prerequisites\n\n1.  **Google Cloud CLI, APIs, and billing**: If `gcloud` is missing or\n    uninitialized or `container.googleapis.com` is disabled, point the user to\n    [Before you begin](https:\/\/docs.cloud.google.com\/kubernetes-engine\/docs\/how-to\/optimize-with-recommenders.md.txt)\n    (never enable APIs or install software yourself). If\n    `recommender.googleapis.com` is disabled, point the user to \"gcloud\" in\n    [Enable the API](https:\/\/docs.cloud.google.com\/recommender\/docs\/enable-api.md.txt).\n    The project needs an active Cloud Billing account.\n2.  **`kubectl` and cluster credentials**: If `kubectl` or required auth plugins\n    are missing, point the user to \"Install kubectl\" and \"Install required\n    plugins\" in\n    [Install kubectl and configure cluster access](https:\/\/docs.cloud.google.com\/kubernetes-engine\/docs\/how-to\/cluster-access-for-kubectl.md.txt),\n    and use \"Store cluster information for kubectl\" on that page to configure\n    cluster credentials for `kubectl`.\n3.  **IAM roles**: Under\n    [Google Kubernetes Engine roles](https:\/\/docs.cloud.google.com\/iam\/docs\/roles-permissions\/container.md.txt)\n    and\n    [Required roles](https:\/\/docs.cloud.google.com\/kubernetes-engine\/docs\/how-to\/optimize-with-recommenders.md.txt):\n    *   Kubernetes Engine Viewer (`roles\/container.viewer`) to configure\n        credentials and read clusters, StatefulSets, PDBs, insights, and\n        recommendations.\n    *   Kubernetes Engine Developer (`roles\/container.developer`) only for the\n        user to create\/update PDBs, update\/scale StatefulSets, or dismiss\n        recommendations.\n    *   Kubernetes Engine Cluster Admin (`roles\/container.clusterAdmin`) only\n        for the user to configure cluster maintenance windows\/exclusions or\n        Standard node-pool maintenance exclusions.\n4.  **Documentation**:\n    *   [Ensure workloads are disruption-ready](https:\/\/docs.cloud.google.com\/kubernetes-engine\/docs\/how-to\/workload-disruption-readiness.md.txt)\n        (Sections: \"Identify workloads with vulnerability to disruption\", \"When\n        GKE identifies workloads with vulnerability to disruption\", \"Implement\n        the guidance to improve disruption readiness\")\n    *   [Optimize your usage of GKE with insights and recommendations](https:\/\/docs.cloud.google.com\/kubernetes-engine\/docs\/how-to\/optimize-with-recommenders.md.txt)\n        (Sections: \"Before you begin\", \"Required roles\", \"View insights and\n        recommendations\", \"Dismiss or restore recommendations\", \"Dismiss\n        recommendations using the Google Cloud CLI\")\n    *   [Enable the API](https:\/\/docs.cloud.google.com\/recommender\/docs\/enable-api.md.txt)\n        (Sections: \"gcloud\")\n    *   [Insights](https:\/\/docs.cloud.google.com\/recommender\/docs\/insights\/using-insights.md.txt)\n        (Sections: \"Description\", \"Content\", \"Target Resources\", \"State Info\",\n        \"Severity\", \"Last Refresh Time\")\n    *   [Google Kubernetes Engine roles and permissions](https:\/\/docs.cloud.google.com\/iam\/docs\/roles-permissions\/container.md.txt)\n        (Sections: \"Google Kubernetes Engine roles\")\n    *   [Install kubectl and configure cluster access](https:\/\/docs.cloud.google.com\/kubernetes-engine\/docs\/how-to\/cluster-access-for-kubectl.md.txt)\n        (Sections: \"Install kubectl\", \"Install required plugins\", \"Store cluster\n        information for kubectl\")\n    *   [Manage clusters](https:\/\/docs.cloud.google.com\/kubernetes-engine\/docs\/how-to\/managing-clusters.md.txt)\n        (Sections: \"View your clusters\")\n    *   [Deploying a stateful application](https:\/\/docs.cloud.google.com\/kubernetes-engine\/docs\/how-to\/stateful-apps.md.txt)\n        (Sections: \"Creating a StatefulSet\", \"Inspecting a StatefulSet\",\n        \"Updating a StatefulSet\", \"Scaling a StatefulSet\")\n    *   [Node upgrade strategies](https:\/\/docs.cloud.google.com\/kubernetes-engine\/docs\/concepts\/node-pool-upgrade-strategies.md.txt)\n        (Sections: \"maxSurge: GKE creates a new surge node before removing an\n        existing one\", \"maxUnavailable: GKE makes an existing node unavailable\n        to recreate it\", \"Phase 3: Drain blue pool\", \"Phase 5: Delete blue\n        pool\")\n    *   [Autopilot cluster upgrades](https:\/\/docs.cloud.google.com\/kubernetes-engine\/docs\/concepts\/cluster-upgrades-autopilot.md.txt)\n        (Sections: \"Automatic node upgrades\")\n    *   [Troubleshoot cluster upgrades](https:\/\/docs.cloud.google.com\/kubernetes-engine\/docs\/troubleshooting\/upgrades.md.txt)\n        (Sections: \"Troubleshoot node pool upgrades taking longer than usual\")\n    *   [Maintenance windows and exclusions](https:\/\/docs.cloud.google.com\/kubernetes-engine\/docs\/concepts\/maintenance-windows-and-exclusions.md.txt)\n        (Sections: \"Automatic maintenance that doesn't respect GKE maintenance\n        policies\", \"Maintenance windows\", \"Maintenance exclusions\", \"Node pool\n        maintenance exclusions\", \"Limitations on configuring maintenance\n        exclusions\", \"Example: Company's legacy database not resilient to node\n        pool upgrades\")\n    *   [Configure maintenance windows and exclusions](https:\/\/docs.cloud.google.com\/kubernetes-engine\/docs\/how-to\/maintenance-windows-and-exclusions.md.txt)\n        (Sections: \"Configure a maintenance window\", \"Configure a maintenance\n        exclusion\")\n    *   [Environment architecture](https:\/\/docs.cloud.google.com\/composer\/docs\/composer-2\/environment-architecture.md.txt)\n        (Sections: \"Environment's cluster\")\n    *   [Get support](https:\/\/docs.cloud.google.com\/kubernetes-engine\/docs\/getting-support.md.txt)\n        (Sections: \"Before you contact support\", \"Recommendations for efficient\n        support\")\n    *   [Disruptions](https:\/\/kubernetes.io\/docs\/concepts\/workloads\/pods\/disruptions\/)\n        (Sections: \"Voluntary and involuntary disruptions\", \"Dealing with\n        disruptions\", \"Pod disruption budgets\")\n    *   [Specifying a Disruption Budget for your Application](https:\/\/kubernetes.io\/docs\/tasks\/run-application\/configure-pdb\/)\n        (Sections: \"Identify an Application to Protect\", \"Think about how your\n        application reacts to disruptions\", \"Rounding logic when specifying\n        percentages\", \"Specifying a PodDisruptionBudget\", \"Create the PDB\n        object\", \"Check the status of the PDB\", \"Healthiness of a Pod\",\n        \"Unhealthy Pod Eviction Policy\", \"Arbitrary workloads and arbitrary\n        selectors\")\n    *   [Configure Liveness, Readiness and Startup Probes](https:\/\/kubernetes.io\/docs\/tasks\/configure-pod-container\/configure-liveness-readiness-startup-probes\/)\n        (Sections: \"Define readiness probes\")\n\nThis skill creates no billable resources, so no teardown is required.\n\n## Diagnostic workflow\n\n> **Scope and Managed Airflow check**:\n> *   **Managed Service for Apache Airflow (formerly Cloud Composer)**: Under\n>     [Environment's cluster](https:\/\/docs.cloud.google.com\/composer\/docs\/composer-2\/environment-architecture.md.txt),\n>     clusters for Managed Airflow and workloads deployed into them are managed\n>     by Google: do not introduce changes in the environment's cluster (doing so\n>     might break the environment). When the user says the cluster belongs to a\n>     Managed Airflow (or Cloud Composer) environment, do not propose workload\n>     or PDB changes; ask when that isn't clear.\n> *   **Unpermissive PDBs (`PDB_UNPERMISSIVE`)**: For requests solely about\n>     `PDB_UNPERMISSIVE` or drains blocked by\n>     `\"Cannot evict pod as it would violate the pod's disruption budget.\"` on a\n>     matching PDB, stop and point the user to\n>     [When GKE identifies workloads with vulnerability to disruption](https:\/\/docs.cloud.google.com\/kubernetes-engine\/docs\/how-to\/workload-disruption-readiness.md.txt)\n>     and\n>     [Troubleshoot node pool upgrades taking longer than usual](https:\/\/docs.cloud.google.com\/kubernetes-engine\/docs\/troubleshooting\/upgrades.md.txt)\n>     to adjust `minAvailable` or `maxUnavailable` themselves. In an audit,\n>     handle matching unpermissive PDBs via \"When a matching PDB already\n>     exists\".\n> *   **Other GKE topics**: Hand off general probe\/PDB setup to\n>     `gke-reliability`, upgrade planning to `gke-upgrades`, `Pending` Pods to\n>     `gke-workload-troubleshooting`, autoscaling\/stockouts to\n>     `gke-cluster-autoscaler`, ComputeClasses to `gke-compute-classes`, and\n>     general manifest generation to `gke-manifest-generation`.\n> *   **Provided manifests, insights, or `kubectl` output**: After the Managed\n>     Airflow check, if insight\/recommendation details, manifests, or `kubectl`\n>     output are provided, capture any `{project_id}`, `{cluster_name}`, and\n>     `{location}`, skip Steps 1\u20132 (honoring dismissed recommendations per Step\n>     2), and evaluate every workload in Step 3 without discovery commands.\n\n### Step 1: Identify the target cluster\n\nObtain `{project_id}`, `{cluster_name}`, and `{location}` (control plane region\nor zone) from the prompt. If `{project_id}` is unknown, ask the user; if\n`{cluster_name}` or `{location}` is unknown, ask the user or follow\n[View your clusters](https:\/\/docs.cloud.google.com\/kubernetes-engine\/docs\/how-to\/managing-clusters.md.txt)\nfor `{project_id}`. Ask when it isn't clear whether `{cluster_name}` belongs to\na Managed Airflow environment.\n\n### Step 2: Check for `PDB_UNPROTECTED_STATEFULSET` insights and recommendations\n\n1.  **Query insights**: Under\n    [Identify workloads with vulnerability to disruption](https:\/\/docs.cloud.google.com\/kubernetes-engine\/docs\/how-to\/workload-disruption-readiness.md.txt),\n    disruption-readiness insights are available only via `gcloud` or the\n    Recommender API (not the Google Cloud console). Follow `gcloud` or API\n    instructions in\n    [View insights and recommendations](https:\/\/docs.cloud.google.com\/kubernetes-engine\/docs\/how-to\/optimize-with-recommenders.md.txt)\n    for `{project_id}` and `{location}`, filtering for\n    `PDB_UNPROTECTED_STATEFULSET`.\n2.  **Filter active insights and check recommendation state**: Keep `ACTIVE`\n    insights matching `{cluster_name}` via \"State Info\" and \"Target Resources\",\n    record \"Severity\" and \"Last Refresh Time\", and read `{statefulset_name}`\n    (`{namespace}` if shown), suggested selector labels (\"Description\" and\n    \"Content\"), and `associatedRecommendations.recommendation` via\n    [Insights](https:\/\/docs.cloud.google.com\/recommender\/docs\/insights\/using-insights.md.txt),\n    \"View insights and recommendations\" and \"Dismiss recommendations using the\n    Google Cloud CLI\" in\n    [Optimize your usage of GKE with insights and recommendations](https:\/\/docs.cloud.google.com\/kubernetes-engine\/docs\/how-to\/optimize-with-recommenders.md.txt),\n    and \"When GKE identifies workloads with vulnerability to disruption\" and\n    \"Implement the guidance to improve disruption readiness\" in\n    [Ensure workloads are disruption-ready](https:\/\/docs.cloud.google.com\/kubernetes-engine\/docs\/how-to\/workload-disruption-readiness.md.txt).\n    Check the recommendation's state using only the read-only list (`ACTIVE`\n    filter hides dismissed recommendations) or describe step in \"Dismiss\n    recommendations using the Google Cloud CLI\"\u2014never run `mark-dismissed`. If\n    `{namespace}` or `{statefulset_name}` is unknown, ask or point to\n    [Inspecting a StatefulSet](https:\/\/docs.cloud.google.com\/kubernetes-engine\/docs\/how-to\/stateful-apps.md.txt).\n3.  **Branch on results** (include the `.md.txt` links from items 1\u20132 when\n    pointing the user to those sections):\n    *   **Active insights**: For each active insight, if its associated\n        recommendation was dismissed, report that the user dismissed it instead\n        of recommending a PDB again (dismissing only hides it in the console\n        while it remains discoverable via `gcloud` and the Recommender API; see\n        [Dismiss or restore recommendations](https:\/\/docs.cloud.google.com\/kubernetes-engine\/docs\/how-to\/optimize-with-recommenders.md.txt)).\n        Otherwise continue to Step 3 for `{statefulset_name}` in `{namespace}`.\n    *   **No active insight for `{cluster_name}`**: Recommendations are assessed\n        once daily (\"Implement the guidance to improve disruption readiness\" in\n        item 2), so recent changes may not appear yet. Proceed to Step 3 if\n        `{statefulset_name}` and `{namespace}` were given; otherwise report none\n        was found and ask for them (or point to \"Inspecting a StatefulSet\" in\n        item 2).\n    *   **API disabled or unreachable**: If `recommender.googleapis.com` is\n        disabled, point to \"gcloud\" in\n        [Enable the API](https:\/\/docs.cloud.google.com\/recommender\/docs\/enable-api.md.txt)\n        (and continue to Step 3 if `{statefulset_name}` and `{namespace}` are\n        known). If unreachable, point to \"View insights and recommendations\"\n        (item 1), \"Inspecting a StatefulSet\" (item 2), and\n        [Check the status of the PDB](https:\/\/kubernetes.io\/docs\/tasks\/run-application\/configure-pdb\/),\n        continuing with Step 3 once output is shared.\n\n### Step 3: Inspect the StatefulSet selector and existing PDBs\n\nConfigure `kubectl` credentials for `{cluster_name}` in `{location}` via\n[Store cluster information for kubectl](https:\/\/docs.cloud.google.com\/kubernetes-engine\/docs\/how-to\/cluster-access-for-kubectl.md.txt),\nand evaluate every StatefulSet in scope (never stop after the first):\n\n1.  **Inspect the StatefulSet**: Follow \"Inspecting a StatefulSet\" (and see\n    \"Creating a StatefulSet\" for `spec.template.metadata.labels`) in\n    [Deploying a stateful application](https:\/\/docs.cloud.google.com\/kubernetes-engine\/docs\/how-to\/stateful-apps.md.txt)\n    for `{statefulset_name}` in `{namespace}` to read `{replicas}`\n    (`spec.replicas`), `{statefulset_selector}` (`.spec.selector`), and\n    `spec.template.metadata.labels`, plus container `readinessProbe` (see\n    [Define readiness probes](https:\/\/kubernetes.io\/docs\/tasks\/configure-pod-container\/configure-liveness-readiness-startup-probes\/)).\n    Per\n    [Identify an Application to Protect](https:\/\/kubernetes.io\/docs\/tasks\/run-application\/configure-pdb\/),\n    `.spec.selector` goes into a matching PDB's `.spec.selector`. If\n    `{statefulset_name}` is not found, ask whether it was deleted:\n    *   If the user confirms it was deleted, tell them no PDB is needed and the\n        recommendation can take up to 24 hours to resolve (see\n        [Implement the guidance to improve disruption readiness](https:\/\/docs.cloud.google.com\/kubernetes-engine\/docs\/how-to\/workload-disruption-readiness.md.txt)).\n    *   Otherwise, re-check `{namespace}` and any Step 2 insight's\n        [Target Resources](https:\/\/docs.cloud.google.com\/recommender\/docs\/insights\/using-insights.md.txt)\n        (it might target another cluster); if still not found, direct the user\n        to Cloud Customer Care (\"Before you contact support\" and\n        \"Recommendations for efficient support\" in\n        [Get support](https:\/\/docs.cloud.google.com\/kubernetes-engine\/docs\/getting-support.md.txt)).\n2.  **Inspect PDBs and selector overlap in `{namespace}`**: Follow \"Check the\n    status of the PDB\", \"Specifying a PodDisruptionBudget\", \"Identify an\n    Application to Protect\", and \"Arbitrary workloads and arbitrary selectors\"\n    in\n    [Specifying a Disruption Budget for your Application](https:\/\/kubernetes.io\/docs\/tasks\/run-application\/configure-pdb\/)\n    to read each PDB's `.spec.selector` (`{}` matches every Pod in\n    `{namespace}`), `minAvailable`, `maxUnavailable`, `status.expectedPods`, and\n    `status.disruptionsAllowed`. `PDB_UNPROTECTED_STATEFULSET` alerts when no\n    existing PDB labels match `{statefulset_selector}` (see\n    [When GKE identifies workloads with vulnerability to disruption](https:\/\/docs.cloud.google.com\/kubernetes-engine\/docs\/how-to\/workload-disruption-readiness.md.txt)).\n    Count only a PDB whose `.spec.selector` equals `{statefulset_selector}` as a\n    match; record any matching `{existing_pdb_name}`, and record any\n    `{existing_pdb_name}` selecting the Pods without matching (`{}`, subset\n    labels, extra `spec.template.metadata.labels`, or a Pod subset), noting\n    whether it also selects other workloads' Pods.\n\n### Step 4: Classify each evaluated StatefulSet from live state\n\nClassify each workload into one category from Step 3, reporting any Step 2\n[Severity](https:\/\/docs.cloud.google.com\/recommender\/docs\/insights\/using-insights.md.txt):\n\n1.  **`StatefulSet Protected`**: `{existing_pdb_name}` in `{namespace}` equals\n    `{statefulset_selector}` (any `{replicas}`). Record\n    `{other_statefulset_name}` and `{other_statefulset_summary}` via \"When a\n    matching PDB already exists\".\n2.  **`Single-Replica or Scaled-to-Zero StatefulSet`**: `{replicas} <= 1` and no\n    PDB in `{namespace}` equals `{statefulset_selector}`. Record\n    `{other_statefulset_name}` and `{other_statefulset_summary}` via\n    \"Single-replica and scaled-to-zero StatefulSets\".\n3.  **`Unprotected StatefulSet`**: `{replicas} > 1` and no PDB in `{namespace}`\n    equals `{statefulset_selector}`. Record missing-PDB or `{existing_pdb_name}`\n    mismatch details in `{classification_summary}`; follow \"Unprotected\n    StatefulSet (add or update a PDB)\".\n\nCount the `Unprotected StatefulSet` workloads as `{count}`.\n\n## Remediation\n\nGive the user fixes to apply themselves (never modify resources or state).\n\n### Unprotected StatefulSet (add or update a PDB)\n\n1.  **Specify `.spec.selector` and disruption budget**: Point to \"When GKE\n    identifies workloads with vulnerability to disruption\" and \"Implement the\n    guidance to improve disruption readiness\" in\n    [Ensure workloads are disruption-ready](https:\/\/docs.cloud.google.com\/kubernetes-engine\/docs\/how-to\/workload-disruption-readiness.md.txt),\n    [Pod disruption budgets](https:\/\/kubernetes.io\/docs\/concepts\/workloads\/pods\/disruptions\/),\n    and \"Identify an Application to Protect\", \"Think about how your application\n    reacts to disruptions\", \"Rounding logic when specifying percentages\", and\n    \"Specifying a PodDisruptionBudget\" in\n    [Specifying a Disruption Budget for your Application](https:\/\/kubernetes.io\/docs\/tasks\/run-application\/configure-pdb\/):\n    *   **Selector**: Copy `{statefulset_selector}` (`.spec.selector`, matching\n        Step 2's recommendation when current) into the PDB's `.spec.selector`,\n        without adding Pod-template-only `spec.template.metadata.labels` (see\n        [Creating a StatefulSet](https:\/\/docs.cloud.google.com\/kubernetes-engine\/docs\/how-to\/stateful-apps.md.txt)).\n    *   **Budget**: Set only one of `maxUnavailable` (`1` adapts to scale;\n        requires one shared controller) or `minAvailable` (quorum, such as `2`\n        of `3` or `3` of `5`). Never set `maxUnavailable` to `0`\/`0%` or\n        `minAvailable` to `100%` or an integer\/rounded-up percentage not less\n        than `{replicas}` (`PDB_UNPERMISSIVE`, causing 1-hour drain waits).\n2.  **Create vs. update overlapping `{existing_pdb_name}`**: Under \"Identify an\n    Application to Protect\", \"Specifying a PodDisruptionBudget\", \"Create the PDB\n    object\", and \"Arbitrary workloads and arbitrary selectors\" in\n    [Specifying a Disruption Budget for your Application](https:\/\/kubernetes.io\/docs\/tasks\/run-application\/configure-pdb\/)\n    (eviction is disallowed for any Pod covered by multiple PDBs):\n    *   **No PDB selects the Pods**: Point to \"Create the PDB object\" to add it.\n    *   **`{existing_pdb_name}` selects only this StatefulSet's Pods** (empty\n        `{}`, subset labels, extra `spec.template.metadata.labels`, or a Pod\n        subset): Advise **not** creating a second PDB; point to \"Create the PDB\n        object\" to update `{existing_pdb_name}` in place to\n        `{statefulset_selector}`.\n    *   **`{existing_pdb_name}` also selects other workloads' Pods** (empty\n        `{}`, shared subset labels, or a shared Pod-template label): Warn that\n        `maxUnavailable` requires all selected Pods to share one controller\n        (bare or unsupported-controller Pods allow only integer `minAvailable`),\n        the budget is shared across all selected Pods rather than per-workload\n        quorum, and adding a second PDB blocks eviction while narrowing\n        `{existing_pdb_name}` alone drops coverage from the other workloads;\n        point to those sections to give each controller a non-overlapping PDB\n        matching `.spec.selector`.\n3.  **Readiness probes (`PDB_STATEFULSET_WITHOUT_PROBES`)**: PDBs respect\n    readiness probes when they look at which Pods can be counted as healthy, and\n    a Pod counts as healthy when it has a `.status.conditions` item with\n    `type=\"Ready\"` and `status=\"True\"`. If missing, point to\n    [Healthiness of a Pod](https:\/\/kubernetes.io\/docs\/tasks\/run-application\/configure-pdb\/),\n    [When GKE identifies workloads with vulnerability to disruption](https:\/\/docs.cloud.google.com\/kubernetes-engine\/docs\/how-to\/workload-disruption-readiness.md.txt),\n    [Define readiness probes](https:\/\/kubernetes.io\/docs\/tasks\/configure-pod-container\/configure-liveness-readiness-startup-probes\/),\n    and\n    [Updating a StatefulSet](https:\/\/docs.cloud.google.com\/kubernetes-engine\/docs\/how-to\/stateful-apps.md.txt).\n4.  **Resolution window and dismissal**: Recommendations are assessed once daily\n    and take up to 24 hours to resolve after changes (see\n    [Implement the guidance to improve disruption readiness](https:\/\/docs.cloud.google.com\/kubernetes-engine\/docs\/how-to\/workload-disruption-readiness.md.txt)).\n    Only if the user decides not to add a PDB, point to \"Dismiss or restore\n    recommendations\" and \"Dismiss recommendations using the Google Cloud CLI\" in\n    [Optimize your usage of GKE with insights and recommendations](https:\/\/docs.cloud.google.com\/kubernetes-engine\/docs\/how-to\/optimize-with-recommenders.md.txt):\n    dismissing only hides a recommendation for all users in the console (where\n    it doesn't appear again even if GKE detects the same behavior), while it\n    remains discoverable via the Google Cloud CLI and Recommender API.\n\n### Single-replica and scaled-to-zero StatefulSets\n\n1.  **If `{replicas} == 0`**: Ask whether it stays at `0` or scales up (under\n    [Check the status of the PDB](https:\/\/kubernetes.io\/docs\/tasks\/run-application\/configure-pdb\/),\n    zero matching Pods shows `ALLOWED DISRUPTIONS: 0`). If kept at `0`, no Pods\n    run to disrupt (for dismissal, see item 4 of \"Unprotected StatefulSet (add\n    or update a PDB)\" above); if scaling to `1`, follow items 2\u20133; if scaling\n    above `1` (see\n    [Scaling a StatefulSet](https:\/\/docs.cloud.google.com\/kubernetes-engine\/docs\/how-to\/stateful-apps.md.txt)),\n    follow \"Unprotected StatefulSet (add or update a PDB)\" for that target.\n2.  **Explain 1-replica PDB trade-offs**: PDBs target replicated apps (\"Dealing\n    with disruptions\" and \"Pod disruption budgets\" in\n    [Disruptions](https:\/\/kubernetes.io\/docs\/concepts\/workloads\/pods\/disruptions\/)).\n    Under \"Think about how your application reacts to disruptions\" and\n    \"Specifying a PodDisruptionBudget\" (`Example 4`) in\n    [Specifying a Disruption Budget for your Application](https:\/\/kubernetes.io\/docs\/tasks\/run-application\/configure-pdb\/),\n    `maxUnavailable: 1` or a positive percentage still allows evicting the lone\n    Pod (`100%` unavailability), while `maxUnavailable` of `0`\/`0%` or\n    `minAvailable` of `1`\/`100%` triggers `PDB_UNPERMISSIVE` and a 1-hour drain\n    wait on Standard surge and Autopilot upgrades (see item 3 of \"When a\n    matching PDB already exists\" below). If a non-matching `{existing_pdb_name}`\n    selects the Pod, handle overlap per item 2 of \"Unprotected StatefulSet (add\n    or update a PDB)\".\n3.  **Documented single-instance options**: Point the user to:\n    *   Omit a PDB and tolerate brief drain downtime (see\n        [Think about how your application reacts to disruptions](https:\/\/kubernetes.io\/docs\/tasks\/run-application\/configure-pdb\/)).\n        If an active recommendation exists and the user decides against a PDB,\n        share item 4 of \"Unprotected StatefulSet (add or update a PDB)\" above.\n    *   Scale above `1` replica before adding a PDB via\n        [Scaling a StatefulSet](https:\/\/docs.cloud.google.com\/kubernetes-engine\/docs\/how-to\/stateful-apps.md.txt).\n    *   Control maintenance timing via a cluster maintenance window\/exclusion or\n        (Standard only) a node-pool maintenance exclusion\u2014noting maintenance\n        policies don't block all automatic maintenance and on Autopilot GKE\n        honors the configuration if possible; see \"Automatic maintenance that\n        doesn't respect GKE maintenance policies\", \"Maintenance windows\",\n        \"Maintenance exclusions\", \"Node pool maintenance exclusions\",\n        \"Limitations on configuring maintenance exclusions\", and \"Example:\n        Company's legacy database not resilient to node pool upgrades\" in\n        [Maintenance windows and exclusions](https:\/\/docs.cloud.google.com\/kubernetes-engine\/docs\/concepts\/maintenance-windows-and-exclusions.md.txt),\n        [Automatic node upgrades](https:\/\/docs.cloud.google.com\/kubernetes-engine\/docs\/concepts\/cluster-upgrades-autopilot.md.txt),\n        and \"Configure a maintenance window\" and \"Configure a maintenance\n        exclusion\" in\n        [Configure maintenance windows and exclusions](https:\/\/docs.cloud.google.com\/kubernetes-engine\/docs\/how-to\/maintenance-windows-and-exclusions.md.txt).\n\n### When a matching PDB already exists\n\n*   **Stale active insight**: If an active `PDB_UNPROTECTED_STATEFULSET` insight\n    still appears for `{other_statefulset_name}`, ask when `{existing_pdb_name}`\n    was created or updated and check \"Target Resources\" and \"Last Refresh Time\"\n    in\n    [Insights](https:\/\/docs.cloud.google.com\/recommender\/docs\/insights\/using-insights.md.txt).\n    If \"Last Refresh Time\" is earlier than the PDB change, explain the daily\n    24-hour assessment window (see\n    [Implement the guidance to improve disruption readiness](https:\/\/docs.cloud.google.com\/kubernetes-engine\/docs\/how-to\/workload-disruption-readiness.md.txt))\n    and advise **not** dismissing just to clear normal lag: under\n    [Dismiss or restore recommendations](https:\/\/docs.cloud.google.com\/kubernetes-engine\/docs\/how-to\/optimize-with-recommenders.md.txt),\n    dismissing only hides a recommendation for all users in the console (where\n    it doesn't appear again even if GKE detects the same behavior), while it\n    remains discoverable via `gcloud` and the Recommender API. If \"Last Refresh\n    Time\" is later than the PDB change and the insight is still active, direct\n    the user to Cloud Customer Care via \"Before you contact support\" and\n    \"Recommendations for efficient support\" in\n    [Get support](https:\/\/docs.cloud.google.com\/kubernetes-engine\/docs\/getting-support.md.txt).\n*   **Single or zero replicas**: If `{replicas} <= 1`, on `1` replica even a\n    permissive PDB allows `100%` unavailability (`0` matches zero Pods); follow\n    \"Single-replica and scaled-to-zero StatefulSets\".\n\nCheck\u2014or point the user to check:\n\n1.  **Permissiveness (`PDB_UNPERMISSIVE`)**: Verify via \"Check the status of the\n    PDB\", \"Rounding logic when specifying percentages\", and \"Specifying a\n    PodDisruptionBudget\" in\n    [Specifying a Disruption Budget for your Application](https:\/\/kubernetes.io\/docs\/tasks\/run-application\/configure-pdb\/)\n    that when `{replicas} > 0` and Pods are healthy, `ALLOWED DISRUPTIONS`\n    (`status.disruptionsAllowed`) is non-zero (`minAvailable`, rounded up for\n    percentages, is less than `{replicas}`, or `maxUnavailable > 0`); otherwise\n    point to\n    [When GKE identifies workloads with vulnerability to disruption](https:\/\/docs.cloud.google.com\/kubernetes-engine\/docs\/how-to\/workload-disruption-readiness.md.txt)\n    and\n    [Troubleshoot node pool upgrades taking longer than usual](https:\/\/docs.cloud.google.com\/kubernetes-engine\/docs\/troubleshooting\/upgrades.md.txt).\n2.  **Readiness probes (`PDB_STATEFULSET_WITHOUT_PROBES`)**: Check container\n    `readinessProbe`; if missing, point to item 3 of \"Unprotected StatefulSet\n    (add or update a PDB)\" above.\n3.  **Disruption despite both**: Point the user to:\n    *   **One-hour surge PDB timeout** (\"maxSurge: GKE creates a new surge node\n        before removing an existing one\" and \"maxUnavailable: GKE makes an\n        existing node unavailable to recreate it\") and **Standard blue-green\n        pool deletion** bypassing PDBs (\"Phase 3: Drain blue pool\" and \"Phase 5:\n        Delete blue pool\") in\n        [Node upgrade strategies](https:\/\/docs.cloud.google.com\/kubernetes-engine\/docs\/concepts\/node-pool-upgrade-strategies.md.txt),\n        plus the 1-hour PDB limit in\n        [Automatic node upgrades](https:\/\/docs.cloud.google.com\/kubernetes-engine\/docs\/concepts\/cluster-upgrades-autopilot.md.txt)\n        and\n        [When GKE identifies workloads with vulnerability to disruption](https:\/\/docs.cloud.google.com\/kubernetes-engine\/docs\/how-to\/workload-disruption-readiness.md.txt).\n    *   **`unhealthyPodEvictionPolicy: AlwaysAllow`** evicting running non-Ready\n        Pods regardless of budget (see\n        [Unhealthy Pod Eviction Policy](https:\/\/kubernetes.io\/docs\/tasks\/run-application\/configure-pdb\/)).\n    *   **Involuntary disruptions or direct deletions** bypassing PDBs\n        (\"Voluntary and involuntary disruptions\" and \"Pod disruption budgets\" in\n        [Disruptions](https:\/\/kubernetes.io\/docs\/concepts\/workloads\/pods\/disruptions\/)).\n    *   **Escalation**: Direct the user to Cloud Customer Care via \"Before you\n        contact support\" and \"Recommendations for efficient support\" in\n        [Get support](https:\/\/docs.cloud.google.com\/kubernetes-engine\/docs\/getting-support.md.txt).\n\n## Output format\n\nCite relied-on doc sections by exact title and link. Omit unprovided\n`{cluster_name}`, `{location}`, or `{project_id}`; omit `Unprotected\nStatefulSets detected` and `Recommended remediation` when `{count}` is `0`; omit\n`Other evaluated StatefulSets` when none apply (`{other_statefulset_summary}`\ncovers single-replica\/scaled-to-zero options or `{existing_pdb_name}`\npermissiveness, readiness-probe, and 24-hour lag notes); and report Step 2's\n[Severity](https:\/\/docs.cloud.google.com\/recommender\/docs\/insights\/using-insights.md.txt)\nwhen retrieved.\n\n```markdown\n### Unprotected StatefulSets detected\n\nFound {count} `StatefulSet` workload(s) without a matching\n`PodDisruptionBudget` on cluster `{cluster_name}` (`{location}`, Project:\n`{project_id}`):\n\n| StatefulSet | Namespace | Replicas | Classification & details |\n| :--- | :--- | :---: | :--- |\n| `{statefulset_name}` | `{namespace}` | {replicas} | {classification_summary} |\n\n### Other evaluated StatefulSets\n\n*   `{other_statefulset_name}` (`{namespace}`, `replicas: {replicas}`):\n    {other_statefulset_summary}\n\n### Recommended remediation\n\n*   For `{statefulset_name}` (`{namespace}`): follow \"Identify an Application\n    to Protect\", \"Specifying a PodDisruptionBudget\", \"Create the PDB object\",\n    and \"Arbitrary workloads and arbitrary selectors\" in\n    [Specifying a Disruption Budget for your Application](https:\/\/kubernetes.io\/docs\/tasks\/run-application\/configure-pdb\/)\n    to create a `PodDisruptionBudget` copying `{statefulset_selector}` with an\n    appropriate budget, or update `{existing_pdb_name}` without overlapping\n    PDBs.\n\n### Verification\n\n*   Follow\n    [Check the status of the PDB](https:\/\/kubernetes.io\/docs\/tasks\/run-application\/configure-pdb\/)\n    to verify `ALLOWED DISRUPTIONS` (`status.disruptionsAllowed`) is non-zero\n    and `status.expectedPods` matches `{replicas}`.\n*   Recommendations are assessed once daily and take up to 24 hours to resolve\n    (see\n    [Implement the guidance to improve disruption readiness](https:\/\/docs.cloud.google.com\/kubernetes-engine\/docs\/how-to\/workload-disruption-readiness.md.txt)).\n```\n","use_cases":["Investigating PDB_UNPROTECTED_STATEFULSET insights","Checking if GKE StatefulSets have a matching PDB","Proposing fixes for selector mismatches where an existing PDB does not match the StatefulSet's .spec.selector"],"limitations":[],"compatibility":[],"setup_tip":null,"sample_input":null,"sample_output":null,"source_url":"https:\/\/github.com\/google\/skills\/blob\/c413c1fdc1714f2e4ae44a449b9744348197119c\/skills\/cloud\/gke-unprotected-statefulset\/SKILL.md","source_commit":"c413c1fdc1714f2e4ae44a449b9744348197119c","license":null,"version":null,"listing_approved_at":"2026-11-27","created_at":"2026-11-26T11:02:16.000000Z","updated_at":"2026-11-27T07:43:08.000000Z","seo_title":"Audit GKE StatefulSet PDB Mismatches","seo_description":"Audit GKE StatefulSets for missing or mismatched PodDisruptionBudgets (PDBs) and propose fixes to prevent disruptions during node drains.","seo_keywords":["GKE StatefulSet PDB audit","Fix PDB mismatch in GKE","GKE disruption budget check","StatefulSet PDB mismatch fix"]}}