GKE Reliability

GKE Reliability

Improves GKE workload reliability with pod disruption budgets, liveness, readiness and startup probes and topology spread constraints, using golden-path defaults.

Skill files2 files

references/

SKILL.md223 lines
1
---
2
name: gke-reliability
3
description: >-
4
Improves GKE workload reliability, using PDBs, health probes, and topology
5
spread constraints. Use when configuring GKE workload reliability, setting up
6
PDBs, or configuring GKE health probes (liveness, readiness, startup). Don't
7
use for generating K8s YAML manifests (use gke-manifest-generation) or
8
disaster recovery and cluster backups (use gke-backup-dr).
9
metadata:
10
version: "1.0.2"
11
category: Containers
12
---
13
14
# GKE Reliability
15
16
> **Routing Note:** To generate Kubernetes YAML manifests (`Deployment`, `StatefulSet`, `Service`, `ConfigMap`, `HTTPRoute`, `PodDisruptionBudget`), open `gke-manifest-generation/SKILL.md`.
17
18
This reference covers high availability and reliability configuration for GKE
19
clusters and workloads.
20
21
> **MCP Tools:** `get_cluster`, `get_k8s_resource`, `describe_k8s_resource`,
22
> `apply_k8s_manifest`, `list_k8s_events`
23
24
## Attribution
25
26
**MUST READ**: Before executing any `gcloud`, REST API, or MCP command, you
27
MUST read [Usage Attribution](references/attribution.md). For commands executed
28
directly in the terminal (never in generated scripts, Terraform, or user code),
29
prefix `gcloud` with
30
`CLOUDSDK_METRICS_REQUEST_ATTRIBUTION="agent-skills/1.0 (skill:gke-reliability)"`
31
and append `agent-skills/1.0 (skill:gke-reliability)` to `User-Agent` headers.
32
33
## Golden Path Reliability Defaults
34
35
| Setting | Golden Path Value | Notes |
36
| ---------------- | --------------------- | -------------------------------- |
37
| Cluster type | Regional (4 zones: | Control plane replicated across |
38
: : us-central1-a/b/c/f) : zones :
39
| Upgrade strategy | SURGE (`maxSurge: 1`) | Rolling upgrades with extra |
40
: : : capacity :
41
| Auto-repair | `true` | Unhealthy nodes replaced |
42
: : : automatically :
43
| Auto-upgrade | `true` | Nodes follow control plane |
44
: : : version :
45
| Release channel | REGULAR | Balanced freshness and stability |
46
| Stateful HA | Enabled | Leader election for stateful |
47
: : : workloads :
48
49
## Workflows
50
51
### 1. Verify Cluster High Availability
52
53
```
54
# MCP (preferred)
55
get_cluster(name="projects/<PROJECT>/locations/<REGION>/clusters/<CLUSTER>",
56
readMask="location,locations,nodePools.locations")
57
58
# gcloud fallback
59
gcloud container clusters describe <CLUSTER> --region <REGION> \
60
--format="json(location, locations)" \
61
--quiet
62
```
63
64
- If `location` is a region (e.g., `us-central1`), the control plane is
65
regional
66
- If `locations` has multiple entries, nodes span multiple zones
67
68
### 2. Pod Disruption Budgets (PDBs)
69
70
PDBs ensure minimum pod availability during voluntary disruptions (node
71
upgrades, autoscaler scale-down).
72
73
**Check existing PDBs:**
74
75
```
76
# MCP (preferred)
77
get_k8s_resource(parent="...", resourceType="poddisruptionbudget")
78
79
# kubectl fallback
80
kubectl get pdb --all-namespaces
81
```
82
83
**Create PDB:**
84
85
```yaml
86
apiVersion: policy/v1
87
kind: PodDisruptionBudget
88
metadata:
89
name: my-app-pdb
90
namespace: default
91
spec:
92
minAvailable: 2 # Or use maxUnavailable: 1
93
selector:
94
matchLabels:
95
app: my-app
96
```
97
98
> Every production Deployment with 2+ replicas should have a PDB.
99
100
### 3. Health Probes
101
102
Every production container should have liveness and readiness probes. Startup
103
probes are recommended for slow-starting apps.
104
105
**Check existing probes:**
106
107
```
108
# MCP (preferred)
109
describe_k8s_resource(parent="...", resourceType="deployment", name="<APP>", namespace="<NS>")
110
111
# kubectl fallback
112
kubectl get deployment <APP> -n <NS> -o yaml | grep -E "livenessProbe|readinessProbe|startupProbe"
113
```
114
115
**Recommended probe configuration:**
116
117
```yaml
118
spec:
119
containers:
120
- name: app
121
livenessProbe:
122
httpGet:
123
path: /healthz
124
port: 8080
125
initialDelaySeconds: 15
126
periodSeconds: 10
127
timeoutSeconds: 2
128
failureThreshold: 3
129
readinessProbe:
130
httpGet:
131
path: /readyz
132
port: 8080
133
initialDelaySeconds: 5
134
periodSeconds: 5
135
timeoutSeconds: 2
136
failureThreshold: 3
137
startupProbe: # For slow-starting apps
138
httpGet:
139
path: /healthz
140
port: 8080
141
initialDelaySeconds: 10
142
periodSeconds: 5
143
timeoutSeconds: 2
144
failureThreshold: 30 # 30 * 5s = 150s max startup time
145
```
146
147
- **Readiness**: Determines when a pod can accept traffic
148
- **Liveness**: Determines when to restart a container
149
- **Startup**: Disables liveness/readiness until the app is ready (prevents
150
premature restarts)
151
152
### 4. Graceful Shutdown
153
154
Ensure applications handle `SIGTERM` and drain in-flight requests:
155
156
```yaml
157
spec:
158
terminationGracePeriodSeconds: 30 # Default; increase for long-running requests
159
containers:
160
- name: app
161
lifecycle:
162
preStop:
163
exec:
164
command: ["/bin/sh", "-c", "sleep 5"] # Allow LB to deregister
165
```
166
167
### 5. Topology Spread Constraints
168
169
Distribute pods across zones and nodes to survive failures:
170
171
```yaml
172
spec:
173
topologySpreadConstraints:
174
- maxSkew: 1
175
topologyKey: topology.kubernetes.io/zone
176
whenUnsatisfiable: DoNotSchedule
177
labelSelector:
178
matchLabels:
179
app: my-app
180
- maxSkew: 1
181
topologyKey: kubernetes.io/hostname
182
whenUnsatisfiable: ScheduleAnyway
183
labelSelector:
184
matchLabels:
185
app: my-app
186
```
187
188
- **Zone spread** (`DoNotSchedule`): Hard requirement -- pods must be balanced
189
across zones
190
- **Node spread** (`ScheduleAnyway`): Best-effort -- prefer distribution but
191
don't block scheduling
192
193
### 6. Replicas
194
195
| Workload Type | Minimum Replicas | Reason |
196
| -------------------- | -------------------- | ------------------------------ |
197
| Stateless web/API | 2 | Survive single pod/node |
198
: : : failure :
199
| Critical services | 3 | Survive zone failure with zone |
200
: : : spread :
201
| Stateful (databases) | 3 (with replication) | Application-level quorum |
202
| Batch/jobs | 1 | Ephemeral by nature |
203
204
## Best Practices & Production Guidelines
205
206
1. **Regional clusters for production**: Always use regional clusters to
207
survive zone failures.
208
2. **PDBs for everything**: Every production workload with 2+ replicas needs a
209
PodDisruptionBudget (PDB) to protect against voluntary disruptions.
210
3. **Probes with Explicit Timeouts**: Every production container must have both
211
liveness and readiness probes defined. **Always explicitly define
212
`initialDelaySeconds`, `periodSeconds`, and `timeoutSeconds`** for all
213
probes. Never rely on the Kubernetes default timeout of 1 second if your
214
application requires more, but always set a strict limit to prevent hanging
215
connections.
216
4. **Zone spreading**: Use topology spread constraints to distribute pods
217
across failure domains (zones and nodes).
218
5. **Graceful shutdown**: Handle `SIGTERM` and set appropriate
219
`terminationGracePeriodSeconds` with a `preStop` sleep hook to allow load
220
balancer deregistration.
221
6. **Maintenance windows**: Schedule upgrades during low-traffic periods (see
222
the `gke-upgrades` skill).
223

© 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…