
gke-cost
Optimizes GKE costs, rightsizes workloads, and configures Spot VMs and CUDs. Use when optimizing GKE costs, rightsizing GKE workloads, or configuring GKE Spot VMs. Don't use for general compute class provisioning or GPU Selection (use gke-compute-classes instead).
- Installs
- 1.3K
- Last 24h
- —
- Trending rank
- —
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/google/skills --skill gke-cost- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads gke-cost automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
GKE Cost Optimization
This reference covers strategies for reducing GKE costs while maintaining the golden path security and reliability posture.
MCP Tools:
get_k8s_resource,describe_k8s_resource,apply_k8s_manifest,patch_k8s_resource,get_cluster
Golden Path Cost Features
The golden path already includes cost-optimizing settings:
| Setting | Value | Impact |
|---|---|---|
autoscalingProfile | OPTIMIZE_UTILIZATION | Aggressive node |
| : : : scale-down reduces idle : | ||
| : : : compute : | ||
verticalPodAutoscaling | enabled | VPA recommendations |
| : : : prevent : | ||
| : : : over-provisioning : | ||
| Autopilot pricing | Pay per pod request | No charge for unused |
| : : : node capacity : | ||
| Node Auto Provisioning | enabled | Right-sized node pools |
| : : : created automatically : |
Cost Optimization Strategies
1. Spot VMs via ComputeClasses
Use Spot VMs for fault-tolerant workloads (60-90% cost reduction).
apiVersion: cloud.google.com/v1
kind: ComputeClass
metadata:
name: spot-with-fallback
spec:
activeMigration:
optimizeRulePriority: true
priorities:
- machineFamily: n4
spot: true
- machineFamily: n4
spot: false
Spot-suitable workloads:
| Workload | Spot-Suitable? |
|---|---|
| Batch / data processing | Yes |
| Dev / test environments | Yes |
| Stateless web/API (replicas >= 2) | Yes (with PDBs) |
| Jobs with checkpointing | Yes |
| Stateful workloads (databases) | No |
| Single-replica critical services | No |
Handling eviction:
spec:
template:
spec:
terminationGracePeriodSeconds: 25 # Must be < 30s for Spot
containers:
- name: app
lifecycle:
preStop:
exec:
command: ["/bin/sh", "-c", "sleep 5"]
1.1 Direct Workload Spot Selection (NodeSelector)
For stateless or batch workloads in GKE Autopilot, you do not need to create a
custom ComputeClass to use Spot VMs. You can target the built-in Spot capacity
directly by adding a nodeSelector to your Pod or Deployment spec.
[!WARNING] Preemption Warning: Spot VMs are interruptible and can be preempted at any time with a 30-second notice. Workloads must be fault-tolerant and run with at least 2 replicas for high availability. Always explicitly warn users about this preemption risk when recommending Spot VMs.
apiVersion: apps/v1
kind: Deployment
metadata:
name: stateless-spot-app
spec:
replicas: 2
template:
spec:
nodeSelector:
cloud.google.com/gke-provisioning: Spot
terminationGracePeriodSeconds: 25 # Must be < 30s to allow graceful shutdown before preemption
containers:
- name: app
image: <IMAGE>
2. Pod Rightsizing
Use VPA recommendations to reduce over-provisioned requests.
# 1. Deploy VPA in recommendation mode
kubectl apply -f - <<EOF
apiVersion: autoscaling.k8s.io/v1
kind: VerticalPodAutoscaler
metadata:
name: <DEPLOYMENT>-vpa
spec:
targetRef:
apiVersion: apps/v1
kind: Deployment
name: <DEPLOYMENT>
updatePolicy:
updateMode: "Off"
EOF
# 2. Wait 24+ hours for data collection
# 3. Read recommendations
kubectl get vpa <DEPLOYMENT>-vpa -o jsonpath='{.status.recommendation}'
Optimization rules:
| Condition | Action | Savings |
|---|---|---|
| CPU request >5x P95 actual | Reduce to P95 * 1.2 | High |
| Memory request >3x P95 actual | Reduce to P95 * 1.2 | High |
| CPU request >2x P95 actual | Reduce to P95 * 1.2 | Medium |
| No resource requests set | Add requests (enables bin-packing) | Medium |
3. Machine Type Selection
| Family | Use Case | Relative Cost |
|---|---|---|
| e2 | General purpose, burstable | Lowest |
| t2a / t2d | Scale-out (Arm/AMD), price-performance | Low |
| : : optimized : : | ||
| n4a | Axion Arm-based, general-purpose | Low |
| : : price-performance : : | ||
| n4 / n4d | General purpose (Intel/AMD), flexible shapes | Low-Medium |
| c4a | Compute-optimized (Arm), high efficiency | Medium-High |
| c3 / c4 | Compute-optimized (Intel) | Medium-High |
| c3d / c4d | Compute-optimized (AMD), high-performance | Medium-High |
| : : throughput : : | ||
| ek-standard | Autopilot enhanced (golden path) | Medium |
| m3 / x4 | Memory-optimized, SAP HANA, large databases | High |
| g2 (L4 GPU) | AI inference | High |
| a3 (H100 GPU) | AI training | Highest |
| a4 / a4x | Ultra-scale AI (Blackwell GPUs) | Highest |
In Autopilot, machine type is managed. Use ComputeClasses to influence selection.
4. Committed Use Discounts (CUDs)
For steady-state workloads, purchase 1-year or 3-year CUDs:
- 1-year: ~20-30% discount
- 3-year: ~50-55% discount
- Applied automatically to matching usage in the region
- Purchase via Google Cloud Console > Billing > Committed use discounts
5. Cluster Management
- Stop/start dev clusters: Idle dev clusters cost money even with no workloads (control plane fee).
- Right-size node pools (Standard): Use Cluster Autoscaler with appropriate min/max.
- Multi-tenant clusters: Share a single cluster across teams instead of
per-team clusters (see the
gke-multitenancyskill).
Cost Monitoring
# View cluster cost breakdown (requires Cost Management API)
gcloud billing budgets list --billing-account=<BILLING_ACCOUNT> --quiet
# View node utilization
kubectl top nodes
# View pod resource usage vs requests
kubectl top pods --all-namespaces --containers
Dev/Test Cost Savings
For non-production environments, these golden path deviations are acceptable:
| Setting | Production (Golden | Dev/Test | : : Path) : : | ----------------------- | ------------------ | ----------------------------- | | Cluster mode | Autopilot | Autopilot (cheaper with fewer | : : : pods) : | Release channel | Regular | Rapid (get fixes faster) | | Private nodes | Required | Optional (simpler access) | | Monitoring components | Full suite | SYSTEM_COMPONENTS only | | Secret Manager rotation | 120s | Disabled | | Maintenance windows | Configured | Not needed |
FAQ
What does the gke-cost skill do?
Optimizes GKE costs, rightsizes workloads, and configures Spot VMs and CUDs. Use when optimizing GKE costs, rightsizing GKE workloads, or configuring GKE Spot VMs. Don't use for general compute class provisioning or GPU Selection (use gke-compute-classes instead).
How do I install gke-cost?
Run npx skills add https://github.com/google/skills --skill gke-cost in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/gke-cost/ (personal) or .claude/skills/gke-cost/ (project).
Which AI agents can use gke-cost?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is gke-cost safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains gke-cost?
It is published by google in google/skills. It has 1,263 recorded installs.
More from google/skills
bigquery-basics
google/skills
Manages datasets, tables, and jobs in BigQuery. Use when you need to interact with BigQuery, run SQL queries, manage BigQuery resources (datasets, tables, views), or perform basic data ingestion and analysis.
cloud-run-basics
google/skills
Manages Cloud Run services, jobs, and worker pools. Use when you need to deploy applications responding to HTTP requests (services), run event-triggered or scheduled tasks (jobs), or handle always-on pull-based background processing (worker pools).
gemini-api
google/skills
Use when the user asks about using Gemini in an enterprise environment or explicitly mentions Vertex AI, Google Cloud, or Agent Platform. Guides the usage of the Gemini API on Agent Platform with the Google Gen AI SDK. Covers SDK usage (Python, JS/TS, Go, Java, C), capabilities like multimodal inputs, tools, media generation, caching, batch prediction, and Live API.
google-cloud-recipe-auth
google/skills
Provides expert guidance on Identity and Access Management (IAM) and authenticating and authorizing to Google Cloud services and APIs, covering human users, service identities, Application Default Credentials (ADC), and best practices for secure access.
google-cloud-recipe-onboarding
google/skills
Guides a developer's first steps on Google Cloud, covering account creation, billing setup, project management, and deploying a first resource. Use when a new developer wants to initialize their first Google Cloud project, configure billing, and verify deployment. Don't use for enterprise organization setup (use Google Cloud Setup guided flow for that instead). Don't use for complex multi-project architectures.
cloud-sql-basics
google/skills
This file generates or explains Cloud SQL resources. Use this file when the user asks to create a Cloud SQL instance or database for MySQL, PostgreSQL, or SQL Server. Cloud SQL manages third-party MySQL, PostgreSQL, and SQL Server instances as resources in Cloud SQL. For example, when Cloud SQL creates an open-source MySQL instance, the resulting resource is a Cloud SQL for MySQL instance that Google Cloud manages. Cloud SQL handles backups, high availability, and secure connectivity for relational database workloads.
Popular other skills
hyperframes-cli
heygen-com/hyperframes
The HyperFrames CLI by job - scaffold, check, look at frames, edit the timeline, preview, render locally or in the cloud, publish, project history - plus reading its JSON and recovering from build or render failures.
triage
mattpocock/skills
Move issues and external PRs through a state machine of triage roles, categorise, verify, grill if needed, and write agent-ready briefs.
ask-matt
mattpocock/skills
Ask which skill or flow fits your situation. A router over the skills in this repo.
to-questionnaire
mattpocock/skills
Turn a decision you can't fully answer into a questionnaire for someone else to fill in.
loop-me
mattpocock/skills
Grill me about specs for the workflows I want to build, within this workspace.