Agent Skillsgoogle/skills › gke-scaling

gke-scaling

GitHub

配置 GKE 工作负载伸缩,包括 HPA、VPA 和节点自动配置 (NAP)。用于优化集群资源利用率与成本。不用于静态集群大小或节点机器类型配置。

skills/cloud/gke-scaling/SKILL.md google/skills

Trigger Scenarios

配置 GKE 自动伸缩 设置 GKE HPA 设置 GKE VPA 配置 GKE NAP

Install

npx skills add google/skills --skill gke-scaling -g -y
More Options

Non-standard path

npx skills add https://github.com/google/skills/tree/main/skills/cloud/gke-scaling -g -y

Use without installing

npx skills use google/skills@gke-scaling

指定 Agent (Claude Code)

npx skills add google/skills --skill gke-scaling -a claude-code -g -y

安装 repo 全部 skill

npx skills add google/skills --all -g -y

预览 repo 内 skill

npx skills add google/skills --list

SKILL.md

Frontmatter
{
    "name": "gke-scaling",
    "metadata": {
        "category": "Containers"
    },
    "description": "Configures GKE autoscaling, including HPA, VPA, and Node Auto-Provisioning (NAP). Use when configuring GKE autoscaling, setting up GKE HPA, setting up GKE VPA, or configuring GKE NAP. Don't use for configuring static cluster sizes or setting node-level machine styles directly (use gke-compute-classes instead)."
}

GKE Workload Scaling

This reference covers scaling workloads on GKE. The golden path enables VPA, OPTIMIZE_UTILIZATION autoscaling profile, and Node Auto Provisioning by default.

MCP Tools: get_k8s_resource, describe_k8s_resource, apply_k8s_manifest, patch_k8s_resource, get_cluster, update_cluster, update_node_pool

Golden Path Scaling Defaults

Setting Golden Path Value Notes
autoscaling.autoscalingProfile OPTIMIZE_UTILIZATION Aggressive scale-down for cost savings
verticalPodAutoscaling.enabled true VPA recommendations available
autoscaling.enableNodeAutoprovisioning true NAP creates node pools on demand
GPU resource limits (T4, A100) 1000000000 each NAP can provision GPU nodes

Scaling Mechanisms

1. Manual Scaling

kubectl-only — no MCP equivalent for kubectl scale. Use kubectl directly.

kubectl scale deployment <DEPLOYMENT> --replicas=<N> -n <NAMESPACE>

2. Horizontal Pod Autoscaling (HPA)

Scales the number of pods based on metrics.

Quick setup (kubectl-only — no MCP equivalent for kubectl autoscale):

kubectl autoscale deployment <DEPLOYMENT> --cpu-percent=50 --min=1 --max=10

Manifest approach (recommended — use MCP apply_k8s_manifest):

See assets/hpa-example.yaml for a template.

apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
  name: <DEPLOYMENT>-hpa
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: <DEPLOYMENT>
  minReplicas: 1
  maxReplicas: 10
  metrics:
  - type: Resource
    resource:
      name: cpu
      target:
        type: Utilization
        averageUtilization: 50

3. Vertical Pod Autoscaling (VPA)

Adjusts CPU and memory requests to match actual usage. Enabled by default on golden path.

Update modes:

  • Off — recommendations only (safest, start here)
  • Initial — sets resources only at pod creation
  • Auto — restarts pods to apply new resource values
  • InPlaceOrRecreate — updates resources without restart when possible (GKE 1.34+)

Create VPA in recommendation mode:

apiVersion: autoscaling.k8s.io/v1
kind: VerticalPodAutoscaler
metadata:
  name: <DEPLOYMENT>-vpa
spec:
  targetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: <DEPLOYMENT>
  updatePolicy:
    updateMode: "Off"

Read recommendations (prefer MCP describe_k8s_resource):

# MCP (preferred)
describe_k8s_resource(parent="...", resourceType="verticalpodautoscaler", name="<DEPLOYMENT>-vpa", namespace="<NAMESPACE>")

# kubectl fallback
kubectl get vpa <DEPLOYMENT>-vpa -o jsonpath='{.status.recommendation}'

See assets/vpa-example.yaml for a full template.

4. Cluster Autoscaler / Node Auto Provisioning (NAP)

On Autopilot (golden path), node scaling is fully managed. NAP automatically creates and sizes node pools based on workload demands.

For Standard clusters:

# Enable cluster autoscaler on a node pool
gcloud container clusters update <CLUSTER_NAME> --region <REGION> \
  --enable-autoscaling --node-pool <POOL_NAME> \
  --min-nodes <MIN> --max-nodes <MAX> \
  --quiet

# Enable NAP
gcloud container clusters update <CLUSTER_NAME> --region <REGION> \
  --enable-autoprovisioning \
  --min-cpu <MIN_CPU> --max-cpu <MAX_CPU> \
  --min-memory <MIN_MEM> --max-memory <MAX_MEM> \
  --quiet

Autoscaling profiles:

Profile Behavior Golden Path?
BALANCED Default GKE; conservative scale-down No
OPTIMIZE_UTILIZATION Aggressive scale-down; lower idle Yes
: : resources : :

Best Practices

  1. Define resource requests: HPA and VPA rely on accurate requests. Always set them.
  2. Avoid metric conflicts: Do not use HPA and VPA on the same metric. Typical pattern: HPA on CPU, VPA on memory.
  3. Pod Disruption Budgets: Define PDBs for all production workloads to ensure availability during scaling events.
  4. HPA stabilization: HPA has a default 5-minute stabilization window. Tune behavior for faster response if needed.
  5. VPA "Auto" caution: Auto mode restarts pods. Ensure your app handles SIGTERM gracefully. VPA requires at least 2 replicas for evictions by default.
  6. Use ComputeClasses: For workload-specific node targeting (Spot fallback, GPU, specific machine families), use ComputeClasses instead of node selectors.

