Kubernetes Cost Optimization
Optimize Kubernetes costs through resource right-sizing, unused resource detection, and cluster efficiency analysis. Use for cost optimization, resource analysis, and capacity plan…
Rohit Ghumare
@rohitg00
Install
$ openclaw skills install @rohitg00/k8s-costKubernetes Cost Optimization
Cost analysis and optimization using kubectl-mcp-server's cost tools.
Requires the
cost,kedatoolsets: start kubectl-mcp-server with--toolsets default,cost,keda(orMCP_TOOLSETS=default,cost,keda).
When to Apply
Use this skill when:
- User mentions: "cost", "savings", "optimize", "expensive", "budget"
- Operations: cost analysis, right-sizing, cleanup unused resources
- Keywords: "how much", "reduce", "efficiency", "waste", "overprovisioned"
Priority Rules
| Priority | Rule | Impact | Tools |
|---|---|---|---|
| 1 | Find and delete unused PVCs | CRITICAL | get_idle_resources |
| 2 | Right-size overprovisioned pods | HIGH | get_resource_recommendations |
| 3 | Identify idle LoadBalancers | HIGH | kubectl_get |
| 4 | Scale down non-prod off-hours | MEDIUM | kubectl_scale |
| 5 | Consolidate small namespaces | LOW | Analysis |
Quick Reference
| Task | Tool | Example |
|---|---|---|
| Namespace cost | get_namespace_cost_allocation | get_namespace_cost_allocation(namespace) |
| Cluster cost | get_cost_analysis | get_cost_analysis() |
| Unused PVCs | get_idle_resources | get_idle_resources(namespace) |
| Right-sizing | get_resource_recommendations | get_resource_recommendations(namespace) |
Quick Cost Analysis
Get Cost Summary
get_namespace_cost_allocation(namespace)
get_cost_analysis()
Find Unused Resources
get_idle_resources(namespace)
get_idle_resources(namespace)
Resource Right-Sizing
get_resource_recommendations(namespace)
kubectl_top(name, namespace)
Cost Optimization Workflow
1. Identify Overprovisioned Resources
get_resource_recommendations(namespace="production")
kubectl_top(name, namespace)
kubectl_top(namespace)
2. Find Idle Resources
get_idle_resources(namespace)
get_idle_resources(namespace)
3. Analyze Node Utilization
kubectl_get(resource_type="nodes")
kubectl_top(resource="nodes")
Right-Sizing Guidelines
| Current State | Recommendation |
|---|---|
| CPU usage < 10% of request | Reduce request by 50% |
| CPU usage > 80% of request | Increase request by 25% |
| Memory < 50% of request | Reduce request |
| Memory near limit | Increase limit, monitor OOM |
Cost by Resource Type
Compute (Pods/Deployments)
kubectl_top(namespace)
kubectl_top(name, namespace)
Storage (PVCs)
kubectl_get(resource_type="pvc", namespace)
get_idle_resources(namespace)
Network (LoadBalancers)
kubectl_get(resource_type="services", namespace)
Multi-Cluster Cost Analysis
Compare costs across clusters:
get_cost_analysis(context="production")
get_cost_analysis(context="staging")
get_cost_analysis(context="development")
Cost Reduction Actions
Immediate Wins
- Delete unused PVCs:
get_idle_resources()then delete - Right-size pods: Apply
get_resource_recommendations() - Scale down dev/staging: Off-hours scaling
Medium-term Optimizations
- Use Spot/Preemptible nodes: For fault-tolerant workloads
- Implement HPA: Auto-scale based on demand
- Use KEDA: Scale to zero for event-driven workloads
Long-term Strategy
- Reserved instances: For stable production workloads
- Multi-tenant clusters: Consolidate small clusters
- Right-size node pools: Match workload requirements
Automated Analysis Script
For comprehensive cost analysis, see scripts/find-overprovisioned.py.
KEDA for Cost Savings
Scale to zero with KEDA:
keda_scaledobjects_list(namespace)
keda_scaledobject_get(name, namespace)
KEDA reduces costs by:
- Scaling pods to 0 when idle
- Event-driven scaling (queue depth, etc.)
- Cron-based scaling for predictable patterns
Related Skills
- k8s-autoscaling - HPA, VPA, KEDA
- k8s-troubleshoot - Resource debugging
Top skills in this category
API Gateway
@byungkyuCall third-party APIs through the Maton gateway, which injects the credential for an app the user has already connected. Use this skill when the user names a connected app and a concrete action in it - read a mailbox, query a CRM, file an issue, update a spreadsheet, etc.
Marketing Mode
@thesethroseMarketing Mode combines 23 comprehensive marketing skills covering strategy, psychology, content, SEO, conversion optimization, and paid growth. Use when users need marketing strategy, copywriting, SEO help, conversion optimization, paid advertising, or any marketing tactic.
Blogwatcher
@steipeteMonitor blogs and RSS/Atom feeds for updates using the blogwatcher CLI.
Marketing Skills
@jchopard69Access 23 marketing modules offering checklists, frameworks, and ready-to-use deliverables for CRO, SEO, copywriting, analytics, launches, ads, and social me...
diagram-generator
@matthewyinGenerate and edit diagrams with the mcp-diagram-generator MCP server. Use this skill for new diagrams, existing .drawio/.mmd/.excalidraw edits, network topology, architecture, flowchart, swimlane, sequence, class, ER, and Excalidraw whiteboard work. Always use this skill when the user asks to draw,