用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/castai/k8s-ai-workshop --skill k8s-resource-rightsizing命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
基于 SOC 职业分类
| name | k8s-resource-rightsizing |
| description | Diagnose OOMKilled pods and fix resource configuration by analyzing actual usage patterns |
I diagnose workloads that are crashing due to incorrect resource limits. I analyze the actual usage pattern of the application, determine the correct resource values, and apply a fix that keeps the workload stable.
kubectl get pods -n <namespace>
Look for:
OOMKilled status — the kernel killed the container for exceeding its memory limitRunning and OOMKilledkubectl describe pod -l app=<name> -n <namespace>
Look in the container status for:
Last State: Terminated
Reason: OOMKilled
Exit Code: 137
Exit code 137 = SIGKILL from OOM killer. The container used more memory than its limits.memory allows.
kubectl get deployment <name> -n <namespace> -o yaml | grep -A 8 resources
Note:
requests.memory — what the scheduler reserves (affects scheduling)limits.memory — the hard ceiling (exceeding this triggers OOMKill)kubectl top pods -n <namespace>
Run this multiple times over 1-2 minutes. Many workloads have usage phases:
The limit must accommodate the PEAK usage, not just the initial usage. If kubectl top shows 60Mi now but the pod OOMKills later, the workload ramps up over time.
Also check pod logs for clues about usage phases:
kubectl logs -l app=<name> -n <namespace>
Calculate the right resource settings:
Memory limit = peak steady-state usage + 30% headroom
Memory request = typical steady-state usage
CPU request = actual CPU usage (from kubectl top)
CPU limit = 2-4x the request to allow burst capacity
kubectl patch deployment <name> -n <namespace> --type=json -p='[
{"op": "replace", "path": "/spec/template/spec/containers/0/resources/requests/memory", "value": "<new-request>"},
{"op": "replace", "path": "/spec/template/spec/containers/0/resources/limits/memory", "value": "<new-limit>"},
{"op": "replace", "path": "/spec/template/spec/containers/0/resources/requests/cpu", "value": "<new-request>"},
{"op": "replace", "path": "/spec/template/spec/containers/0/resources/limits/cpu", "value": "<new-limit>"}
]'
Or use kubectl edit deployment <name> -n <namespace> to modify the values.
After applying the fix:
kubectl rollout status deployment/<name> -n <namespace>
kubectl get pods -n <namespace> -w
Watch for 2-3 minutes to confirm:
kubectl top pods -n <namespace> shows memory usage staying below the new limitIf pods still OOMKill, the limit is still too low — increase it further.
After fixing, summarize:
Use this skill when: