Unable to connect to the server: EOF (error during kubectl command)

Hi, I’ve just had the same problem and after a lot of google, I realized the followings :

  1. Docker cgroup driver Config :

$ cat <<EOF | sudo tee /etc/docker/daemon.json
{
“exec-opts”: [“native.cgroupdriver=systemd”]
}

$ sudo systemctl daemon-reload
$ sudo systemctl restart docker
$ sudo systemctl restart kubelet

  1. Disabling Swap :

sudo swapoff -a (Note : at every servers restart)

sudo vi /etc/fstab
→ then comment out the swap line UUID
OR use the following command without editing the file
sudo sed -i ‘/ swap / s/^/#/’ /etc/fstab

  1. Sysctl Config :

cat <<EOF | sudo tee /etc/modules-load.d/k8s.conf
br_netfilter
EOF

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

sudo sysctl --system