Rightsizing Workflow

  1. Deploy VPA in Off mode for 24+ hours
  2. Read recommendations: kubectl describe vpa <NAME>
  3. Compare target values against current requests
  4. Apply with 20% buffer: new_request = target * 1.2
  5. Use patch format to update Deployment
Condition Recommendation Risk
CPU request >5x P95 actual Reduce to P95 * 1.2 Medium
Memory request >3x P95 actual Reduce to P95 * 1.2 Medium
CPU request >2x P95 actual Rightsizing with 20% buffer Low
No resource limits set Add limits to prevent noisy-neighbor Low

Version History

  • aabe37a Current 2026-07-05 15:29

Same Skill Collection

skills/ads/data-manager-api/data-manager-api-audience-ingestion/SKILL.md
skills/ads/data-manager-api/data-manager-api-event-ingestion/SKILL.md
skills/ads/data-manager-api/data-manager-api-setup/SKILL.md
skills/ads/google-ads-api/google-ads-api-mcp-setup/SKILL.md
skills/ads/google-mobile-ads/google-mobile-ads-android-migrate-to-next-gen/SKILL.md
skills/ads/google-mobile-ads/google-mobile-ads-banner/SKILL.md
skills/ads/google-mobile-ads/google-mobile-ads-get-started/SKILL.md
skills/ads/google-mobile-ads/google-mobile-ads-interstitial/SKILL.md
skills/ads/google-mobile-ads/google-mobile-ads-rewarded/SKILL.md
skills/ads/interactive-media-ads/ima-sdk-basics/SKILL.md
skills/analytics/google-analytics-admin-api-basics/SKILL.md
skills/analytics/google-analytics-data-api-basics/SKILL.md
skills/cloud/agent-platform-endpoint-management/SKILL.md
skills/cloud/agent-platform-migrate-from-ai-studio/SKILL.md
skills/cloud/agent-platform-model-registry/SKILL.md
skills/cloud/agent-platform-prompt-management/SKILL.md
skills/cloud/agent-platform-rag-engine-management/SKILL.md
skills/cloud/agent-platform-skill-registry/SKILL.md
skills/cloud/agent-platform-tuning-management/SKILL.md
skills/cloud/agent-platform-tuning/SKILL.md
skills/cloud/alloydb-basics/SKILL.md
skills/cloud/bigquery-ai-ml/SKILL.md
skills/cloud/bigquery-basics/SKILL.md
skills/cloud/bigquery-bigframes/SKILL.md
skills/cloud/bigtable-basics/SKILL.md
skills/cloud/cloud-run-basics/SKILL.md
skills/cloud/detection-engineering-coverage-evaluation/SKILL.md
skills/cloud/firebase-basics/SKILL.md
skills/cloud/gcloud/SKILL.md
skills/cloud/gemini-agents-api/SKILL.md
skills/cloud/gemini-api/SKILL.md
skills/cloud/gemini-interactions-api/SKILL.md
skills/cloud/gke-app-onboarding/SKILL.md
skills/cloud/gke-backup-dr/SKILL.md
skills/cloud/gke-basics/SKILL.md
skills/cloud/gke-batch-hpc/SKILL.md
skills/cloud/gke-cluster-creation/SKILL.md
skills/cloud/gke-compute-classes/SKILL.md
skills/cloud/gke-cost/SKILL.md
skills/cloud/gke-golden-path/SKILL.md
skills/cloud/gke-inference/SKILL.md
skills/cloud/gke-multitenancy/SKILL.md
skills/cloud/gke-networking/SKILL.md
skills/cloud/gke-observability/SKILL.md
skills/cloud/gke-reliability/SKILL.md
skills/cloud/gke-security/SKILL.md
skills/cloud/gke-storage/SKILL.md
skills/cloud/google-cloud-networking-observability/SKILL.md
skills/cloud/google-cloud-recipe-auth/SKILL.md
skills/cloud/google-cloud-recipe-onboarding/SKILL.md
skills/cloud/google-cloud-waf-cost-optimization/SKILL.md
skills/cloud/google-cloud-waf-operational-excellence/SKILL.md
skills/cloud/google-cloud-waf-performance-optimization/SKILL.md
skills/cloud/google-cloud-waf-reliability/SKILL.md
skills/cloud/google-cloud-waf-security/SKILL.md
skills/cloud/google-cloud-waf-sustainability/SKILL.md
skills/cloud/iam-recommendations-fetcher/SKILL.md
skills/ads/google-ads-api/google-ads-api-quickstart/SKILL.md
skills/cloud/agent-platform-alert-configuration/SKILL.md
skills/cloud/agent-platform-deploy/SKILL.md
skills/cloud/agent-platform-eval-flywheel/SKILL.md
skills/cloud/agent-platform-inference/SKILL.md
skills/cloud/cloud-sql-basics/SKILL.md
skills/cloud/datalineage-bigquery-asset-impact-analysis/SKILL.md
skills/cloud/gke-upgrades/SKILL.md
skills/cloud/google-agents-cli-onboarding/SKILL.md
skills/cloud/google-cloud-recipe-foundation-builder/SKILL.md
skills/cloud/workload-manager-basics/SKILL.md

Metadata

Files
0
Version
aabe37a
Hash
190e2ef9
Indexed
2026-07-05 15:29

Главная - Вики-сайт
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-07-13 08:46
浙ICP备14020137号-1 $Гость$