#Kubernetes Cluster Initialization iptables error #K8s
The primary step to configure container runtimes is setting up system prerequisites.
For this, it usually needs loading of overlay and br_netfilter modules and then modifying kernel settings with below.
# Setup required sysctl params, these persist across reboots.
cat <<EOF | sudo tee /etc/sysctl.d/99-kubernetes-cri.conf
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1
net.bridge.bridge-nf-call-ip6tables = 1
EOF# Apply sysctl params without reboot
sudo sysctl --systemStill, there may be an error as shown below appear in the time of cluster initialisztion using kubeadm init
[init] Using Kubernetes version: v1.22.0[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
This causes when be_netfilter module not detected and if some necessary network configurations are missing. This can be fixed.
Solution :
- Load the br_netfilter module again, use sudo if non-root user
modprobe br_netfilter
- set bridge iptables rules and ip_forward rule to 1. This is default setting on new linux kernels but CentOs and RHEL doesnt have this setting by default.
echo 1 > /proc/sys/net/bridge/bridge-nf-call-iptables
echo 1 > /proc/sys/net/ipv4/ip_forward
- Apply the settings using sysctl -p
- Now Run kubeadm reset before init, this will not clean CNI configuration, IPtables/IPVS tables or kubeconfig files
After this control-plane (or) master node can initialize the cluster and join worker nodes to cluster. Repeat the steps in worker nodes if the error appears while joining i.e., kubeadm join
Comments
Post a Comment
feel free to give feedback