Agent Skillsgoogle/skills › gke-workload-scaling

gke-workload-scaling

GitHub

管理GKE工作负载的HPA和VPA自动扩缩容,涵盖手动缩放、基于CPU/内存/自定义指标的HPA配置及VPA资源调整。排除集群级或节点级扩容场景。

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

Trigger Scenarios

配置Horizontal Pod Autoscaler (HPA) 配置Vertical Pod Autoscaler (VPA) 应用GKE工作负载自动扩缩容最佳实践

Install

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

Non-standard path

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

Use without installing

npx skills use google/skills@gke-workload-scaling

指定 Agent (Claude Code)

npx skills add google/skills --skill gke-workload-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-workload-scaling",
    "metadata": {
        "category": "Containers"
    },
    "description": "Manages scaling for GKE workloads using HPA and VPA. Use when configuring Horizontal Pod Autoscaler (HPA), configuring Vertical Pod Autoscaler (VPA), or applying best practices for GKE workload autoscaling. Do not use for cluster-level autoscaling (Cluster Autoscaler), static cluster sizing, or configuring node-level machine styles directly."
}

GKE Workload Scaling

This skill provides workflows and best practices for scaling applications on Google Kubernetes Engine (GKE). It covers manual scaling, Horizontal Pod Autoscaling (HPA), and Vertical Pod Autoscaling (VPA).

Workflows

1. Manual Scaling

Scale a deployment to a fixed number of replicas. Useful for immediate manual intervention or testing.

Command:

kubectl scale deployment {deployment_name} --replicas={number} -n {namespace}

# Verify the scale event
kubectl get deployment {deployment_name} -n {namespace}

2. Horizontal Pod Autoscaling (HPA)

Automatically scale the number of pods based on observed CPU utilization, memory utilization, or custom metrics.

Prerequisites:

  • Metrics Server must be running (enabled by default on GKE).
  • Containers clearly define resource requests/limits.

Quick Command:

kubectl autoscale deployment {deployment_name} --cpu-percent=50 --min=1 --max=10

Manifest Approach (Recommended): Use a YAML manifest for version-controlled configuration. See assets/hpa-example.yaml for a template.

kubectl apply -f assets/hpa-example.yaml

# Verify HPA is created and fetching metrics
kubectl get hpa

Custom Metrics & External Metrics: For GKE, the modern and recommended approach for scaling based on Cloud Monitoring metrics (e.g., Pub/Sub queue length) is to use the External metric type, which is natively supported by the GKE control plane without requiring the Custom Metrics Adapter. For application-specific metrics exposed via Prometheus, you can use Google Cloud Managed Service for Prometheus or the Prometheus Adapter.

3. Vertical Pod Autoscaling (VPA)

Automatically adjust the CPU and memory reservations for your pods to match actual usage. This is critical for right-sizing workloads.

Prerequisites:

  • VPA must be enabled on the cluster.
    • Autopilot: Enabled by default.
    • Standard: Must be enabled manually.

Enable VPA on Standard Cluster:

gcloud container clusters update {cluster_name} --enable-vertical-pod-autoscaling --zone {zone}

Update Modes:

  • Off: Calculates recommendations but does not apply them. Good for "dry run" analysis.
  • Initial: Assigns resources only at pod creation time.
  • Auto: Updates running pods by restarting them if recommendations differ significantly from requests.
  • InPlaceOrRecreate: Attempts to update Pod resources without recreating the Pod. If in-place update is not possible, it reverts to Auto mode (requires GKE 1.34+).

Example: See assets/vpa-example.yaml for a configuration template.

Best Practices

  1. Define Resource Requests: HPA and VPA rely on accurate resource requests. Always define them in your container specs.
  2. Avoid Metric Conflicts: Do not configure HPA and VPA to use the same metric (e.g., both CPU). This causes thrashing.
    • Typical Pattern: HPA on CPU, VPA on Memory.
  3. Pod Disruption Budgets (PDBs): Define PDBs to ensure application availability during scaling events or node upgrades.
  4. HPA Lag: HPA has a stabilization window (default 5 mins) to prevent rapid fluctuation.
  5. VPA "Auto" Mode Risks: In "Auto" mode, VPA restarts pods to change resources. Ensure your application handles restarts gracefully (e.g., handles SIGTERM).
    • Note: By default, VPA requires at least 2 replicas to perform evictions (to prevent a situation where the only running replica is evicted, causing downtime). In GKE 1.22+, you can override this by setting minReplicas in PodUpdatePolicy.

Rightsizing Workflow

  1. Deploy VPA in Off mode for 24+ hours
  2. Read recommendations: kubectl describe vpa {deployment_name}-vpa -n {namespace}
  3. Compare target values against current requests
  4. Apply with 20% buffer: new_request = target * 1.2
  5. Use patch format or update deployment manifest to apply new resource requests
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

  • 513a7a5 Current 2026-07-19 19:04

Same Skill Collection

skills/ads/data-manager-api-audience-ingestion/SKILL.md
skills/ads/data-manager-api-event-ingestion/SKILL.md
skills/ads/data-manager-api-setup/SKILL.md
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-mcp-setup/SKILL.md
skills/ads/google-ads-api/google-ads-api-mcp-setup/SKILL.md
skills/ads/google-mobile-ads-android-migrate-to-next-gen/SKILL.md
skills/ads/google-mobile-ads-banner/SKILL.md
skills/ads/google-mobile-ads-get-started/SKILL.md
skills/ads/google-mobile-ads-interstitial/SKILL.md
skills/ads/google-mobile-ads-rewarded/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/ima-sdk-basics/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-logging-query-generation/SKILL.md
skills/cloud/cloud-monitoring-metric-selection/SKILL.md
skills/cloud/cloud-run-basics/SKILL.md
skills/cloud/datalineage-summary/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-autoscaler/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-scaling/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-solution-agentic-ai-borderless-data-lakehouse/SKILL.md
skills/cloud/google-cloud-solution-agentic-ai-data-science-workflow/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-quickstart/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/gemini-live-api/SKILL.md
skills/cloud/gke-upgrades/SKILL.md
skills/cloud/google-agents-cli-onboarding/SKILL.md
skills/cloud/google-cloud-global-frontend-configuration/SKILL.md
skills/cloud/google-cloud-recipe-foundation-builder/SKILL.md
skills/cloud/google-cloud-solution-agentic-ai-bidirectional-streaming/SKILL.md
skills/cloud/google-cloud-solution-agentic-analytics-spark-knowledge-catalog/SKILL.md
skills/cloud/google-cloud-solution-architecture/SKILL.md
skills/cloud/google-cloud-solution-rag-enterprise-search-gke-sqldb/SKILL.md
skills/cloud/workload-manager-basics/SKILL.md

Metadata

Files
0
Version
513a7a5
Hash
cca5bf26
Indexed
2026-07-19 19:04

inicio - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-07-20 10:10
浙ICP备14020137号-1 $mapa de visitantes$