k8s常见问题排查

现象/Events 问题类型 重点检查

Insufficient cpu CPU 资源不足 kubectl describe node、kubectl top node

Insufficient memory 内存不足 Node Allocatable、requests

had taint 节点污点 kubectl describe node

didn't match node selector 节点标签/亲和性 kubectl get nodes --show-labels

pod has unbound immediate PersistentVolumeClaims PVC 未绑定 PVC、PV、StorageClass

volume node affinity conflict 存储和节点 zone 冲突 PV Node Affinity

FailedMount 挂载失败 CSI、节点、存储

Too many pods Pod 数量上限 Node pod capacity

network plugin not ready CNI/节点网络问题 kubelet、CNI Pod、Node 网络

ImagePullBackOff 镜像或仓库问题 镜像地址、Secret、网络

六、处理顺序

遇到 Pod Pending 时,建议固定执行:

# 1. 看 Pod 当前状态

kubectl get pod <pod> -n <namespace> -o wide

# 2. 看调度事件

kubectl describe pod <pod> -n <namespace>

# 3. 看最近集群事件

kubectl get events -A --sort-by=.lastTimestamp

# 4. 看节点资源和状态

kubectl get nodes

kubectl describe node <node>

kubectl top node

# 5. 看 PVC

kubectl get pvc -n <namespace>

kubectl describe pvc <pvc> -n <namespace>

# 6. 看存储插件

kubectl get pod -A | grep -Ei 'csi|storage'

然后根据事件分类:

Insufficient cpu/memory

    → 资源问题

taint/selector/affinity

    → 调度约束问题

PVC Pending / unbound

    → 存储供应问题

FailedMount

    → 存储挂载或 CSI 问题

network plugin not ready

    → CNI/节点网络问题

最后总结

判断一个 Pending Pod,不能只看 kubectl get pod,必须看:

kubectl describe pod <pod> -n <namespace>

其中 Events 通常已经给出第一层原因。

最重要的区分方式是:

调度问题:

    Pod 还没有被分配到 Node。

资源问题:

    找不到满足 CPU、内存、Pod数量等条件的 Node。

存储问题:

    PVC 没有绑定,或卷无法挂载。

网络问题:

    Node 或 CNI 没有准备好,或者 Service/Endpoint 不通。

实际处理时优先保留事件和状态证据,再修改 requests、标签、taint、PVC 或节点配置,避免为了让 Pod 快速 Running 而绕过原本的资源隔离和存储约束。

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容