Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deleted ~/.kube/config

I accidentally deleted the config file from ~/.kube/config. Every kubectl command fails due to config missing.

Example:

kubectl get nodes

The connection to the server localhost:8080 was refused - did you specify the right host or port?

I have already install k3s using:

export K3S_KUBECONFIG_MODE="644"
curl -sfL https://get.k3s.io | sh -s - --docker

and kubectl using:

snap install kubectl --classic

Does anyone know how to fix this?

like image 448
e7lT2P Avatar asked Jan 19 '26 22:01

e7lT2P


1 Answers

The master copy is available at /etc/rancher/k3s/k3s.yaml. So, copy it back to ~/.kube/config

cp /etc/rancher/k3s/k3s.yaml ~/.kube/config

Reference: https://rancher.com/docs/k3s/latest/en/cluster-access/

like image 72
Rakesh Gupta Avatar answered Jan 21 '26 10:01

Rakesh Gupta