用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/tomevault-io/skills-registry --skill kubernetes命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
基于 SOC 职业分类
正在显示 SKILL.md
| name | kubernetes |
| description | >- Use when this capability is needed. |
Best practices and anti-patterns for Kubernetes deployments, resource configuration, and cluster management. Run the linter on every manifest before review; use this prose guidance to explain findings and propose fixes.
When to use: Every production container deployment.
apiVersion: apps/v1
kind: Deployment
metadata:
name: api-service
spec:
template:
spec:
containers:
- name: api
image: api:v1.2.3
resources:
requests:
memory: "256Mi"
cpu: "250m"
limits:
memory: "512Mi"
cpu: "500m"
Benefits: Predictable scheduling, protection against resource exhaustion, fair resource sharing across pods.
When to use: All production deployments.
containers:
- name: api
livenessProbe:
httpGet:
path: /health
port: 8080
initialDelaySeconds: 30
periodSeconds: 10
failureThreshold: 3
readinessProbe:
httpGet:
path: /ready
port: 8080
initialDelaySeconds: 5
periodSeconds: 5
successThreshold: 1
Benefits: Auto-restart unhealthy pods, traffic only to ready pods, graceful startup handling.
When to use: Production services requiring high availability.
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: api-pdb
spec:
minAvailable: 2
selector:
matchLabels:
app: api
| Aspect | Description |
|---|---|
| WHY | Unlimited resources cause node exhaustion, OOM kills, and unpredictable scheduling. One pod can starve others. |
| DETECTION | Missing resources.limits in container specs. |
| FIX | Always set requests (guaranteed) and limits (maximum). |
| Aspect | Description |
|---|---|
| WHY | Non-reproducible deployments. Rollbacks impossible. Different nodes may pull different versions. |
| DETECTION | Image tags ending in :latest or no tag specified. |
| FIX | Use specific semantic version tags. Pin to exact digest for critical workloads. |
| Aspect | Description |
|---|---|
| WHY | Kubernetes can't detect unhealthy pods. Traffic goes to broken pods. No auto-recovery. |
| DETECTION | Deployments without livenessProbe or readinessProbe. |
| FIX | Add both probes. Liveness for restart, readiness for traffic routing. |
| Aspect | Description |
|---|---|
| WHY | Container escape vulnerabilities are exploitable as root. Violates least privilege. |
| DETECTION | No securityContext or runAsNonRoot: false. Missing runAsUser. |
| FIX | Set runAsNonRoot: true. Specify non-root user. Drop all capabilities. |
| Aspect | Description |
|---|---|
| WHY | No fault tolerance. Pod restart = downtime. No rolling update capability. |
| DETECTION | replicas: 1 in production deployments. No PDB defined. |
| FIX | Minimum 2 replicas for production. Add PodDisruptionBudget. Use anti-affinity. |
kubectl get events shows no warningsRun the linter on every manifest before review. Consume its output only — the script source never enters context.
Input: JSON representation of one or more Kubernetes manifests. YAML must be converted to JSON first (see below).
YAML to JSON conversion:
python3 -c "import sys,json,yaml; print(json.dumps(yaml.safe_load(sys.stdin)))" < deployment.yaml \
| python .claude/skills/devops/kubernetes/scripts/k8s_lint.py -
Or with yq:
yq -o json deployment.yaml | python .claude/skills/devops/kubernetes/scripts/k8s_lint.py -
Run via Bash (file argument — JSON):
python .claude/skills/devops/kubernetes/scripts/k8s_lint.py manifest.json
Run via Bash (stdin — JSON):
cat manifest.json | python .claude/skills/devops/kubernetes/scripts/k8s_lint.py -
Input format — single manifest:
{"apiVersion": "apps/v1", "kind": "Deployment", "metadata": {"name": "api"}, "spec": {...}}
Input format — multiple manifests:
[
{"kind": "Deployment", ...},
{"kind": "Service", ...}
]
Output:
findings array (each finding has id, severity, manifest, container, title, detail, reference) and summary counts.Findings covered:
| ID | Check | Severity | Source |
|---|---|---|---|
| K8S-001 | Missing resource requests | MEDIUM | Kubernetes Resource Management docs |
| K8S-002 | Missing resource limits | HIGH | Kubernetes docs; CIS §5.3 |
| K8S-003 | Missing liveness probe | HIGH | Kubernetes Configure Probes docs |
| K8S-004 | Missing readiness probe | MEDIUM | Kubernetes Configure Probes docs |
| K8S-005 | Image tag :latest or untagged | HIGH | Kubernetes best practices |
| K8S-006 | privileged: true | CRITICAL | CIS Kubernetes Benchmark §5.2.1 |
| K8S-007 | hostNetwork: true | CRITICAL | CIS Kubernetes Benchmark §5.2.4 |
| K8S-008 | No non-root securityContext | HIGH | CIS Kubernetes Benchmark §5.2.6 |
| K8S-009 | Single replica Deployment | MEDIUM | Kubernetes HA best practices |
What to do with the output:
Error handling: The script exits non-zero with an ERROR message to stderr on I/O failure or invalid JSON. The kind field is required in every manifest.
| Task | Pattern |
|---|---|
| Prevent resource exhaustion | Set requests and limits |
| Auto-restart broken pods | Liveness probe |
| Route traffic to ready pods | Readiness probe |
| Reproducible deployments | Specific version tags |
| Secure containers | Non-root, drop capabilities |
| High availability | Multiple replicas + PDB |
| External configuration | ConfigMaps + Secrets |
Source: Everyone-Needs-A-Copilot/claude-copilot — distributed by TomeVault.