报错现象

K8S 1.28.3安装排错:kubeadm join节点时报错——[ERROR FileContent--proc-sys-net-bridge-bridge-nf-call-iptables]_docker

[root@k8s-worker02 ~]# kubeadm join 192.168.20.101:6443 --token rnegrb.uqacnpc8fw95o94h \
> --discovery-token-ca-cert-hash sha256:a719921952410a3cd8f5bef075022a1c28ba3123946005d0a9523691ad1e68b2 \
> --cri-socket unix:///var/run/containerd/containerd.sock
[preflight] Running pre-flight checks
error execution phase preflight: [preflight] Some fatal errors occurred:
	[ERROR FileContent--proc-sys-net-bridge-bridge-nf-call-iptables]: /proc/sys/net/bridge/bridge-nf-call-iptables does not exist
[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
[root@k8s-worker02 ~]# kubeadm join 192.168.20.101:6443 --token rnegrb.uqacnpc8fw95o94h --discovery-token-ca-cert-hash sha256:a719921952410a3cd8f5bef075022a1c28ba3123946005d0a9523691ad1e68b2 
[preflight] Running pre-flight checks
error execution phase preflight: [preflight] Some fatal errors occurred:
	[ERROR FileContent--proc-sys-net-bridge-bridge-nf-call-iptables]: /proc/sys/net/bridge/bridge-nf-call-iptables does not exist
[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

解决办法

K8S 1.28.3安装排错:kubeadm join节点时报错——[ERROR FileContent--proc-sys-net-bridge-bridge-nf-call-iptables]_kubernetes_02

[root@k8s-worker02 ~]# modprobe br_netfilter
[root@k8s-worker02 ~]# kubeadm join 192.168.20.101:6443 --token rnegrb.uqacnpc8fw95o94h --discovery-token-ca-cert-hash sha256:a719921952410a3cd8f5bef075022a1c28ba3123946005d0a9523691ad1e68b2 --cri-socket unix:///var/run/containerd/containerd.sock
[preflight] Running pre-flight checks
[preflight] Reading configuration from the cluster...
[preflight] FYI: You can look at this config file with 'kubectl -n kube-system get cm kubeadm-config -o yaml'
[kubelet-start] Writing kubelet configuration to file "/var/lib/kubelet/config.yaml"
[kubelet-start] Writing kubelet environment file with flags to file "/var/lib/kubelet/kubeadm-flags.env"
[kubelet-start] Starting the kubelet
[kubelet-start] Waiting for the kubelet to perform the TLS Bootstrap...

This node has joined the cluster:
* Certificate signing request was sent to apiserver and a response was received.
* The Kubelet was informed of the new secure connection details.

Run 'kubectl get nodes' on the control-plane to see this node join the cluster.

验证

K8S 1.28.3安装排错:kubeadm join节点时报错——[ERROR FileContent--proc-sys-net-bridge-bridge-nf-call-iptables]_3c_03

详细解释

根据错误信息,出现了一个预检错误。错误消息中提到了缺少 /proc/sys/net/bridge/bridge-nf-call-iptables 文件。

这个错误可以通过在节点上加载 br_netfilter 模块来解决。请按照以下步骤进行操作:

  1. 在节点上以 root 用户或具有 sudo 权限的用户身份登录。
  2. 运行以下命令来加载 br_netfilter 模块:
modprobe br_netfilter
```
  1. 如果您使用的是 CentOS 7 或 RHEL 7,还需要在 /etc/sysctl.conf 文件中启用 net.bridge.bridge-nf-call-iptables 参数。运行以下命令以编辑该文件:
vi /etc/sysctl.conf
```
  1. 在文件中找到 net.bridge.bridge-nf-call-iptables 参数,并确保它的值设置为 1。如果找不到该行,可以在文件的末尾添加以下行:
net.bridge.bridge-nf-call-iptables = 1
```
  1. 保存并关闭文件。在 vi 编辑器中,按下 Esc 键,然后输入 :wq,最后按下 Enter 键。
  2. 运行以下命令以使修改的参数生效:
sysctl -p
```

现在,您可以再次尝试运行 kubeadm join 命令以加入节点到 Kubernetes 集群中。如果仍然遇到其他错误,请提供完整的错误消息,以便我能够更好地帮助您解决问题。