recover-kubectl-config-running-kubernetes-on-ubuntu

We already covered the installation and configuration of the Ubuntu integrated Kubernetes deployment with conjure-up and juju. But there can be quite some trouble if you delete or lose your kubectl config file to access the Kubernetes cluster.

Luckily there is an extremely simple way to get that solved and to recover kubectl config.

Just imaging you play around with different Kubernetes environments and suddenly you want to clean up all the testing. rm -rf .kube or rm .kube/* and all clean.

Unfortunately you also delete your access to the running Kubernetes cluster you always work with.

You’re going to notice that pretty quick as a kubectl get all returns an error.

Something like:

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

Alright, now how to recover the configuration?

When you run juju status, you’re going to see a Kubernetes master, typically kubernetes-master/0. And in the user directory on the kubernetes-master system is a kubectl config as well. So we just need to copy it to our local system. Either ssh into the kubernetes-master/0, juju ssh kubernetes-master/0 and copy the content of the config file into your local homedirectory .kube/config or use juju scp.

juju scp kubernetes-master/0:config ~/.kube/

That’s it and kubectl get all should work as usual again.

RELATED ARTICLES

Save energy without reducing VM performance in your VMware vSphere cluster
16 August 2022
Over the last couple of decades energy consumption went up massively in every data center and while the…
Dennis
Metrics & Logs support for IoT - Bringing Secure Monitoring and Logging to the Edge
7 July 2022
Simple uptime monitoring for Internet-of-Things (IoT) is well-known and requires knowing if the devices are up and running.…
Dennis
Monitoring Azure SQL Managed Instance with Opvizor Metrics & Logs
17 January 2022
When you have critical applications and business processes that rely on Azure resources, it's critical to keep an…
Dennis

White Paper — Registration

You will receive the research paper by mail.

Codenotary — Webinar

White Paper — Registration

Please let us know where we can send the whitepaper on Codenotary Trusted Software Supply Chain. 

Become a partner

Start Your Trial

Please enter contact information to receive an email with the virtual appliance download instructions.

Start Free Trial

Please enter contact information to receive an email with the free trial details.

Subscribe to our newsletter