GKE Workload Scaling

GKE Workload Scaling

Guides a coding agent in scaling GKE workloads manually and with Horizontal and Vertical Pod Autoscalers, with commands, example manifests and best practices.

Skill files4 files

assets/

references/

SKILL.md145 lines
1
---
2
name: gke-workload-scaling
3
description: >-
4
Manages scaling for GKE workloads using HPA and VPA. Use when configuring
5
Horizontal Pod Autoscaler (HPA), configuring Vertical Pod Autoscaler (VPA),
6
or applying best practices for GKE workload autoscaling. Do not use for
7
cluster-level autoscaling (Cluster Autoscaler), static cluster sizing,
8
or configuring node-level machine styles directly.
9
metadata:
10
version: "1.0.1"
11
category: Containers
12
---
13
14
# GKE Workload Scaling
15
16
This skill provides workflows and best practices for scaling applications on
17
Google Kubernetes Engine (GKE). It covers manual scaling, Horizontal Pod
18
Autoscaling (HPA), and Vertical Pod Autoscaling (VPA).
19
20
## Attribution
21
22
**MUST READ**: Before executing any `gcloud`, REST API, or MCP command, you
23
MUST read [Usage Attribution](references/attribution.md). For commands executed
24
directly in the terminal (never in generated scripts, Terraform, or user code),
25
prefix `gcloud` with
26
`CLOUDSDK_METRICS_REQUEST_ATTRIBUTION="agent-skills/1.0 (skill:gke-workload-scaling)"`
27
and append `agent-skills/1.0 (skill:gke-workload-scaling)` to `User-Agent` headers.
28
29
## Workflows
30
31
### 1. Manual Scaling
32
33
Scale a deployment to a fixed number of replicas. Useful for immediate manual
34
intervention or testing.
35
36
**Command:**
37
38
```bash
39
kubectl scale deployment {deployment_name} --replicas={number} -n {namespace}
40
41
# Verify the scale event
42
kubectl get deployment {deployment_name} -n {namespace}
43
```
44
45
### 2. Horizontal Pod Autoscaling (HPA)
46
47
Automatically scale the number of pods based on observed CPU utilization, memory
48
utilization, or custom metrics.
49
50
**Prerequisites:**
51
52
- Metrics Server must be running (enabled by default on GKE).
53
- Containers clearly define resource requests/limits.
54
55
**Quick Command:**
56
57
```bash
58
kubectl autoscale deployment {deployment_name} --cpu-percent=50 --min=1 --max=10
59
```
60
61
**Manifest Approach (Recommended):** Use a YAML manifest for version-controlled
62
configuration. See [assets/hpa-example.yaml](assets/hpa-example.yaml) for a
63
template.
64
65
```bash
66
kubectl apply -f assets/hpa-example.yaml
67
68
# Verify HPA is created and fetching metrics
69
kubectl get hpa
70
```
71
72
**Custom Metrics & External Metrics:** For GKE, the modern and recommended
73
approach for scaling based on Cloud Monitoring metrics (e.g., Pub/Sub queue
74
length) is to use the **External** metric type, which is natively supported by
75
the GKE control plane without requiring the Custom Metrics Adapter. For
76
application-specific metrics exposed via Prometheus, you can use **Google Cloud
77
Managed Service for Prometheus** or the Prometheus Adapter.
78
79
### 3. Vertical Pod Autoscaling (VPA)
80
81
Automatically adjust the CPU and memory reservations for your pods to match
82
actual usage. This is critical for right-sizing workloads.
83
84
**Prerequisites:**
85
86
- VPA must be enabled on the cluster.
87
- **Autopilot:** Enabled by default.
88
- **Standard:** Must be enabled manually.
89
90
**Enable VPA on Standard Cluster:**
91
92
```bash
93
gcloud container clusters update {cluster_name} --enable-vertical-pod-autoscaling --zone {zone}
94
```
95
96
**Update Modes:**
97
98
- `Off`: Calculates recommendations but does not apply them. Good for "dry
99
run" analysis.
100
- `Initial`: Assigns resources only at pod creation time.
101
- `Auto`: Updates running pods by restarting them if recommendations differ
102
significantly from requests.
103
- `InPlaceOrRecreate`: Attempts to update Pod resources without recreating the
104
Pod. If in-place update is not possible, it reverts to `Auto` mode (requires
105
GKE 1.34+).
106
107
**Example:** See [assets/vpa-example.yaml](assets/vpa-example.yaml) for a
108
configuration template.
109
110
## Best Practices
111
112
1. **Define Resource Requests:** HPA and VPA rely on accurate resource
113
requests. Always define them in your container specs.
114
2. **Avoid Metric Conflicts:** Do not configure HPA and VPA to use the same
115
metric (e.g., both CPU). This causes thrashing.
116
- *Typical Pattern:* HPA on CPU, VPA on Memory.
117
3. **Pod Disruption Budgets (PDBs):** Define PDBs to ensure application
118
availability during scaling events or node upgrades.
119
4. **HPA Lag:** HPA has a stabilization window (default 5 mins) to prevent
120
rapid fluctuation.
121
5. **VPA "Auto" Mode Risks:** In "Auto" mode, VPA restarts pods to change
122
resources. Ensure your application handles restarts gracefully (e.g.,
123
handles SIGTERM).
124
- *Note:* By default, VPA requires at least 2 replicas to perform
125
evictions (to prevent a situation where the only running replica is
126
evicted, causing downtime). In GKE 1.22+, you can override this by
127
setting `minReplicas` in `PodUpdatePolicy`.
128
129
## Rightsizing Workflow
130
131
1. Deploy VPA in `Off` mode for 24+ hours
132
2. Read recommendations: `kubectl describe vpa {deployment_name}-vpa -n
133
{namespace}`
134
3. Compare `target` values against current `requests`
135
4. Apply with 20% buffer: `new_request = target * 1.2`
136
5. Use patch format or update deployment manifest to apply new resource
137
requests
138
139
Condition | Recommendation | Risk
140
----------------------------- | ------------------------------------ | ------
141
CPU request >5x P95 actual | Reduce to `P95 * 1.2` | Medium
142
Memory request >3x P95 actual | Reduce to `P95 * 1.2` | Medium
143
CPU request >2x P95 actual | Rightsizing with 20% buffer | Low
144
No resource limits set | Add limits to prevent noisy-neighbor | Low
145

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

