gke-cost-optimization
Guidance on optimizing costs for Google Kubernetes Engine (GKE) clusters.
Works with
---
name: gke-cost-optimization
description: Guidance on optimizing costs for Google Kubernetes Engine (GKE) clusters.
license: Apache-2.0
---
# 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:**
1. Enable GKE cost allocation in the cluster settings.
**Command:**
```bash
gcloud container clusters update <cluster-name> \
--enable-cost-allocation \
--region <region>
```
2. 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:**
```yaml
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
1. **Enable Cost Allocation**: Always enable GKE cost allocation to understand where your money is going.
2. **Use Resource Quotas**: Enforce resource quotas in multi-tenant clusters to prevent cost runaways.
3. **Leverage Spot VMs**: Use Spot VMs for fault-tolerant, stateless workloads to save up to 91%.
4. **Automate Scaling**: Use Cluster Autoscaler and HPA/VPA to ensure you only pay for what you need.More DevOps & Infrastructure skills
azure-ai
microsoft/azure-skills
Use for Azure AI: Search, Speech, OpenAI, Document Intelligence. Helps with search, vector/hybrid search, speech-to-text, text-to-speech, transcription, OCR. WHEN: AI Search, query search, vector search, hybrid search, semantic search, speech-to-text, text-to-speech, transcribe, OCR, convert text to speech.
appinsights-instrumentation
microsoft/azure-skills
Guidance for instrumenting webapps with Azure Application Insights. Provides telemetry patterns, SDK setup, and configuration references. WHEN: how to instrument app, App Insights SDK, telemetry patterns, what is App Insights, Application Insights guidance, instrumentation examples, APM best practices.
azure-storage
microsoft/azure-skills
Azure Storage Services including Blob Storage, File Shares, Queue Storage, Table Storage, and Data Lake. Answers questions about storage access tiers (hot, cool, cold, archive), when to use each tier, and tier comparison. Provides object storage, SMB file shares, async messaging, NoSQL key-value, and big data analytics. Includes lifecycle management. USE FOR: blob storage, file shares, queue storage, table storage, data lake, upload files, download blobs, storage accounts, access tiers, storage tiers, hot cool cold archive, storage tier comparison, when to use storage tiers, lifecycle management, Azure Storage concepts. DO NOT USE FOR: SQL databases, Cosmos DB (use azure-prepare), messaging with Event Hubs or Service Bus (use azure-messaging).

