Kubernetes specialist

From seaworld008/Commonly-used-high-value-skills · View interactive version

Kubernetes specialist is an AI agent skill from the GitHub repository seaworld008/Commonly-used-high-value-skills. Use when managing Kubernetes clusters, debugging Pods and workloads, designing Helm charts, reviewing manifests, or improving deployment, scaling, and observability practices.

How to use this skill

Skill file

Kubernetes Specialist

触发条件

核心能力

1. 资源管理 (Resource Management)

2. Pod 故障排查流程

3. Helm Chart 最佳实践

4. 自动扩缩容 (HPA/VPA)

5. 安全与 RBAC

常用命令/模板

故障排查组合拳

# 仅列出 phase 非 Running 的 Pod,其中也包括已成功结束的任务
kubectl get pods -A --field-selector='status.phase!=Running'
# 同时检查 Running 中未就绪或反复重启的容器,再查事件和上一实例日志
kubectl get pods -A -o 'custom-columns=NS:.metadata.namespace,NAME:.metadata.name,READY:.status.containerStatuses[*].ready,WAITING:.status.containerStatuses[*].state.waiting.reason,RESTARTS:.status.containerStatuses[*].restartCount'

# 追踪实时日志并显示时间戳
kubectl logs -f <pod-name> --timestamps

# 查看资源占用排行
kubectl top nodes
kubectl top pods

# 导出资源定义的干净版本(去除 runtime 信息)
kubectl get deployment <name> -o yaml | kubectl-neat > deployment.yaml

Deployment 模板 (Best Practice)

apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-app
spec:
  replicas: 3
  selector:
    matchLabels:
      app: my-app
  template:
    metadata:
      labels:
        app: my-app
    spec:
      containers:
      - name: main
        image: my-app:v1.2.3
        resources:
          requests:
            cpu: "100m"
            memory: "128Mi"
          limits:
            cpu: "500m"
            memory: "512Mi"
        livenessProbe:
          httpGet:
            path: /healthz
            port: 8080
          initialDelaySeconds: 15
          periodSeconds: 20
        readinessProbe:
          httpGet:
            path: /readyz
            port: 8080

HPA 配置示例

apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
  name: my-app-hpa
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: my-app
  minReplicas: 2
  maxReplicas: 10
  metrics:
  - type: Resource
    resource:
      name: cpu
      target:
        type: Utilization
        averageUtilization: 70

边界与限制

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.