Lab 3: Multi Master K3s kubeconfig files for smooth accessibility

Scenario:

We have multiple master nodes and we want to ensure that our operation using kubectl in our local machine is smooth and uninterrupted.

First, create the necessary kubeconfig files and add the configuration data into it like the following:

Then we modify our shell profile. Depending on your setup, as for me, I'm using zsh as my shell. Therefore, I will modify the .zshrc file as below:

#My Onprem K8s master nodes
export CONFIG_K3S_MASTER_NODE01=$HOME/.kube/k3s-master-node01
export CONFIG_K3S_MASTER_NODE02=$HOME/.kube/k3s-master-node02
export CONFIG_K3S_MASTER_NODE03=$HOME/.kube/k3s-master-node03

#Merge all the configs
export KUBECONFIG=$CONFIG_K3S_MASTER_NODE01:$CONFIG_K3S_MASTER_NODE02:$CONFIG_K3S_MASTER_NODE03:$CONFIG_MINIKUBE

Finally, you may get the results just like below:

Last updated