agentleFS
RuneStone-TechRuneStone-Tech/optimize-anything/skills/devops/kubernetes/SKILL.md

kubernetes-optimizer

Skill1 starsChanged 8 days agoMITView on GitHub

Audit and optimize Kubernetes manifests and workloads (Kubernetes 1.37 current, 1.36/1.35 supported, 1.34 EOL) for requests/limits and scheduling, probes and lifecycle, securityContext/Pod Security/RBAC, Services/Ingress/NetworkPolicy, HPA/PDB/autoscaling and cost, observability, deprecated APIs and safe upgrades, with real before/after measurement. Always produces a written findings report and a fix plan for approval before touching code. Use this whenever the user mentions Kubernetes manifests, Helm/Kustomize, resource requests/limits, OOMKilled/CrashLoopBackOff, readiness/liveness probes, HPA/PDB, NetworkPolicy, RBAC, Pod Security, cluster upgrades, K8s cost, or "optimize my Kubernetes setup" -- even if they never say audit or optimize.

The file

We split this skill into the rules it gives an agent

5 rules. About 0 are common, 1 is distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Run python <skill-dir>/scripts/audit.py <repo-root> -- static scan for floating images, missing probes/resources/securityContext, …

    line 15
  2. Very specific:

    Read references/upgrades-tooling.md once: what can be measured here (kubectl, metrics-server, kube-state-metrics, scans, cost tools).

    line 17
  3. Very specific:

    Measure, never guess: Read the live objects (kubectl get/describe), metrics (CPU/memory throttling, OOMKills, restarts, pending pods), …

    line 32
  4. Very specific:

    Use plan mode: EnterPlanMode (load with ToolSearch if deferred), write the plan, present with ExitPlanMode.

    line 42
  5. Distinctive:

    Upgrade one minor at a time: Check deprecated APIs and add-on compatibility before the control plane moves.

    line 65

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Kubernetes Optimizer

Audit a Kubernetes workload/config, report what is unsafe, unreliable or expensive and why, agree a plan, then change it. Order: evidence, approval, edits. Cluster changes can cause outages; nothing is applied before approval.

Workflow

1. Scope (quick)

  • Find the manifests/Helm/Kustomize and record: cluster version (1.37 current; 1.36/1.35 supported; 1.34 EOL), distribution, ingress/CNI/CSI, autoscaler, workload types, namespaces and environment.
  • Run python <skill-dir>/scripts/audit.py <repo-root> -- static scan for floating images, missing probes/resources/securityContext, privileged/host access, deprecated APIs, missing PDB/NetworkPolicy/HPA, secrets in env and risky Services/Ingress, with file:line evidence. Use --json to post-process.
  • Classify the pain: reliability (OOM/crash/restarts), latency/throughput, scheduling/capacity, security/compliance, cost, or upgrade risk. Ask which hurts if unclear.
  • Read references/upgrades-tooling.md once: what can be measured here (kubectl, metrics-server, kube-state-metrics, scans, cost tools).

2. Audit

The script finds cheap leads; you find the rest by reading the manifests and the live cluster. Load only what applies:

AreaReference
Deployments/StatefulSets, probes, requests/limits, lifecycle, PDB, topologyreferences/workloads.md
Services, Ingress, NetworkPolicy, DNS, mTLSreferences/networking.md
securityContext, Pod Security, RBAC, secrets, admissionreferences/security.md
HPA/VPA/autoscaling, scheduling, capacity and costreferences/scaling-cost.md
Metrics, logs, traces, events, SLOs and alertsreferences/observability.md
API deprecations, cluster upgrades, validation/scanning toolsreferences/upgrades-tooling.md

Measure, never guess. Read the live objects (kubectl get/describe), metrics (CPU/memory throttling, OOMKills, restarts, pending pods), events and traces. A YAML review without cluster evidence is a hypothesis; a healthy pod at low load is not capacity proof.

Mark each finding Confirmed (kubectl/metrics/event/code evidence) or Suspected (needs measuring).

3. Report

Fill assets/report-template.md, save it as KUBERNETES_OPTIMIZATION_REPORT.md in the repo root, and show the user. Five-line summary, findings table by impact/effort/risk, then per-finding detail (evidence, why it hurts, fix, risk, rollout/rollback). Group near-duplicates.

4. Plan -- then stop for approval

Use plan mode: EnterPlanMode (load with ToolSearch if deferred), write the plan, present with ExitPlanMode; if unavailable show it in chat and wait for an explicit "go". Structure:

  1. Quick wins -- pin images, set requests/limits, add readiness/startup probes, securityContext, PDB, NetworkPolicy, HPA, fix deprecated APIs. Low risk, manifest-only.
  2. Structural -- right-size requests from metrics, split workloads, topology spread/anti-affinity, HPA/VPA strategy, ingress/TLS, RBAC least privilege, resource quotas, cost labels. Name each behavior change.
  3. Heavy -- cluster upgrade, CNI/CSI/ingress replacement, autoscaler migration, multi-cluster/multi-tenant architecture. Separately approved with a staged rollout. Each step: files/cluster objects touched, expected effect, how to verify, how to roll back.

5. Fix

Only approved items, in small groups. After each: kubectl diff/server-side dry-run, policy/scan checks, rollout status, and the relevant metrics. A break must trace to one change. Do not mix a cluster upgrade with workload optimization. If a change alters availability (PDB/replicas), security posture, or network reachability, stop and ask.

6. Verify and wrap up

Re-check the same objects/metrics: restarts/OOMKills, pending pods, CPU throttling, p95/p99 latency, availability during rollout, HPA behavior, cost. State plainly what could not be measured. End with deferred items and one suggested next step.

Principles

  • Requests are scheduling; limits are enforcement. Set requests from measured usage, not guesses.
  • Probes must reflect readiness, not liveness theater. Startup protects slow boots; readiness removes traffic; liveness restarts only true hangs.
  • Least privilege by default. Non-root, no privilege escalation, read-only rootfs, dropped capabilities, scoped RBAC.
  • Availability is a budget. PDB, replicas, topology spread and graceful termination are part of correctness.
  • Network is deny-by-default where possible. NetworkPolicy + explicit ingress/egress.
  • Autoscaling needs signals. HPA on meaningful metrics, requests set, and a node autoscaler that can react.
  • Upgrade one minor at a time. Check deprecated APIs and add-on compatibility before the control plane moves.
  • Cost is a workload property. Requests, replicas, storage class and idle capacity have owners.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.