
Description
Guidance on optimizing costs for Google Kubernetes Engine (GKE) clusters.
SKILL.md
GKE Cost Optimization
This skill provides guidance on optimizing costs for Google Kubernetes Engine (GKE) clusters.
Overview
Cost optimization in GKE involves tracking costs, setting limits to prevent waste, and rightsizing workloads to match actual usage.
Workflows
1. Enable GKE Cost Allocation
GKE cost allocation allows you to see the cost of your GKE resources in Cloud Billing, broken down by namespace and cluster labels.
Steps:
- Enable GKE cost allocation in the cluster settings.
Command:
gcloud container clusters update <cluster-name> \
--enable-cost-allocation \
--region <region>
- View costs in the Cloud Billing reports by grouping by namespace or labels.
2. Configure Resource Quotas
Resource quotas restrict the total resource consumption in a namespace, preventing any single tenant from consuming all cluster resources.
Example ResourceQuota Manifest:
apiVersion: v1
kind: ResourceQuota
metadata:
name: compute-quota
namespace: my-namespace
spec:
hard:
requests.cpu: "4"
requests.memory: 16Gi
limits.cpu: "8"
limits.memory: 32Gi
3. Rightsizing Strategies
Rightsizing involves adjusting the requested resources of your workloads to match their actual utilization.
- Use VPA in Recommender Mode: Let VPA observe usage and recommend CPU and memory requests.
- Use MPA: Reconcile HPA and VPA to avoid conflicts.
- Review Cost Recommendations: Check the Google Cloud Console for GKE cost optimization recommendations.
Best Practices
- Enable Cost Allocation: Always enable GKE cost allocation to understand where your money is going.
- Use Resource Quotas: Enforce resource quotas in multi-tenant clusters to prevent cost runaways.
- Leverage Spot VMs: Use Spot VMs for fault-tolerant, stateless workloads to save up to 91%.
- Automate Scaling: Use Cluster Autoscaler and HPA/VPA to ensure you only pay for what you need.
More skills from the gke-mcp repository
View all 25 skillscustom-golden-image-discovery
discover golden base images for GKE nodes
Jul 12DeploymentGoogle CloudKubernetesgke-ai-troubleshooting-handle-disruption-gpu-tpu
diagnose GPU and TPU workload disruptions
Jul 28DebuggingGoogle CloudKubernetesPerformancegke-ai-troubleshooting-jobset-interruption
diagnose GKE JobSet interruptions
Jul 12DebuggingGoogle CloudKubernetesObservabilitygke-ai-troubleshooting-skill-creation-guide
create GKE troubleshooting skill bundles
Jul 12DocumentationEngineeringGoogle CloudTechnical Writinggke-ai-troubleshooting-tpu-connection-failure-vbar-oom
diagnose GKE TPU connection failures
Jul 12DebuggingGoogle CloudKubernetesPerformancegke-app-onboarding
containerize and deploy apps to GKE
Jul 12ContainersDeploymentGoogle CloudKubernetes +1
More from Google Cloud
View publisherkb-search
search and extract local knowledge base documents
knowledge-catalog
Jul 12DocumentationKnowledge BaseSearchknowledge_catalog_discovery_agent
search and rank Knowledge Catalog data entries
knowledge-catalog
Jul 12Data AnalysisGoogle CloudKnowledge ManagementSearchcontributing
contribute to Cloud Foundation Fabric
cloud-foundation-fabric
Jul 31AutomationEngineeringGitHubGoogle Cloud +1fabric-builder
generate Terraform code for Google Cloud
cloud-foundation-fabric
Jul 12Google CloudInfrastructure as CodeTerraformfast-0-org-setup-prereqs
prepare prerequisites for FAST 0-org-setup
cloud-foundation-fabric
Jul 12Google CloudOperationsagent-aware-cli
design agent-aware command-line interfaces
vertex-ai-creative-studio
Jul 12CLIEngineeringGoogle Cloud