环境:
centos7.6 ;
kubeadm安装k8s集群(版本v1.26.0);
容器引擎对应cri-dockerd-0.3.1-3.el7.x86_64.rpm(这里其实还发生一件事,装k8s 1.25的时候,容器引擎太低,导致无法识别,于是换了个新版本的)
报错一:FileContent--proc-sys-net-ipv4-ip_forward]: /proc/sys/net/ipv4/ip_forward contents are not set to 1
1、报错详情
root@k8s-node1[19:15:39]:~ $ kubeadm join 10.1.1.71:6443 --token o439xs.un9q83tqtcpu8d0t \ > --discovery-token-ca-cert-hash sha256:97db974222df80559c0b03940c51bda582afbf9bcaca1ddb4319f97d1024acc8 --cri-socket=unix:///var/run/cri-dockerd.sock [preflight] Running pre-flight checks error execution phase preflight: [preflight] Some fatal errors occurred: [ERROR FileContent--proc-sys-net-ipv4-ip_forward]: /proc/sys/net/ipv4/ip_forward contents are not set to 1 [preflight] If you know what you are doing, you can make a check non-fatal with `--ignore-preflight-errors=...` To see the stack trace of this error execute with --v=5 or higher
2、报错解决
这个错误提示显示了一个预检错误,指出 /proc/sys/net/ipv4/ip_forward 的内容未设置为 1。在 Kubernetes 的预安装检查中,这是一个必要的设置,它允许数据包在节点之间进行转发。
要解决这个问题,需要设置 /proc/sys/net/ipv4/ip_forward 的值为 1。
编辑 /etc/sysctl.conf 文件并确保以下行存在:
net.ipv4.ip_forward = 1
保存并退出文件,然后运行以下命令使更改生效:
sysctl -p
报错二:/etc/kubernetes/kubelet.conf already exists
报错详情:
root@k8s-node1[19:21:45]:~ $ kubeadm join 10.1.1.71:6443 --token o439xs.un9q83tqtcpu8d0t --discovery-token-ca-cert-hash sha256:97db974222df80559c0b03940c51bda582afbf9bcaca1ddb4319f97d1024acc8 --cri-socket=unix:///var/run/cri-dockerd.sock [preflight] Running pre-flight checks error execution phase preflight: [preflight] Some fatal errors occurred: [ERROR FileAvailable--etc-kubernetes-kubelet.conf]: /etc/kubernetes/kubelet.conf already exists [ERROR Port-10250]: Port 10250 is in use [ERROR FileAvailable--etc-kubernetes-pki-ca.crt]: /etc/kubernetes/pki/ca.crt already exists [preflight] If you know what you are doing, you can make a check non-fatal with `--ignore-preflight-errors=...` To see the stack trace of this error execute with --v=5 or higher
解决办法:
解决方法:运行kubeadm reset重置子节点,之后直接对子节点使用
kubeadm join 10.1.1.71:6443 --token o439xs.un9q83tqtcpu8d0t --discovery-token-ca-cert-hash sha256:97db974222df80559c0b03940c51bda582afbf9bcaca1ddb4319f97d1024acc8 --cri-socket=unix:///var/run/cri-dockerd.sock
将其加入对应的父节点中。