kubeconfig Contexts and Multi-Cluster Access
Stop SSH-ing to the control plane to run kubectl. Install kubectl on Windows, copy each cluster's admin kubeconfig across, merge four clusters into one file without losing the contexts you already had, and switch between them by name.
Installation and Cluster Builds Guide 12 of 103 Beginner
- Kubernetes1.36.4
- Clusters4 (1, 2, 3 and 4 node)
- Runtimecontainerd 2.2.6
- CNICalico v3.32.1
- TimeAbout 25 min
Certificate data, cluster CAs and byte counts are specific to this lab. The Windows kubectl was installed with Chocolatey; winget or a direct download behave the same once kubectl is on PATH.
- WorkstationWindows 11
- kubectl1.36 client
| Server Name | IP Address | OS | Roles | CPU | RAM | HDD |
|---|---|---|---|---|---|---|
| CKA1001 | 192.168.0.175 | Ubuntu 26.04 LTS | Control Plane Node | 2 Core | 4 GB | 50 GB |
| CKA1001-NODE01 | 192.168.0.176 | Ubuntu 26.04 LTS | Worker Node | 2 Core | 4 GB | 50 GB |
| CKA1001-NODE02 | 192.168.0.177 | Ubuntu 26.04 LTS | Worker Node | 2 Core | 4 GB | 50 GB |
| CKA1001-NODE03 | 192.168.0.178 | Ubuntu 26.04 LTS | Worker Node | 2 Core | 4 GB | 50 GB |
| CKA2001 | 192.168.0.181 | Ubuntu 26.04 LTS | Control Plane Node | 2 Core | 4 GB | 50 GB |
| CKA2001-NODE01 | 192.168.0.182 | Ubuntu 26.04 LTS | Worker Node | 2 Core | 4 GB | 50 GB |
| CKA2001-NODE02 | 192.168.0.183 | Ubuntu 26.04 LTS | Worker Node | 2 Core | 4 GB | 50 GB |
| CKA3001 | 192.168.0.185 | Ubuntu 26.04 LTS | Control Plane Node | 2 Core | 4 GB | 50 GB |
| CKA3001-NODE01 | 192.168.0.186 | Ubuntu 26.04 LTS | Worker Node | 2 Core | 4 GB | 50 GB |
| CKA4001 | 192.168.0.191 | Ubuntu 26.04 LTS | Control Plane Node | 2 Core | 4 GB | 50 GB |
This guide includes
Use this when you are still SSH-ing into a control plane to run kubectl, or when several clusters have to be reachable from one workstation. This matters because every kubeadm cluster names itself identically, so merging their configs collides unless you rename as you copy.
- installing kubectl on Windows, and understanding what
admin.confcontains before copying it anywhere - renaming each cluster, user and context while copying, so the merge does not collide
- backing up the kubeconfig you already have before touching it
- merging with
KUBECONFIGandconfig view --flatten, minding the separator and the first-file-wins rule - switching context and confirming every cluster actually answers
Before you start
- At least one working cluster, and SSH access to its control plane.
- Windows 10 or 11 with a terminal you like. The commands below are shown from Git Bash; PowerShell equivalents are noted where they differ.
- Network reach from the workstation to each control plane on TCP 6443.
- Somewhere private to keep the file.
admin.confis a cluster-admin credential, not a config file.
-
Install kubectl on Windows
-
Understand what you are about to copy
-
Copy each cluster's config across, renaming as you go
-
Back up the kubeconfig you already have
-
Merge, and mind the separator
-
Deal with duplicates: first file wins
-
Install it and check every cluster answers
-
Switch contexts, and avoid the obvious accident