Writing Skills
writing-skills
效率与协作技能,来自 obra/superpowers,查看原文获取完整用途和操作说明。
k8s-cost-optimizer【部署与运维】Analyzes Kubernetes cluster resource allocation versus actual usage to find waste and generate right-sizing recommendations. Use when someone asks about Kubernetes costs, overprovisioned pods, resource requests/limits tuning, cluster efficiency, or cloud bill reduction for K8s workloads. Trigger words: k8s costs, pod resources, right-size, overprovis…
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
This skill audits Kubernetes clusters for resource inefficiency by comparing requested CPU/memory against actual usage from metrics-server. It identifies zombie deployments, overprovisioned workloads, and generates kustomize-compatible patches for right-sizing with safety buffers.
Run kubectl cluster-info and kubectl top nodes to confirm connectivity and that metrics-server is running. If metrics-server is unavailable, inform the user and suggest installing it first.
For each namespace (or user-specified namespaces):
# Get resource requests/limits for all pods
kubectl get pods --all-namespaces -o json | jq '[.items[] | {
namespace: .metadata.namespace,
pod: .metadata.name,
containers: [.spec.containers[] | {
name: .name,
cpu_request: .resources.requests.cpu,
cpu_limit: .resources.limits.cpu,
mem_request: .resources.requests.memory,
mem_limit: .resources.limits.memory
}]
}]'
# Get actual usage
kubectl top pods --all-namespaces --no-headers
For each deployment, compute:
Use these reference prices if the user doesn't specify:
Flag deployments where:
For each overprovisioned workload:
Format a table showing:
User prompt:
Audit the api-services namespace for resource waste
Agent output:
Resource Audit: api-services namespace
───────────────────────────────────────
Deployment Replicas CPU Req→Used Mem Req→Used Efficiency Est. Waste
user-auth 3 500m→120m 1Gi→340Mi 26% $85/mo
order-processor 2 1000m→650m 2Gi→1.4Gi 68% $31/mo
email-worker 2 250m→15m 512Mi→80Mi 8% $42/mo
Recommendations:
1. email-worker: Reduce to 1 replica, set requests to cpu:50m/mem:150Mi → saves $42/mo
2. user-auth: Set requests to cpu:180m/mem:500Mi → saves $68/mo
3. order-processor: Requests are reasonable, minor trim to cpu:850m → saves $12/mo
Total potential savings: $122/month ($1,464/year)
User prompt:
Find unused deployments across all namespaces
Agent output:
Zombie Workloads Detected
─────────────────────────
Namespace: staging
✗ feature-auth-v2 2 replicas CPU: 0m Last deploy: 2025-09-14 → $28/mo wasted
✗ hotfix-payment-flow 1 replica CPU: 0m Last deploy: 2025-10-02 → $14/mo wasted
✗ demo-dashboard 3 replicas CPU: 0m Last deploy: 2025-07-28 → $42/mo wasted
Namespace: dev
✗ test-migration 1 replica CPU: 0m Last deploy: 2025-11-18 → $14/mo wasted
Suggested cleanup:
kubectl delete deployment feature-auth-v2 hotfix-payment-flow demo-dashboard -n staging
kubectl delete deployment test-migration -n dev
Total zombie cost: $98/month