After reboot of kubernetes master node, "kubectl" command throwing this error:
Unable to connect to the server: Service Unavailable
Kindly suggest how to start the service or fix this issue.
# kubectl get nodes
Unable to connect to the server: Service Unavailable
#
# kubectl cluster-info
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
Unable to connect to the server: Service Unavailable
#
# echo $KUBECONFIG
/root/.kube/config
#
# kubectl config view
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: DATA+OMITTED
server: https://192.168.1.1:6443
name: kubernetes
contexts:
- context:
cluster: kubernetes
user: kubernetes-admin
name: kubernetes-admin@kubernetes
current-context: kubernetes-admin@kubernetes
kind: Config
preferences: {}
users:
- name: kubernetes-admin
user:
client-certificate-data: REDACTED
client-key-data: REDACTED
#
You did not specify which container driver your cluster is using, so I'm going to assume it is docker
, also assuming you are using linux.
Most probably you don't have kube-apiserver
running. You have to start/restart it to solve your issue.
$ systemctl status docker
# systemctl start docker
or
# systemctl restart docker
kube-apiserver
container is running
# docker ps -a
look for a container with COMMAND kube-apiserver
. If it's running you are done, if not, restart it
# docker restart <container ID>
To ensure you won't have the same problem in the future, configure Docker to start on boot
# systemctl enable docker.service
# systemctl enable containerd.service
If your distribution does not user systemd
use service
instead of systemctl
# service <service name> status/stop/start/restart
In above commands $
means run as normal user, #
means run as root.