After reboot Centos7 server , when run kubectl get pod get error: the connection to the server localhost:8080 was refused

2/22/2020

What happened: when I reboot the centos7 server and run get pod, see below error:

The connection to the server localhost:8080 was refused - did you specify the right host or port? What you expected to happen:

before I reboot the system, the Kubernetes have three nodes, and pods/service/,.. all working fine. How to reproduce it (as minimally and precisely as possible):

  • reboot the server
  • kubectl get pod

Anything else we need to know?

I even used sudo kubeadm reset and init again but the issue still exists!

-- cool_rz
centos
centos7
kubernetes

1 Answer

2/26/2020

There are few things to consider:

  1. kubeadm reset performs a best effort revert of changes made by kubeadm init or kubeadm join. So some configurations may stay on the cluster.

  2. Make sure you run kubectl as a proper user. You might need to copy the admin.conf to .kube/config dir of the user's home directory.

  3. After kubeadm init you need to run the following commands:

sudo cp /etc/kubernetes/admin.conf $HOME/ sudo chown $(id -u):$(id -g) $HOME/admin.conf export KUBECONFIG=$HOME/admin.conf

Make sure you do so.

  1. Check Centos' firewall configuration. After the restart it might go back to defaults.

Please let me know if that helped.

-- OhHiMark
Source: StackOverflow