New User Failed Run Kubectl with Error “The connection to the server xxx.xxx.xxx was refused – did you specify the right host or port?”

The Problem

When run kubectl from a new created user, failed with error:

The connection to the server xxx.xxx.xxx was refused - did you specify the right host or port?

The Solution

A newly created user has no KUBECONFIG configured. Setup kubernetes configuration for the new user:

# mkdir -p $HOME/.kube
# sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
# sudo chown $(id -u):$(id -g) $HOME/.kube/config
Related Post