Error using kubectl (The connection to the server localhost:8080 was refused – did you specify the right host or port?)

Quote from moshe on 15/10/2020, 11:03 pmUser getting the following error while trying to run kubectl commands
kubectl -n kube-system get pods
Error using kubectl (The connection to the server localhost:8080 was refused – did you specify the right host or port?)
The connection to the server localhost:8080 was refused – did you specify the right host or port?
Resolution
The kubernets config file is missing in your home directory. To fix the problem, run these commandssudo cp /etc/kubernetes/admin.conf ~/.kube/config
sudo chmod 755 ~/.kube/config
sudo chown <your_user_name> ~/.kube/config
sudo chhgrp <your_user_group> ~/.kube/config
User getting the following error while trying to run kubectl commands
kubectl -n kube-system get pods
Error using kubectl (The connection to the server localhost:8080 was refused – did you specify the right host or port?)
The connection to the server localhost:8080 was refused – did you specify the right host or port?
Resolution
The kubernets config file is missing in your home directory. To fix the problem, run these commandssudo cp /etc/kubernetes/admin.conf ~/.kube/config
sudo chmod 755 ~/.kube/config
sudo chown <your_user_name> ~/.kube/config
sudo chhgrp <your_user_group> ~/.kube/config