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

Asking for help? Comment out what you need so we can get more information to help you!

Cluster information:

Kubernetes version:
Client Version: version.Info{Major:“1”, Minor:“27”, GitVersion:“v1.27.0”, GitCommit:“1b4df30b3cdfeaba6024e81e559a6cd09a089d65”, GitTreeState:“clean”, BuildDate:“2023-04-11T17:10:18Z”, GoVersion:“go1.20.3”, Compiler:“gc”, Platform:“linux/amd64”}
Kustomize Version: v5.0.1
Server Version: version.Info{Major:“1”, Minor:“27”, GitVersion:“v1.27.0”, GitCommit:“1b4df30b3cdfeaba6024e81e559a6cd09a089d65”, GitTreeState:“clean”, BuildDate:“2023-04-11T17:04:24Z”, GoVersion:“go1.20.3”, Compiler:“gc”, Platform:“linux/amd64”}

Cloud being used: bare-metal
Installation method: kubeadm
Host OS: Ubuntu 22.04
CNI and version:
CRI and version:

Basically, my problem is when i digit this command “kubectl get pods --all-namespaces” some podes listed as " Unable to connect to the server: EOF ". Sometimes, works and when it works some pods are running and others are with this error “CrashLoopBackOff”
I tried to run kubernetes HA with a multimaster nodes.
I have a haproxy with this configuration:
"

frontend kubernetes
bind 10.9.32.88:6443
option tcplog
mode tcp
default_backend kubernetes-master-nodes
backend kubernetes-master-nodes
mode tcp
balance roundrobin
option tcp-check
server kubernetes-master1 10.9.32.80:6443 check fall 3 rise 2
server kubernetes-master2 10.9.32.81:6443 check fall 3 rise 2

"
And i use the command in the master “sudo kubeadm init --control-plane-endpoint 10.9.32.88:6443 --pod-network-cidr 10.244.0.0/16”
Please help me

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