在 Debian 上部署 Kubernetes(k8s)报错,原因非常多。你可以先贴出具体报错信息,我才能精准帮你定位。
不过,下面先给你一份Debian 部署 k8s 最常见的报错 & 解决清单,你可以对照看。
报错示例
[ERROR Swap]: running with swap on is not supported
解决
sudo swapoff -a
sudo sed -i '/ swap / s/^/#/' /etc/fstab
报错示例
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
报错示例
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
报错示例
Unable to connect to the server: dial tcp 6443
解决
sudo ufw disable
# 或放行端口
sudo ufw allow 6443,10250,2379:2380,10251,10252/tcp
报错示例
hostname "node1" could not be reached
解决
hostnamectl set-hostname node1
echo "127.0.0.1 node1" >> /etc/hosts
常见原因
解决
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
现象
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
请把以下信息贴出来:
cat /etc/os-release)你可以直接把报错粘过来,我帮你一步步排。