> For the complete documentation index, see [llms.txt](https://learn.farizizwan.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://learn.farizizwan.com/devops-and-devsecops/kubernetes/poc-lab/high-availability-portable-mini-kubernetes-data-center-with-k3s/lab-3-multi-master-k3s-kubeconfig-files-for-smooth-accessibility.md).

# 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:

<figure><img src="https://4081356430-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfpkGw9BiJgzxmKhSpJNH%2Fuploads%2FlvSDCbIsxn67ViPnjn3C%2FScreenshot%202023-10-09%20at%2012.11.10%20AM.png?alt=media&amp;token=b67df1b2-1d03-4a31-850f-1a4577e948ae" alt=""><figcaption><p>k3s-master-node0* is the file that contains the configuration data required to access the Kubernetes clusters</p></figcaption></figure>

Then we modify our shell profile. Depending on your setup, as for me, I'm using [zsh](https://ohmyz.sh/) as my shell. Therefore, I will modify the `.zshrc` file as below:

<pre class="language-bash"><code class="lang-bash"><strong>#My Onprem K8s master nodes
</strong><strong>export CONFIG_K3S_MASTER_NODE01=$HOME/.kube/k3s-master-node01
</strong>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
</code></pre>

Finally, you may get the results just like below:

<figure><img src="https://4081356430-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfpkGw9BiJgzxmKhSpJNH%2Fuploads%2FIk2EqIhvI1U4rpdbcOkY%2FScreenshot%202023-10-09%20at%2012.23.34%20AM.png?alt=media&amp;token=b83ce8b1-6358-478c-9509-87fd297f1f65" alt=""><figcaption><p>Notice there were multiple context displayed for my master nodes</p></figcaption></figure>
