Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to have multiple kubernetes config and change quicky between them

I am working with multiple Kubernetes clusters at Azure, so I need to change quickly from one cluster to another without having various files at my path C:\Users\username\.kube, because I have to rename or replace the file when I wish to change to other.

like image 466
kelgwiin Avatar asked Apr 03 '19 19:04

kelgwiin


People also ask

How do I switch between two Kubernetes clusters?

After your clusters, users, and contexts are defined in one or more configuration files, you can quickly switch between clusters by using the kubectl config use-context command. Note: A file that is used to configure access to a cluster is sometimes called a kubeconfig file.

Can Kubernetes manage multiple clusters?

Scaling and bursting of applications: Multi-cluster Kubernetes enables you to provide the ability to scale beyond the limitations of a single cluster by moving parts of your application to additional clusters.


Video Answer


1 Answers

I suggest that you use the following tools and tricks:

  • Use asdf to manage multiple kubectl versions
  • Set the KUBECONFIG env var to change between multiple kubeconfig files
  • Use kube-ps1 to keep track of your current context/namespace
  • Use kubectx and kubens to change fast between clusters/namespaces
  • Use aliases to combine them all together

Take a look at this article, it explains how to accomplish this: Using different kubectl versions with multiple Kubernetes clusters

I also recommend this read: Mastering the KUBECONFIG file

like image 52
Eduardo Baitello Avatar answered Sep 30 '22 04:09

Eduardo Baitello