Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

kubernetes lost ~/.kube/config

Unfortunately I lost my local

~/.kube/config

where I had configuration for my namespace.

Is there a way to get this config if I have access to master nodes?

Thanks in advance

like image 286
kpazik Avatar asked Mar 04 '23 11:03

kpazik


1 Answers

I believe you're using kubeadm to start your kubernetes cluster, you can generate the new kubeconfig file using following command:

kubeadm alpha phase kubeconfig admin --kubeconfig-dir /etc/kubernetes --cert-dir /etc/kubernetes/pki

This will generate a new config file in /etc/kubernetes/admin.conf. Then you can copy the file in following way:

mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
like image 51
Prafull Ladha Avatar answered Mar 11 '23 02:03

Prafull Ladha