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.

CNIL
Metrics and Logs

(formerly, Opvizor Performance Analyzer)

VMware vSphere & Cloud
PERFORMANCE MONITORING, LOG ANALYSIS, LICENSE COMPLIANCE!

Monitor and Analyze Performance and Log files:
Performance monitoring for your systems and applications with log analysis (tamperproof using immudb) and license compliance (RedHat, Oracle, SAP and more) in one virtual appliance!

Subscribe to Our Newsletter

Get the latest product updates, company news, and special offers delivered right to your inbox.
Share on twitter
Share on linkedin
Share on facebook
Share on email

Subscribe to our newsletter

White Paper — Registration

We will send you the research paper via email.

CodeNotary — Webinar

White Paper — Registration

Please let us know who you are, so we can send you the CodeNotary Trusted Software Supply Chain white paper.

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.