Effortlessly Manage Multiple Kubernetes Clusters with kubecm
Learn how to install kubecm, merge multiple kubeconfig files, list, switch, and delete cluster contexts, enabling streamlined, single‑file management of many Kubernetes clusters directly from the command line without manually editing the config file, and see visual cues for the active context.
Background
Kubernetes provides the kubectl command‑line tool to operate clusters, using a kubeconfig file (default location ~/.kube/config) for configuration. To manage multiple clusters with kubectl, you can add several cluster entries to the same kubeconfig by editing the file directly or running a series of kubectl config commands.
After a Kubernetes cluster is installed, a kubeconfig file is generated. To combine these files so that a single kubeconfig can manage many clusters, you can use the kubecm tool, which this article demonstrates.
Install kubecm
First, install kubecm on the machine that will manage multiple clusters. Refer to the official documentation for installation instructions.
Add credentials to kubeconfig with kubecm
Obtain the kubeconfig file for a cluster, rename it to the desired context name, and merge it into ~/.kube/config with the following command:
kubecm add -f <file>When prompted, choose True to overwrite the default kubeconfig file, then press Enter.
View cluster list
After adding clusters with kubecm, run kubecm ls to display the list of clusters in the kubeconfig. An asterisk marks the currently active cluster.
Switch cluster
To switch to another cluster, use kubecm switch for an interactive selection:
However, using kubectx for switching is still recommended.
Remove cluster
To delete a cluster, run kubecm delete <context>:
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Ops Development Stories
Maintained by a like‑minded team, covering both operations and development. Topics span Linux ops, DevOps toolchain, Kubernetes containerization, monitoring, log collection, network security, and Python or Go development. Team members: Qiao Ke, wanger, Dong Ge, Su Xin, Hua Zai, Zheng Ge, Teacher Xia.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
