Analyze and reduce Kubernetes infrastructure costs through resource right-sizing and idle resource cleanup.
Install
mkdir -p .claude/skills/k8s-cost && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/7299" && unzip -o skill.zip -d .claude/skills/k8s-cost && rm skill.zipInstalls to .claude/skills/k8s-cost
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Optimize Kubernetes costs through resource right-sizing, unused resource detection, and cluster efficiency analysis. Use for cost optimization, resource analysis, and capacity planning.Key capabilities
- →Analyze namespace and cluster costs
- →Identify orphaned persistent volume claims
- →Provide resource right-sizing recommendations
- →Identify idle load balancers
- →Scale down non-production environments
How it works
It utilizes cost analysis tools to inspect resource usage, identify waste like orphaned PVCs or overprovisioned pods, and suggest scaling actions.
Inputs & outputs
When to use k8s-cost
- →Cleaning up orphaned persistent volume claims
- →Right-sizing overprovisioned pod resources
- →Analyzing namespace cost allocation
- →Scaling down development environments during off-hours
About this skill
Kubernetes Cost Optimization
Cost analysis and optimization using kubectl-mcp-server's cost tools.
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 | find_orphaned_pvcs |
| 2 | Right-size overprovisioned pods | HIGH | get_resource_recommendations |
| 3 | Identify idle LoadBalancers | HIGH | get_services |
| 4 | Scale down non-prod off-hours | MEDIUM | scale_deployment |
| 5 | Consolidate small namespaces | LOW | Analysis |
Quick Reference
| Task | Tool | Example |
|---|---|---|
| Namespace cost | get_namespace_cost | get_namespace_cost(namespace) |
| Cluster cost | get_cluster_cost | get_cluster_cost() |
| Unused PVCs | find_orphaned_pvcs | find_orphaned_pvcs(namespace) |
| Right-sizing | get_resource_recommendations | get_resource_recommendations(namespace) |
Quick Cost Analysis
Get Cost Summary
get_namespace_cost(namespace)
get_cluster_cost()
Find Unused Resources
find_unused_resources(namespace)
find_orphaned_pvcs(namespace)
Resource Right-Sizing
get_resource_recommendations(namespace)
get_pod_metrics(name, namespace)
Cost Optimization Workflow
1. Identify Overprovisioned Resources
get_resource_recommendations(namespace="production")
get_pod_metrics(name, namespace)
get_resource_usage(namespace)
2. Find Idle Resources
find_orphaned_pvcs(namespace)
find_unused_resources(namespace)
3. Analyze Node Utilization
get_nodes()
get_node_metrics()
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)
get_resource_usage(namespace)
get_pod_metrics(name, namespace)
Storage (PVCs)
get_pvc(namespace)
find_orphaned_pvcs(namespace)
Network (LoadBalancers)
get_services(namespace)
Multi-Cluster Cost Analysis
Compare costs across clusters:
get_cluster_cost(context="production")
get_cluster_cost(context="staging")
get_cluster_cost(context="development")
Cost Reduction Actions
Immediate Wins
- Delete unused PVCs:
find_orphaned_pvcs()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_tool(namespace)
keda_scaledobject_get_tool(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
When not to use it
- →When the cluster lacks the necessary monitoring metrics
- →When the user does not have permission to modify cluster resources
Limitations
- →Requires access to cluster metrics
- →Recommendations require manual review before application
How it compares
This skill provides specific, actionable cost-saving recommendations based on cluster metrics rather than general resource monitoring.
Compared to similar skills
k8s-cost side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| k8s-cost (this skill) | 3 | 6mo | Review | Intermediate |
| k8s-cilium | 1 | 6mo | Review | Advanced |
| linkerd-patterns | 6 | 5mo | Review | Advanced |
| storage-networking | 6 | 7mo | Review | Advanced |
Try saying
Example prompts that trigger this skill in your AI assistant.
More by rohitg00
View all by rohitg00 →You might also like
k8s-cilium
rohitg00
Cilium and Hubble network observability for Kubernetes. Use when managing network policies, observing traffic flows, or troubleshooting connectivity with eBPF-based networking.
linkerd-patterns
wshobson
Implement Linkerd service mesh patterns for lightweight, security-focused service mesh deployments. Use when setting up Linkerd, configuring traffic policies, or implementing zero-trust networking with minimal overhead.
storage-networking
pluginagentmarketplace
Master Kubernetes storage management and networking architecture. Learn persistent storage, network policies, service discovery, and ingress routing.
k8s-helm
rohitg00
Manage Helm charts, releases, and repositories. Use for Helm installations, upgrades, rollbacks, chart development, and release management.
observability-engineer
sickn33
Build production-ready monitoring, logging, and tracing systems. Implements comprehensive observability strategies, SLI/SLO management, and incident response workflows. Use PROACTIVELY for monitoring infrastructure, performance optimization, or production reliability.
kubernetes-architect
sickn33
Expert Kubernetes architect specializing in cloud-native infrastructure, advanced GitOps workflows (ArgoCD/Flux), and enterprise container orchestration. Masters EKS/AKS/GKE, service mesh (Istio/Linkerd), progressive delivery, multi-tenancy, and platform engineering. Handles security, observability, cost optimization, and developer experience. Use PROACTIVELY for K8s architecture, GitOps implementation, or cloud-native platform design.