温馨提示×

debian k8s部署报错怎么破

小樊
43
2026-09-26 12:03:28
栏目: 智能运维

在 Debian 上部署 Kubernetes(k8s)报错,原因非常多。你可以先贴出具体报错信息,我才能精准帮你定位。

不过,下面先给你一份Debian 部署 k8s 最常见的报错 & 解决清单,你可以对照看。


一、系统环境类(最常见)

1️⃣ swap 未关闭

报错示例

[ERROR Swap]: running with swap on is not supported

解决

sudo swapoff -a
sudo sed -i '/ swap / s/^/#/' /etc/fstab

2️⃣ 内核参数 / 模块问题

报错示例

modprobe: FATAL: Module br_netfilter not found

解决

sudo modprobe br_netfilter
echo 'br_netfilter' | sudo tee /etc/modules-load.d/br_netfilter.conf

cat <<EOF | sudo tee /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-iptables = 1
net.bridge.bridge-nf-call-ip6tables = 1
net.ipv4.ip_forward = 1
EOF

sudo sysctl --system

3️⃣ cgroup 驱动不一致(containerd / docker)

报错示例

failed to create kubelet: misconfiguration: kubelet cgroup driver: "systemd" is different from docker "cgroupfs"

解决(containerd 推荐)

sudo mkdir -p /etc/containerd
containerd config default | sudo tee /etc/containerd/config.toml

# 修改
SystemdCgroup = true

sudo systemctl restart containerd

二、网络类

4️⃣ 防火墙 / 端口未开

报错示例

Unable to connect to the server: dial tcp 6443

解决

sudo ufw disable
# 或放行端口
sudo ufw allow 6443,10250,2379:2380,10251,10252/tcp

5️⃣ 网卡 / 主机名问题

报错示例

hostname "node1" could not be reached

解决

hostnamectl set-hostname node1
echo "127.0.0.1 node1" >> /etc/hosts

三、kubeadm 初始化类

6️⃣ kubeadm init 失败

常见原因

  • 时间不同步
  • 镜像拉不到(国内尤甚)

解决

sudo apt install -y chrony
sudo systemctl enable --now chrony

国内初始化示例:

kubeadm init \
  --image-repository registry.aliyuncs.com/google_containers \
  --pod-network-cidr=10.244.0.0/16

7️⃣ 网络插件没装

现象

kubectl get nodes
STATUS: NotReady

解决(Flannel 示例)

kubectl apply -f https://raw.githubusercontent.com/flannel-io/flannel/master/Documentation/kube-flannel.yml

四、快速自检命令

kubectl get nodes
kubectl get pods -A
journalctl -u kubelet -xe
sudo systemctl status containerd

五、建议你这样发报错给我(更快解决)

请把以下信息贴出来:

  1. Debian 版本(cat /etc/os-release)
  2. k8s 版本
  3. 容器运行时(docker / containerd)
  4. 完整报错日志(关键信息即可)
  5. 到哪一步报错(init / join / 起 pod)

你可以直接把报错粘过来,我帮你一步步排。

0 踩