When I run any kubectl commands, I'm getting
The connection to the server localhost:8080 was refused - did you specify the right host or port?
When I run any kubectl commands, I'm getting
The connection to the server localhost:8080 was refused - did you specify the right host or port?
This problem is likely caused by a bad ~/.kube/config perhaps you have a file from a different kubernetes install (minikube) or an older k3s. If the server is local you can fix this by running these commands,
mkdir ~/.kube
sudo k3s kubectl config view --raw | tee ~/.kube/config
chmod 600 ~/.kube/config
The contents of ~/.kube/config need to have the same information as /etc/rancher/k3s/k3s.yaml when the server was started (the keys, ip, and ports).
Note in order to tell k3s to use this config file you'll want to configure KUBECONFIG.
export KUBECONFIG=~/.kube/config
You should persist this by having it set in ~/.profile or ~/.bashrc