Rate This Document
Findability
Accuracy
Completeness
Readability

"The connection to the server localhost" Displayed When Executing kubectl get nodes

Symptom

When the kubectl get nodes command is executed, the message "The connection to the server localhost:8080 was refused" is displayed.

Key Process and Cause Analysis

The execution permission is insufficient because the permission on the config file of kubectl is not properly assigned.

Conclusion and Solution

  1. Run the following commands in sequence to re-assign proper permission:
    cp /etc/kubernetes/admin.conf $HOME/
    chown $(id -u):$(id -g) $HOME/admin.conf
  1. Update the environment variables.
    export KUBECONFIG=$HOME/admin.conf
  2. Run the kubectl get nodes command again to check the node.
    kubectl get nodes