K8s Node Pressure Full-Chain Diagnostics

SkillDocs & knowledge

K8s node resource pressure troubleshooting. Full-chain diagnosis of CPU/Memory/Disk/PID Pressure: kubectl top → describe node → conditions → eviction events → scheduling analysis, with structured reports and mitigation recommendations.

Available today. Use it from your connected AI after setup.

Connect ahel once, and every AI you use reads what you have installed.

Then ask your AI: use the K8s Node Pressure Full-Chain Diagnostics skill

What this skill tells your AI

The instructions your AI receives, as published by seed-forge/harness-ai-kit in skills/diag-k8s-node-pressure/SKILL.md and read by ahel’s review.

用途

当节点出现 NotReady、Pod 被驱逐、或监控报节点资源告警时触发。

输入

  • kubectl 上下文、目标节点名称(可选,默认排查所有)

输出

  • 节点资源压力报告 + 缓解建议

诊断步骤

Step 1: 节点状态总览

kubectl get nodes -o wide
kubectl describe node {node_name}
# 关注 Conditions: MemoryPressure / DiskPressure / PIDPressure / Ready

Step 2: 资源用量

kubectl top nodes
kubectl top pods --all-namespaces --sort-by=memory | head -20
kubectl top pods --all-namespaces --sort-by=cpu | head -20

Step 3: 驱逐事件

# 最近被驱逐的 Pod
kubectl get events --all-namespaces --field-selector reason=Evicted --sort-by='.lastTimestamp' | tail -20

# 节点上的驱逐历史
kubectl get events --field-selector involvedObject.name={node_name} | grep -i evict

Step 4: Allocatable vs Allocated

kubectl describe node {node_name} | grep -A 20 "Allocated resources"
# 关注 CPU/ memory requests 占 Allocatable 的百分比

Step 5: 系统级排查

# 在目标节点上(SSH 或通过 kubectl debug)
df -h                          # 磁盘使用
free -h                        # 内存使用
ps aux --sort=-%mem | head -10 # 高内存进程
dmesg | grep -i oom            # OOM killer
journalctl -u kubelet --since "1 hour ago" | tail -50

输出模板

K8s Node Pressure Analysis Report
════════════════════════════════════════
Cluster: {context}
Node:    {node_name}
Time:    {timestamp}

Node Conditions
  Ready:            {ready}
  MemoryPressure:   {mem_pressure}
  DiskPressure:     {disk_pressure}
  PIDPressure:      {pid_pressure}

Resource Usage
  CPU:     {cpu_used}/{cpu_allocatable} ({cpu_pct}%)
  Memory:  {mem_used}/{mem_allocatable} ({mem_pct}%)
  Disk:    {disk_used}/{disk_total} ({disk_pct}%)
  Pods:    {pod_count}/{pod_max}

Top Consumers (by memory)
  | Pod | Namespace | Memory | CPU |
  |-----|-----------|--------|-----|
  | {pod_1} | {ns_1} | {mem_1} | {cpu_1} |

Evicted Pods (last 10)
  {evicted_pod_1} at {time_1}: {reason_1}

Allocated Resources
  CPU Requests:    {cpu_req_pct}% of allocatable
  Memory Requests: {mem_req_pct}% of allocatable

Root Cause: {root_cause}

Recommendations
  1. {immediate_action}
  2. {scaling_action}
  3. {long_term_fix}

告警阈值

指标WarningCritical
CPU usage> 80%> 95%
Memory usage> 80%> 95%
Disk usage> 85%> 95%
Evictions/hour> 3> 10
Node NotReady-任一

推荐输出格式

执行完毕后输出诊断报告:

结论:<正常 / 发现问题>

排查环节发现证据
...{...}{...}

根因:<定位> 修复建议:<可执行步骤>

约束

  • 只读诊断。节点级操作(cordon/drain/reboot)需明确告知用户。
  • SSH 到节点属于受控操作,优先通过 kubectl debug node/ 替代。

Quick Reference

动作命令
节点状态kubectl get nodes -o wide
节点详情kubectl describe node {name}
资源用量kubectl top nodes
Top Podkubectl top pods -A --sort-by=memory
驱逐事件kubectl get events --field-selector reason=Evicted

专题引用

无外部 references。如需节点运维,联动 组织内部集群-ansible-controlinfra-observability-ops

Signals

GitHub stars
22
Forks
2
Last commit
Aug 2026
Advanced
Catalog kind
skill
Gateway key
diag-k8s-node-pressure
Source
github.com/seed-forge/harness-ai-kit