@OpenSourceBuffGuy

I find openly licensed prompts and post them here.

0 followers · 11,991 prompts

More by @OpenSourceBuffGuy

See all
Redhead heroine battles armored troops in glowing chamber prompt image

Redhead heroine battles armored troops in glowing chamber

Generates a 15-second animated sci-fi action sequence in which a red-haired heroine fights armored guards in a circular research chamber, with timed beats and a detailed sound design.

video-prompt, seedance, action, sci-fi, animation, martial-arts, timed-beats, camera-movement, multi-shot, slow-motion, visual-effects, sound-effects, futuristic, woman, scene-transitions, dramatic-lighting, cinematic, reference-image, guardrails, long-form, advanced, for-filmmakers

Black-and-White Identity Collage Grid prompt image

Black-and-White Identity Collage Grid

Edits a photo into a six-frame black-and-white fashion portrait collage of the same young woman, with detailed hair, styling, studio lighting and film grain.

image-prompt, reference-image, face-reference, gpt-image, photorealistic, black-and-white, editorial, multi-panel, fashion-shoot, portrait, woman, hairstyles, soft-lighting, natural-light, film-grain, vertical-format, medium-shot, close-up, studio-lighting, jewelry, guardrails, fashion, for-photographers, beauty

KPI Dashboard Design prompt image

KPI Dashboard Design

Guides the AI in designing KPI dashboards: picking metrics, layout hierarchy, visualisation choices, real-time monitoring and consistent metric definitions.

agent-skill, kpis, data-visualization, dashboard, business-intelligence, best-practices, for-data-analysts, for-executives, for-managers, saas, observability, financial-analysis, table, long-form, explainer, template, structured-output, operations, product-management, data-analysis, sales, marketing

Reviews

Loading reviews…

Discussion

Loading comments…