在 CentOS 上排查 Kubernetes(k8s)问题,通常遵循**“从整体到节点,从节点到 Pod,从 Pod 到容器”的排查思路。下面给你一套实用、可操作的排查流程**。
kubectl get nodes
kubectl get nodes -o wide
常见异常:
NotReady:节点 kubelet 或网络异常SchedulingDisabled:被 cordonkubectl get cs
新版本 k8s 可能已废弃,可忽略
ssh node-ip
systemctl status kubelet
journalctl -u kubelet -f
常见问题:
CentOS 常见:
# Docker
systemctl status docker
journalctl -u docker -f
# containerd
systemctl status containerd
ctr containers list
top
free -h
df -h
重点看:
systemctl status firewalld
getenforce
常见坑:
kubectl get pods -A
kubectl get pods -n <namespace>
状态含义:
Pending:调度问题CrashLoopBackOff:容器反复崩溃ImagePullBackOff:镜像拉取失败Terminating:删除卡住kubectl describe pod <pod> -n <ns>
重点看:
kubectl logs <pod> -n <ns>
kubectl logs <pod> -c <container> -n <ns>
kubectl logs <pod> --previous
常见:
kubectl get pods -n kube-system
ip a
ip route
ping <pod-ip>
firewall-cmd --list-all
k8s 常用端口:
kubectl describe pod <pod>
看:
kubectl get events --sort-by=.metadata.creationTimestamp
kubectl describe node <node>
kubectl exec -it <pod> -- sh
kubectl drain <node> --ignore-daemonsets
kubectl get componentstatuses
kubectl get nodeskubectl get pods -Akubectl describe podkubectl logskubelet / docker / 系统资源如果你愿意,可以告诉我:
我可以帮你精准定位某一类问题(比如 NotReady、网络不通、Pod 起不来)。