GKE Unprotected StatefulSet Check

GKE Unprotected StatefulSet Check

Finds GKE StatefulSets lacking a matching PodDisruptionBudget, checks selector mismatches in read-only mode, and proposes manifests that protect them during node drains.

Skill files2 files

references/

SKILL.md499 lines
1
---
2
name: gke-unprotected-statefulset
3
metadata:
4
version: "1.0.0"
5
category: Containers
6
description: >-
7
Audits, detects, and proposes fixes for GKE StatefulSets that lack a matching
8
PodDisruptionBudget (PDB) to prevent simultaneous Pod evictions during
9
voluntary node drains (GKE insight subtype PDB_UNPROTECTED_STATEFULSET). Use
10
when investigating the PDB_UNPROTECTED_STATEFULSET insight, checking whether
11
GKE StatefulSets have a matching PDB, or proposing fixes for selector
12
mismatches where an existing PDB does not match the StatefulSet's
13
.spec.selector. Don't use for existing PDBs that allow zero disruptions or
14
block node drains (PDB_UNPERMISSIVE), general probe and PDB setup unrelated
15
to this insight (use gke-reliability), upgrade planning (use gke-upgrades),
16
Pods stuck in Pending (use gke-workload-troubleshooting), node autoscaling or
17
capacity stockouts (use gke-cluster-autoscaler), ComputeClass configuration
18
(use gke-compute-classes), or general Kubernetes manifest generation (use
19
gke-manifest-generation).
20
---
21
22
# GKE unprotected StatefulSet skill
23
24
Use this skill to find, verify, and propose fixes for GKE `StatefulSet`
25
workloads lacking a matching `PodDisruptionBudget` (PDB), subtype
26
`PDB_UNPROTECTED_STATEFULSET`. Without a matching PDB, voluntary node drains can
27
take down all Pods at once or drop a stateful app below quorum; a zero-budget
28
PDB triggers `PDB_UNPERMISSIVE`, which GKE violates after one hour (see
29
[When GKE identifies workloads with vulnerability to disruption](https://docs.cloud.google.com/kubernetes-engine/docs/how-to/workload-disruption-readiness.md.txt)
30
and "Dealing with disruptions" and "Pod disruption budgets" in
31
[Disruptions](https://kubernetes.io/docs/concepts/workloads/pods/disruptions/)).
32
33
> **Read-only rule**: Run read-only diagnostic commands only. Never drain,
34
> delete, or re-create nodes, create or modify Kubernetes resources, dismiss or
35
> change insight or recommendation state, or run any other command that changes
36
> the cluster or project. Give the user any fix to apply themselves.
37
38
## Usage attribution
39
40
**MUST READ**: Before executing any `gcloud`, REST API, or MCP command, read and
41
follow [Usage Attribution](references/attribution.md).
42
43
## Prerequisites
44
45
1. **Google Cloud CLI, APIs, and billing**: If `gcloud` is missing or
46
uninitialized or `container.googleapis.com` is disabled, point the user to
47
[Before you begin](https://docs.cloud.google.com/kubernetes-engine/docs/how-to/optimize-with-recommenders.md.txt)
48
(never enable APIs or install software yourself). If
49
`recommender.googleapis.com` is disabled, point the user to "gcloud" in
50
[Enable the API](https://docs.cloud.google.com/recommender/docs/enable-api.md.txt).
51
The project needs an active Cloud Billing account.
52
2. **`kubectl` and cluster credentials**: If `kubectl` or required auth plugins
53
are missing, point the user to "Install kubectl" and "Install required
54
plugins" in
55
[Install kubectl and configure cluster access](https://docs.cloud.google.com/kubernetes-engine/docs/how-to/cluster-access-for-kubectl.md.txt),
56
and use "Store cluster information for kubectl" on that page to configure
57
cluster credentials for `kubectl`.
58
3. **IAM roles**: Under
59
[Google Kubernetes Engine roles](https://docs.cloud.google.com/iam/docs/roles-permissions/container.md.txt)
60
and
61
[Required roles](https://docs.cloud.google.com/kubernetes-engine/docs/how-to/optimize-with-recommenders.md.txt):
62
* Kubernetes Engine Viewer (`roles/container.viewer`) to configure
63
credentials and read clusters, StatefulSets, PDBs, insights, and
64
recommendations.
65
* Kubernetes Engine Developer (`roles/container.developer`) only for the
66
user to create/update PDBs, update/scale StatefulSets, or dismiss
67
recommendations.
68
* Kubernetes Engine Cluster Admin (`roles/container.clusterAdmin`) only
69
for the user to configure cluster maintenance windows/exclusions or
70
Standard node-pool maintenance exclusions.
71
4. **Documentation**:
72
* [Ensure workloads are disruption-ready](https://docs.cloud.google.com/kubernetes-engine/docs/how-to/workload-disruption-readiness.md.txt)
73
(Sections: "Identify workloads with vulnerability to disruption", "When
74
GKE identifies workloads with vulnerability to disruption", "Implement
75
the guidance to improve disruption readiness")
76
* [Optimize your usage of GKE with insights and recommendations](https://docs.cloud.google.com/kubernetes-engine/docs/how-to/optimize-with-recommenders.md.txt)
77
(Sections: "Before you begin", "Required roles", "View insights and
78
recommendations", "Dismiss or restore recommendations", "Dismiss
79
recommendations using the Google Cloud CLI")
80
* [Enable the API](https://docs.cloud.google.com/recommender/docs/enable-api.md.txt)
81
(Sections: "gcloud")
82
* [Insights](https://docs.cloud.google.com/recommender/docs/insights/using-insights.md.txt)
83
(Sections: "Description", "Content", "Target Resources", "State Info",
84
"Severity", "Last Refresh Time")
85
* [Google Kubernetes Engine roles and permissions](https://docs.cloud.google.com/iam/docs/roles-permissions/container.md.txt)
86
(Sections: "Google Kubernetes Engine roles")
87
* [Install kubectl and configure cluster access](https://docs.cloud.google.com/kubernetes-engine/docs/how-to/cluster-access-for-kubectl.md.txt)
88
(Sections: "Install kubectl", "Install required plugins", "Store cluster
89
information for kubectl")
90
* [Manage clusters](https://docs.cloud.google.com/kubernetes-engine/docs/how-to/managing-clusters.md.txt)
91
(Sections: "View your clusters")
92
* [Deploying a stateful application](https://docs.cloud.google.com/kubernetes-engine/docs/how-to/stateful-apps.md.txt)
93
(Sections: "Creating a StatefulSet", "Inspecting a StatefulSet",
94
"Updating a StatefulSet", "Scaling a StatefulSet")
95
* [Node upgrade strategies](https://docs.cloud.google.com/kubernetes-engine/docs/concepts/node-pool-upgrade-strategies.md.txt)
96
(Sections: "maxSurge: GKE creates a new surge node before removing an
97
existing one", "maxUnavailable: GKE makes an existing node unavailable
98
to recreate it", "Phase 3: Drain blue pool", "Phase 5: Delete blue
99
pool")
100
* [Autopilot cluster upgrades](https://docs.cloud.google.com/kubernetes-engine/docs/concepts/cluster-upgrades-autopilot.md.txt)
101
(Sections: "Automatic node upgrades")
102
* [Troubleshoot cluster upgrades](https://docs.cloud.google.com/kubernetes-engine/docs/troubleshooting/upgrades.md.txt)
103
(Sections: "Troubleshoot node pool upgrades taking longer than usual")
104
* [Maintenance windows and exclusions](https://docs.cloud.google.com/kubernetes-engine/docs/concepts/maintenance-windows-and-exclusions.md.txt)
105
(Sections: "Automatic maintenance that doesn't respect GKE maintenance
106
policies", "Maintenance windows", "Maintenance exclusions", "Node pool
107
maintenance exclusions", "Limitations on configuring maintenance
108
exclusions", "Example: Company's legacy database not resilient to node
109
pool upgrades")
110
* [Configure maintenance windows and exclusions](https://docs.cloud.google.com/kubernetes-engine/docs/how-to/maintenance-windows-and-exclusions.md.txt)
111
(Sections: "Configure a maintenance window", "Configure a maintenance
112
exclusion")
113
* [Environment architecture](https://docs.cloud.google.com/composer/docs/composer-2/environment-architecture.md.txt)
114
(Sections: "Environment's cluster")
115
* [Get support](https://docs.cloud.google.com/kubernetes-engine/docs/getting-support.md.txt)
116
(Sections: "Before you contact support", "Recommendations for efficient
117
support")
118
* [Disruptions](https://kubernetes.io/docs/concepts/workloads/pods/disruptions/)
119
(Sections: "Voluntary and involuntary disruptions", "Dealing with
120
disruptions", "Pod disruption budgets")
121
* [Specifying a Disruption Budget for your Application](https://kubernetes.io/docs/tasks/run-application/configure-pdb/)
122
(Sections: "Identify an Application to Protect", "Think about how your
123
application reacts to disruptions", "Rounding logic when specifying
124
percentages", "Specifying a PodDisruptionBudget", "Create the PDB
125
object", "Check the status of the PDB", "Healthiness of a Pod",
126
"Unhealthy Pod Eviction Policy", "Arbitrary workloads and arbitrary
127
selectors")
128
* [Configure Liveness, Readiness and Startup Probes](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/)
129
(Sections: "Define readiness probes")
130
131
This skill creates no billable resources, so no teardown is required.
132
133
## Diagnostic workflow
134
135
> **Scope and Managed Airflow check**:
136
> * **Managed Service for Apache Airflow (formerly Cloud Composer)**: Under
137
> [Environment's cluster](https://docs.cloud.google.com/composer/docs/composer-2/environment-architecture.md.txt),
138
> clusters for Managed Airflow and workloads deployed into them are managed
139
> by Google: do not introduce changes in the environment's cluster (doing so
140
> might break the environment). When the user says the cluster belongs to a
141
> Managed Airflow (or Cloud Composer) environment, do not propose workload
142
> or PDB changes; ask when that isn't clear.
143
> * **Unpermissive PDBs (`PDB_UNPERMISSIVE`)**: For requests solely about
144
> `PDB_UNPERMISSIVE` or drains blocked by
145
> `"Cannot evict pod as it would violate the pod's disruption budget."` on a
146
> matching PDB, stop and point the user to
147
> [When GKE identifies workloads with vulnerability to disruption](https://docs.cloud.google.com/kubernetes-engine/docs/how-to/workload-disruption-readiness.md.txt)
148
> and
149
> [Troubleshoot node pool upgrades taking longer than usual](https://docs.cloud.google.com/kubernetes-engine/docs/troubleshooting/upgrades.md.txt)
150
> to adjust `minAvailable` or `maxUnavailable` themselves. In an audit,
151
> handle matching unpermissive PDBs via "When a matching PDB already
152
> exists".
153
> * **Other GKE topics**: Hand off general probe/PDB setup to
154
> `gke-reliability`, upgrade planning to `gke-upgrades`, `Pending` Pods to
155
> `gke-workload-troubleshooting`, autoscaling/stockouts to
156
> `gke-cluster-autoscaler`, ComputeClasses to `gke-compute-classes`, and
157
> general manifest generation to `gke-manifest-generation`.
158
> * **Provided manifests, insights, or `kubectl` output**: After the Managed
159
> Airflow check, if insight/recommendation details, manifests, or `kubectl`
160
> output are provided, capture any `{project_id}`, `{cluster_name}`, and
161
> `{location}`, skip Steps 1–2 (honoring dismissed recommendations per Step
162
> 2), and evaluate every workload in Step 3 without discovery commands.
163
164
### Step 1: Identify the target cluster
165
166
Obtain `{project_id}`, `{cluster_name}`, and `{location}` (control plane region
167
or zone) from the prompt. If `{project_id}` is unknown, ask the user; if
168
`{cluster_name}` or `{location}` is unknown, ask the user or follow
169
[View your clusters](https://docs.cloud.google.com/kubernetes-engine/docs/how-to/managing-clusters.md.txt)
170
for `{project_id}`. Ask when it isn't clear whether `{cluster_name}` belongs to
171
a Managed Airflow environment.
172
173
### Step 2: Check for `PDB_UNPROTECTED_STATEFULSET` insights and recommendations
174
175
1. **Query insights**: Under
176
[Identify workloads with vulnerability to disruption](https://docs.cloud.google.com/kubernetes-engine/docs/how-to/workload-disruption-readiness.md.txt),
177
disruption-readiness insights are available only via `gcloud` or the
178
Recommender API (not the Google Cloud console). Follow `gcloud` or API
179
instructions in
180
[View insights and recommendations](https://docs.cloud.google.com/kubernetes-engine/docs/how-to/optimize-with-recommenders.md.txt)
181
for `{project_id}` and `{location}`, filtering for
182
`PDB_UNPROTECTED_STATEFULSET`.
183
2. **Filter active insights and check recommendation state**: Keep `ACTIVE`
184
insights matching `{cluster_name}` via "State Info" and "Target Resources",
185
record "Severity" and "Last Refresh Time", and read `{statefulset_name}`
186
(`{namespace}` if shown), suggested selector labels ("Description" and
187
"Content"), and `associatedRecommendations.recommendation` via
188
[Insights](https://docs.cloud.google.com/recommender/docs/insights/using-insights.md.txt),
189
"View insights and recommendations" and "Dismiss recommendations using the
190
Google Cloud CLI" in
191
[Optimize your usage of GKE with insights and recommendations](https://docs.cloud.google.com/kubernetes-engine/docs/how-to/optimize-with-recommenders.md.txt),
192
and "When GKE identifies workloads with vulnerability to disruption" and
193
"Implement the guidance to improve disruption readiness" in
194
[Ensure workloads are disruption-ready](https://docs.cloud.google.com/kubernetes-engine/docs/how-to/workload-disruption-readiness.md.txt).
195
Check the recommendation's state using only the read-only list (`ACTIVE`
196
filter hides dismissed recommendations) or describe step in "Dismiss
197
recommendations using the Google Cloud CLI"—never run `mark-dismissed`. If
198
`{namespace}` or `{statefulset_name}` is unknown, ask or point to
199
[Inspecting a StatefulSet](https://docs.cloud.google.com/kubernetes-engine/docs/how-to/stateful-apps.md.txt).
200
3. **Branch on results** (include the `.md.txt` links from items 1–2 when
201
pointing the user to those sections):
202
* **Active insights**: For each active insight, if its associated
203
recommendation was dismissed, report that the user dismissed it instead
204
of recommending a PDB again (dismissing only hides it in the console
205
while it remains discoverable via `gcloud` and the Recommender API; see
206
[Dismiss or restore recommendations](https://docs.cloud.google.com/kubernetes-engine/docs/how-to/optimize-with-recommenders.md.txt)).
207
Otherwise continue to Step 3 for `{statefulset_name}` in `{namespace}`.
208
* **No active insight for `{cluster_name}`**: Recommendations are assessed
209
once daily ("Implement the guidance to improve disruption readiness" in
210
item 2), so recent changes may not appear yet. Proceed to Step 3 if
211
`{statefulset_name}` and `{namespace}` were given; otherwise report none
212
was found and ask for them (or point to "Inspecting a StatefulSet" in
213
item 2).
214
* **API disabled or unreachable**: If `recommender.googleapis.com` is
215
disabled, point to "gcloud" in
216
[Enable the API](https://docs.cloud.google.com/recommender/docs/enable-api.md.txt)
217
(and continue to Step 3 if `{statefulset_name}` and `{namespace}` are
218
known). If unreachable, point to "View insights and recommendations"
219
(item 1), "Inspecting a StatefulSet" (item 2), and
220
[Check the status of the PDB](https://kubernetes.io/docs/tasks/run-application/configure-pdb/),
221
continuing with Step 3 once output is shared.
222
223
### Step 3: Inspect the StatefulSet selector and existing PDBs
224
225
Configure `kubectl` credentials for `{cluster_name}` in `{location}` via
226
[Store cluster information for kubectl](https://docs.cloud.google.com/kubernetes-engine/docs/how-to/cluster-access-for-kubectl.md.txt),
227
and evaluate every StatefulSet in scope (never stop after the first):
228
229
1. **Inspect the StatefulSet**: Follow "Inspecting a StatefulSet" (and see
230
"Creating a StatefulSet" for `spec.template.metadata.labels`) in
231
[Deploying a stateful application](https://docs.cloud.google.com/kubernetes-engine/docs/how-to/stateful-apps.md.txt)
232
for `{statefulset_name}` in `{namespace}` to read `{replicas}`
233
(`spec.replicas`), `{statefulset_selector}` (`.spec.selector`), and
234
`spec.template.metadata.labels`, plus container `readinessProbe` (see
235
[Define readiness probes](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/)).
236
Per
237
[Identify an Application to Protect](https://kubernetes.io/docs/tasks/run-application/configure-pdb/),
238
`.spec.selector` goes into a matching PDB's `.spec.selector`. If
239
`{statefulset_name}` is not found, ask whether it was deleted:
240
* If the user confirms it was deleted, tell them no PDB is needed and the
241
recommendation can take up to 24 hours to resolve (see
242
[Implement the guidance to improve disruption readiness](https://docs.cloud.google.com/kubernetes-engine/docs/how-to/workload-disruption-readiness.md.txt)).
243
* Otherwise, re-check `{namespace}` and any Step 2 insight's
244
[Target Resources](https://docs.cloud.google.com/recommender/docs/insights/using-insights.md.txt)
245
(it might target another cluster); if still not found, direct the user
246
to Cloud Customer Care ("Before you contact support" and
247
"Recommendations for efficient support" in
248
[Get support](https://docs.cloud.google.com/kubernetes-engine/docs/getting-support.md.txt)).
249
2. **Inspect PDBs and selector overlap in `{namespace}`**: Follow "Check the
250
status of the PDB", "Specifying a PodDisruptionBudget", "Identify an
251
Application to Protect", and "Arbitrary workloads and arbitrary selectors"
252
in
253
[Specifying a Disruption Budget for your Application](https://kubernetes.io/docs/tasks/run-application/configure-pdb/)
254
to read each PDB's `.spec.selector` (`{}` matches every Pod in
255
`{namespace}`), `minAvailable`, `maxUnavailable`, `status.expectedPods`, and
256
`status.disruptionsAllowed`. `PDB_UNPROTECTED_STATEFULSET` alerts when no
257
existing PDB labels match `{statefulset_selector}` (see
258
[When GKE identifies workloads with vulnerability to disruption](https://docs.cloud.google.com/kubernetes-engine/docs/how-to/workload-disruption-readiness.md.txt)).
259
Count only a PDB whose `.spec.selector` equals `{statefulset_selector}` as a
260
match; record any matching `{existing_pdb_name}`, and record any
261
`{existing_pdb_name}` selecting the Pods without matching (`{}`, subset
262
labels, extra `spec.template.metadata.labels`, or a Pod subset), noting
263
whether it also selects other workloads' Pods.
264
265
### Step 4: Classify each evaluated StatefulSet from live state
266
267
Classify each workload into one category from Step 3, reporting any Step 2
268
[Severity](https://docs.cloud.google.com/recommender/docs/insights/using-insights.md.txt):
269
270
1. **`StatefulSet Protected`**: `{existing_pdb_name}` in `{namespace}` equals
271
`{statefulset_selector}` (any `{replicas}`). Record
272
`{other_statefulset_name}` and `{other_statefulset_summary}` via "When a
273
matching PDB already exists".
274
2. **`Single-Replica or Scaled-to-Zero StatefulSet`**: `{replicas} <= 1` and no
275
PDB in `{namespace}` equals `{statefulset_selector}`. Record
276
`{other_statefulset_name}` and `{other_statefulset_summary}` via
277
"Single-replica and scaled-to-zero StatefulSets".
278
3. **`Unprotected StatefulSet`**: `{replicas} > 1` and no PDB in `{namespace}`
279
equals `{statefulset_selector}`. Record missing-PDB or `{existing_pdb_name}`
280
mismatch details in `{classification_summary}`; follow "Unprotected
281
StatefulSet (add or update a PDB)".
282
283
Count the `Unprotected StatefulSet` workloads as `{count}`.
284
285
## Remediation
286
287
Give the user fixes to apply themselves (never modify resources or state).
288
289
### Unprotected StatefulSet (add or update a PDB)
290
291
1. **Specify `.spec.selector` and disruption budget**: Point to "When GKE
292
identifies workloads with vulnerability to disruption" and "Implement the
293
guidance to improve disruption readiness" in
294
[Ensure workloads are disruption-ready](https://docs.cloud.google.com/kubernetes-engine/docs/how-to/workload-disruption-readiness.md.txt),
295
[Pod disruption budgets](https://kubernetes.io/docs/concepts/workloads/pods/disruptions/),
296
and "Identify an Application to Protect", "Think about how your application
297
reacts to disruptions", "Rounding logic when specifying percentages", and
298
"Specifying a PodDisruptionBudget" in
299
[Specifying a Disruption Budget for your Application](https://kubernetes.io/docs/tasks/run-application/configure-pdb/):
300
* **Selector**: Copy `{statefulset_selector}` (`.spec.selector`, matching
301
Step 2's recommendation when current) into the PDB's `.spec.selector`,
302
without adding Pod-template-only `spec.template.metadata.labels` (see
303
[Creating a StatefulSet](https://docs.cloud.google.com/kubernetes-engine/docs/how-to/stateful-apps.md.txt)).
304
* **Budget**: Set only one of `maxUnavailable` (`1` adapts to scale;
305
requires one shared controller) or `minAvailable` (quorum, such as `2`
306
of `3` or `3` of `5`). Never set `maxUnavailable` to `0`/`0%` or
307
`minAvailable` to `100%` or an integer/rounded-up percentage not less
308
than `{replicas}` (`PDB_UNPERMISSIVE`, causing 1-hour drain waits).
309
2. **Create vs. update overlapping `{existing_pdb_name}`**: Under "Identify an
310
Application to Protect", "Specifying a PodDisruptionBudget", "Create the PDB
311
object", and "Arbitrary workloads and arbitrary selectors" in
312
[Specifying a Disruption Budget for your Application](https://kubernetes.io/docs/tasks/run-application/configure-pdb/)
313
(eviction is disallowed for any Pod covered by multiple PDBs):
314
* **No PDB selects the Pods**: Point to "Create the PDB object" to add it.
315
* **`{existing_pdb_name}` selects only this StatefulSet's Pods** (empty
316
`{}`, subset labels, extra `spec.template.metadata.labels`, or a Pod
317
subset): Advise **not** creating a second PDB; point to "Create the PDB
318
object" to update `{existing_pdb_name}` in place to
319
`{statefulset_selector}`.
320
* **`{existing_pdb_name}` also selects other workloads' Pods** (empty
321
`{}`, shared subset labels, or a shared Pod-template label): Warn that
322
`maxUnavailable` requires all selected Pods to share one controller
323
(bare or unsupported-controller Pods allow only integer `minAvailable`),
324
the budget is shared across all selected Pods rather than per-workload
325
quorum, and adding a second PDB blocks eviction while narrowing
326
`{existing_pdb_name}` alone drops coverage from the other workloads;
327
point to those sections to give each controller a non-overlapping PDB
328
matching `.spec.selector`.
329
3. **Readiness probes (`PDB_STATEFULSET_WITHOUT_PROBES`)**: PDBs respect
330
readiness probes when they look at which Pods can be counted as healthy, and
331
a Pod counts as healthy when it has a `.status.conditions` item with
332
`type="Ready"` and `status="True"`. If missing, point to
333
[Healthiness of a Pod](https://kubernetes.io/docs/tasks/run-application/configure-pdb/),
334
[When GKE identifies workloads with vulnerability to disruption](https://docs.cloud.google.com/kubernetes-engine/docs/how-to/workload-disruption-readiness.md.txt),
335
[Define readiness probes](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/),
336
and
337
[Updating a StatefulSet](https://docs.cloud.google.com/kubernetes-engine/docs/how-to/stateful-apps.md.txt).
338
4. **Resolution window and dismissal**: Recommendations are assessed once daily
339
and take up to 24 hours to resolve after changes (see
340
[Implement the guidance to improve disruption readiness](https://docs.cloud.google.com/kubernetes-engine/docs/how-to/workload-disruption-readiness.md.txt)).
341
Only if the user decides not to add a PDB, point to "Dismiss or restore
342
recommendations" and "Dismiss recommendations using the Google Cloud CLI" in
343
[Optimize your usage of GKE with insights and recommendations](https://docs.cloud.google.com/kubernetes-engine/docs/how-to/optimize-with-recommenders.md.txt):
344
dismissing only hides a recommendation for all users in the console (where
345
it doesn't appear again even if GKE detects the same behavior), while it
346
remains discoverable via the Google Cloud CLI and Recommender API.
347
348
### Single-replica and scaled-to-zero StatefulSets
349
350
1. **If `{replicas} == 0`**: Ask whether it stays at `0` or scales up (under
351
[Check the status of the PDB](https://kubernetes.io/docs/tasks/run-application/configure-pdb/),
352
zero matching Pods shows `ALLOWED DISRUPTIONS: 0`). If kept at `0`, no Pods
353
run to disrupt (for dismissal, see item 4 of "Unprotected StatefulSet (add
354
or update a PDB)" above); if scaling to `1`, follow items 2–3; if scaling
355
above `1` (see
356
[Scaling a StatefulSet](https://docs.cloud.google.com/kubernetes-engine/docs/how-to/stateful-apps.md.txt)),
357
follow "Unprotected StatefulSet (add or update a PDB)" for that target.
358
2. **Explain 1-replica PDB trade-offs**: PDBs target replicated apps ("Dealing
359
with disruptions" and "Pod disruption budgets" in
360
[Disruptions](https://kubernetes.io/docs/concepts/workloads/pods/disruptions/)).
361
Under "Think about how your application reacts to disruptions" and
362
"Specifying a PodDisruptionBudget" (`Example 4`) in
363
[Specifying a Disruption Budget for your Application](https://kubernetes.io/docs/tasks/run-application/configure-pdb/),
364
`maxUnavailable: 1` or a positive percentage still allows evicting the lone
365
Pod (`100%` unavailability), while `maxUnavailable` of `0`/`0%` or
366
`minAvailable` of `1`/`100%` triggers `PDB_UNPERMISSIVE` and a 1-hour drain
367
wait on Standard surge and Autopilot upgrades (see item 3 of "When a
368
matching PDB already exists" below). If a non-matching `{existing_pdb_name}`
369
selects the Pod, handle overlap per item 2 of "Unprotected StatefulSet (add
370
or update a PDB)".
371
3. **Documented single-instance options**: Point the user to:
372
* Omit a PDB and tolerate brief drain downtime (see
373
[Think about how your application reacts to disruptions](https://kubernetes.io/docs/tasks/run-application/configure-pdb/)).
374
If an active recommendation exists and the user decides against a PDB,
375
share item 4 of "Unprotected StatefulSet (add or update a PDB)" above.
376
* Scale above `1` replica before adding a PDB via
377
[Scaling a StatefulSet](https://docs.cloud.google.com/kubernetes-engine/docs/how-to/stateful-apps.md.txt).
378
* Control maintenance timing via a cluster maintenance window/exclusion or
379
(Standard only) a node-pool maintenance exclusion—noting maintenance
380
policies don't block all automatic maintenance and on Autopilot GKE
381
honors the configuration if possible; see "Automatic maintenance that
382
doesn't respect GKE maintenance policies", "Maintenance windows",
383
"Maintenance exclusions", "Node pool maintenance exclusions",
384
"Limitations on configuring maintenance exclusions", and "Example:
385
Company's legacy database not resilient to node pool upgrades" in
386
[Maintenance windows and exclusions](https://docs.cloud.google.com/kubernetes-engine/docs/concepts/maintenance-windows-and-exclusions.md.txt),
387
[Automatic node upgrades](https://docs.cloud.google.com/kubernetes-engine/docs/concepts/cluster-upgrades-autopilot.md.txt),
388
and "Configure a maintenance window" and "Configure a maintenance
389
exclusion" in
390
[Configure maintenance windows and exclusions](https://docs.cloud.google.com/kubernetes-engine/docs/how-to/maintenance-windows-and-exclusions.md.txt).
391
392
### When a matching PDB already exists
393
394
* **Stale active insight**: If an active `PDB_UNPROTECTED_STATEFULSET` insight
395
still appears for `{other_statefulset_name}`, ask when `{existing_pdb_name}`
396
was created or updated and check "Target Resources" and "Last Refresh Time"
397
in
398
[Insights](https://docs.cloud.google.com/recommender/docs/insights/using-insights.md.txt).
399
If "Last Refresh Time" is earlier than the PDB change, explain the daily
400
24-hour assessment window (see
401
[Implement the guidance to improve disruption readiness](https://docs.cloud.google.com/kubernetes-engine/docs/how-to/workload-disruption-readiness.md.txt))
402
and advise **not** dismissing just to clear normal lag: under
403
[Dismiss or restore recommendations](https://docs.cloud.google.com/kubernetes-engine/docs/how-to/optimize-with-recommenders.md.txt),
404
dismissing only hides a recommendation for all users in the console (where
405
it doesn't appear again even if GKE detects the same behavior), while it
406
remains discoverable via `gcloud` and the Recommender API. If "Last Refresh
407
Time" is later than the PDB change and the insight is still active, direct
408
the user to Cloud Customer Care via "Before you contact support" and
409
"Recommendations for efficient support" in
410
[Get support](https://docs.cloud.google.com/kubernetes-engine/docs/getting-support.md.txt).
411
* **Single or zero replicas**: If `{replicas} <= 1`, on `1` replica even a
412
permissive PDB allows `100%` unavailability (`0` matches zero Pods); follow
413
"Single-replica and scaled-to-zero StatefulSets".
414
415
Check—or point the user to check:
416
417
1. **Permissiveness (`PDB_UNPERMISSIVE`)**: Verify via "Check the status of the
418
PDB", "Rounding logic when specifying percentages", and "Specifying a
419
PodDisruptionBudget" in
420
[Specifying a Disruption Budget for your Application](https://kubernetes.io/docs/tasks/run-application/configure-pdb/)
421
that when `{replicas} > 0` and Pods are healthy, `ALLOWED DISRUPTIONS`
422
(`status.disruptionsAllowed`) is non-zero (`minAvailable`, rounded up for
423
percentages, is less than `{replicas}`, or `maxUnavailable > 0`); otherwise
424
point to
425
[When GKE identifies workloads with vulnerability to disruption](https://docs.cloud.google.com/kubernetes-engine/docs/how-to/workload-disruption-readiness.md.txt)
426
and
427
[Troubleshoot node pool upgrades taking longer than usual](https://docs.cloud.google.com/kubernetes-engine/docs/troubleshooting/upgrades.md.txt).
428
2. **Readiness probes (`PDB_STATEFULSET_WITHOUT_PROBES`)**: Check container
429
`readinessProbe`; if missing, point to item 3 of "Unprotected StatefulSet
430
(add or update a PDB)" above.
431
3. **Disruption despite both**: Point the user to:
432
* **One-hour surge PDB timeout** ("maxSurge: GKE creates a new surge node
433
before removing an existing one" and "maxUnavailable: GKE makes an
434
existing node unavailable to recreate it") and **Standard blue-green
435
pool deletion** bypassing PDBs ("Phase 3: Drain blue pool" and "Phase 5:
436
Delete blue pool") in
437
[Node upgrade strategies](https://docs.cloud.google.com/kubernetes-engine/docs/concepts/node-pool-upgrade-strategies.md.txt),
438
plus the 1-hour PDB limit in
439
[Automatic node upgrades](https://docs.cloud.google.com/kubernetes-engine/docs/concepts/cluster-upgrades-autopilot.md.txt)
440
and
441
[When GKE identifies workloads with vulnerability to disruption](https://docs.cloud.google.com/kubernetes-engine/docs/how-to/workload-disruption-readiness.md.txt).
442
* **`unhealthyPodEvictionPolicy: AlwaysAllow`** evicting running non-Ready
443
Pods regardless of budget (see
444
[Unhealthy Pod Eviction Policy](https://kubernetes.io/docs/tasks/run-application/configure-pdb/)).
445
* **Involuntary disruptions or direct deletions** bypassing PDBs
446
("Voluntary and involuntary disruptions" and "Pod disruption budgets" in
447
[Disruptions](https://kubernetes.io/docs/concepts/workloads/pods/disruptions/)).
448
* **Escalation**: Direct the user to Cloud Customer Care via "Before you
449
contact support" and "Recommendations for efficient support" in
450
[Get support](https://docs.cloud.google.com/kubernetes-engine/docs/getting-support.md.txt).
451
452
## Output format
453
454
Cite relied-on doc sections by exact title and link. Omit unprovided
455
`{cluster_name}`, `{location}`, or `{project_id}`; omit `Unprotected
456
StatefulSets detected` and `Recommended remediation` when `{count}` is `0`; omit
457
`Other evaluated StatefulSets` when none apply (`{other_statefulset_summary}`
458
covers single-replica/scaled-to-zero options or `{existing_pdb_name}`
459
permissiveness, readiness-probe, and 24-hour lag notes); and report Step 2's
460
[Severity](https://docs.cloud.google.com/recommender/docs/insights/using-insights.md.txt)
461
when retrieved.
462
463
```markdown
464
### Unprotected StatefulSets detected
465
466
Found {count} `StatefulSet` workload(s) without a matching
467
`PodDisruptionBudget` on cluster `{cluster_name}` (`{location}`, Project:
468
`{project_id}`):
469
470
| StatefulSet | Namespace | Replicas | Classification & details |
471
| :--- | :--- | :---: | :--- |
472
| `{statefulset_name}` | `{namespace}` | {replicas} | {classification_summary} |
473
474
### Other evaluated StatefulSets
475
476
* `{other_statefulset_name}` (`{namespace}`, `replicas: {replicas}`):
477
{other_statefulset_summary}
478
479
### Recommended remediation
480
481
* For `{statefulset_name}` (`{namespace}`): follow "Identify an Application
482
to Protect", "Specifying a PodDisruptionBudget", "Create the PDB object",
483
and "Arbitrary workloads and arbitrary selectors" in
484
[Specifying a Disruption Budget for your Application](https://kubernetes.io/docs/tasks/run-application/configure-pdb/)
485
to create a `PodDisruptionBudget` copying `{statefulset_selector}` with an
486
appropriate budget, or update `{existing_pdb_name}` without overlapping
487
PDBs.
488
489
### Verification
490
491
* Follow
492
[Check the status of the PDB](https://kubernetes.io/docs/tasks/run-application/configure-pdb/)
493
to verify `ALLOWED DISRUPTIONS` (`status.disruptionsAllowed`) is non-zero
494
and `status.expectedPods` matches `{replicas}`.
495
* Recommendations are assessed once daily and take up to 24 hours to resolve
496
(see
497
[Implement the guidance to improve disruption readiness](https://docs.cloud.google.com/kubernetes-engine/docs/how-to/workload-disruption-readiness.md.txt)).
498
```
499

© Google LLC · Apache 2.0 · source · posted by @OpenSourceBuffGuy on promptparty.com

@OpenSourceBuffGuy

I find openly licensed prompts and post them here.

0 followers · 14,621 prompts

More by @OpenSourceBuffGuy

See all
Sea turtle carrying floating film studio island prompt image

Sea turtle carrying floating film studio island

Draws a giant sea turtle carrying a floating island film studio through a starry sky, where fairies polish rough film strips into golden film.

image-prompt, nano-banana, 3d-render, cartoon, fantasy-world, creatures, animals, whimsical, dreamy, cinematic, dramatic-lighting, vibrant-colors, bokeh, miniature, widescreen, night-scene, illustration, concept-art, surreal, storytelling, clay-3d

Desert buggy escapes drones past industrial outpost prompt image

Desert buggy escapes drones past industrial outpost

Builds a 15-second desert chase video where a racer in an armored buggy escapes drones past an industrial outpost, using five reference images with set jobs.

video-prompt, hailuo, action, multi-shot, timed-beats, camera-movement, reference-image, character-consistency, negative-prompt, cinematic, sci-fi, cars, landscape, aerial-view, tracking-shot, photorealistic, sound-effects, structured-output, long-form, widescreen

1 view
Cozy Pixel Art Farm Island Village prompt image

Cozy Pixel Art Farm Island Village

Draws a cozy 16-bit pixel-art farming village across six small islands joined by bridges, with exact counts for buildings, animals and crops.

image-prompt, gpt-image, pixel-art, isometric, game-assets, concept-art, maps, worldbuilding, cozy, vibrant-colors, ocean, landscape, wide-shot, widescreen, game-development, video-games, structured-output, whimsical, summer, high-angle, aerial-view, animals, negative-prompt, cityscape

1 view

Reviews

Loading reviews…

Discussion

Loading comments…