Cloud Malaya Lab
  • Home Cloud Lab
    • Architecture
    • DNS Server
  • DevOps & DevSecOps
    • Kubernetes
      • Fundamental
        • Taints in Kubernetes
        • Kubernetes Observability (Monitoring) Guide
        • DNS in Kubernetes (CoreDNS)
        • Storage in Kubernetes
          • Container Storage Interface - CSI
          • Ephemeral Storage Explain
        • Cluster CPU & Memory Inspections
        • Open Source and Free Storage Solution Kubernetes
      • PoC Lab
        • Configure Access to Multiple Cluster using KUBE_CONFIG
        • High Availability Portable Mini Kubernetes Data Center with K3s
          • Lab 1: Build the K3s Infrastructure
          • Lab 2: Automate the K3s clusters deployment with Ansible
          • Lab 3: Multi Master K3s kubeconfig files for smooth accessibility
          • Lab 4: Network Configurations & Tools
        • AWX/Ansible Tower Deployment on Kubernetes
          • Lab 1 - Understanding Requirements
          • Lab 2 - AWX,AWX Operator Configurations & Deployments
          • Lab 3 - Ingress Networking & Connectivity via Nginx
          • Lab 4: AWX Web Console & accessibility on LAN
        • Troubleshooting: Ansible Tower - Reset admin password
    • Monitoring & Observability
      • Splunk
        • Splunk Deployment for SME (Malay Version)
    • System Administration - Linux
      • RedHat Derivatives
        • Add User to Sudoers
        • Yum Update vs Yum Upgrade
        • DNF update vs upgrade
        • SMP PREEMPT_DYNAMIC Definitions
      • Virtualization
        • KVM
      • Storage
  • Digital Infrastructure & Cloud Solutions
    • Solution & System Design
      • Public Cloud
        • Fundamental
          • AWS
          • Azure
          • GCP
        • Lab
          • Simple CD menggunakan Github Action
      • Private Cloud & On-Premise
      • On-Premise to Cloud Design
        • AWS Direct Connect
      • High Availability & Fault Tolerance Design
      • Disaster Recovery
Powered by GitBook
On this page
  1. DevOps & DevSecOps
  2. Kubernetes
  3. PoC Lab

Configure Access to Multiple Cluster using KUBE_CONFIG

Simple way on making access to multiple k8s cluster

Scenario

We have multiple K8s cluster:

  1. A cluster in an on-premise environment (Microk8S)

  2. A cluster on the Cloud environment (AWS)

  3. A cluster on the Cloud environment (Digital Ocean)

You may create multiple config files under the ~/.kube/ directory.

Example:

┌─[admin@my-dev-svr] - [~/.kube] - [Mon May 22, 21:50]
└─[$]> tree
.
├── aws-cluster-01
├── do-k8s-01-kubeconfig
└── [email protected]

0 directories, 3 files
┌─[admin@my-dev-svr] - [~/.kube] - [Mon May 22, 21:50]
└─[$]>

As you can see on the example above, aws-cluster-01 is the config files for cluster that hosted on AWS, do-k8s-01-kubeconfig is for the cluster access on the Digital Ocean, while the last one [email protected] is MicroK8s cluster that reside on the on-premise environment.

Then, you have to modify .bash_profile or .zshrc to combine all the access config into one liner KUBE_CONFIG environment variable like the following:

#On Prem K8s
export CONFIG_MICROK8S=$HOME/.kube/[email protected]

#Cloud K8s
export CONFIG_DO=$HOME/.kube/do-k8s-01-kubeconfig
export CONFIG_AWS=$HOME/.kube/aws-cluster-01

#Merge all the configs
export KUBECONFIG=$CONFIG_MICROK8S:$CONFIG_DO:$CONFIG_AWS

Finally, test the connectivity.

PreviousPoC LabNextHigh Availability Portable Mini Kubernetes Data Center with K3s

Last updated 1 year ago

Gist Source:

https://gist.github.com/malikperang/82db3f21ac0fde6ab1752ce329f782e5