在 Debian 上部署 Kubernetes(k8s) 时,报错的原因很多,需要先定位阶段和具体错误信息。下面我按「常见阶段 + 典型报错 + 解决方案」给你一个排查速查表,你可以对照使用;如果还不行,把完整报错贴出来,我可以精准帮你分析。
cat /etc/os-release
✅ 推荐:
uname -r
lsmod | grep br_netfilter
如果没有:
modprobe br_netfilter
modprobe overlay
并写入开机加载:
cat <<EOF | sudo tee /etc/modules-load.d/k8s.conf
br_netfilter
overlay
EOF
swapoff -a
sed -i '/swap/d' /etc/fstab
否则 kubeadm init 必报错。
Debian 默认无 SELinux,但注意:
iptables -F
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
或:
systemctl disable --now ufw
failed to create containerd
systemctl status containerd
journalctl -u containerd -xe
常见原因
mkdir -p /etc/containerd
containerd config default > /etc/containerd/config.toml
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc.options]
SystemdCgroup = true
然后:
systemctl restart containerd
Port 10250 is in use
✅ 解决:
ss -lntp | grep 10250
kill -9 <pid>
cgroup driver mismatch
✅ 解决(kubelet + containerd 一致):
cat <<EOF > /etc/systemd/system/kubelet.service.d/20-extra-args.conf
[Service]
ExecStart=
ExecStart=/usr/bin/kubelet --cgroup-driver=systemd
EOF
systemctl daemon-reload
systemctl restart kubelet
failed to pull image
✅ 方案 1(国内):
kubeadm init --image-repository registry.aliyuncs.com/google_containers
✅ 方案 2:手动拉镜像
crictl pull registry.aliyuncs.com/google_containers/pause:3.9
The connection to the server localhost:8080 was refused
✅ 解决:
mkdir -p $HOME/.kube
cp /etc/kubernetes/admin.conf $HOME/.kube/config
chown $(id -u):$(id -g) $HOME/.kube/config
kubectl get nodes
kubectl describe node
journalctl -u kubelet
✅ 常见原因:
kubectl apply -f https://docs.projectcalico.org/manifests/calico.yaml
kubectl apply -f https://github.com/flannel-io/flannel/releases/latest/download/kube-flannel.yml
✅ swapoff -a
✅ systemd 时间同步
✅ containerd 正常运行
✅ 内核模块加载
✅ 防火墙放行
✅ cgroup 驱动一致
✅ 网络插件已安装
请你直接贴出以下信息之一:
例如:
Debian 12
kubeadm init 报错:
[ERROR Port-10250]: Port 10250 is in use
我可以一步一步带你修 ✅