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
kubectlcommand‑line tool to operate clusters, using a
kubeconfigfile (default location
~/.kube/config) for configuration. To manage multiple clusters with
kubectl, you can add several cluster entries to the same
kubeconfigby editing the file directly or running a series of
kubectl configcommands.
After a Kubernetes cluster is installed, a
kubeconfigfile is generated. To combine these files so that a single
kubeconfigcan manage many clusters, you can use the
kubecmtool, which this article demonstrates.
Install kubecm
First, install
kubecmon the machine that will manage multiple clusters. Refer to the official documentation for installation instructions.
Add credentials to kubeconfig with kubecm
Obtain the
kubeconfigfile for a cluster, rename it to the desired context name, and merge it into
~/.kube/configwith the following command:
<code>kubecm add -f <file></code>When prompted, choose True to overwrite the default kubeconfig file, then press Enter.
View cluster list
After adding clusters with
kubecm, run
kubecm lsto display the list of clusters in the
kubeconfig. An asterisk marks the currently active cluster.
Switch cluster
To switch to another cluster, use
kubecm switchfor an interactive selection:
However, using
kubectxfor switching is still recommended.
Remove cluster
To delete a cluster, run
kubecm delete <context>:
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.