/kubecm

Merge multiple kubeconfig

Primary LanguageGoApache License 2.0Apache-2.0

KubeCM

Build Status Go Report Card GitHub GitHub release

Merge multiple kubeconfig

Merge multiple kubeconfig
 _          _
| | ___   _| |__   ___  ___ _ __ ___
| |/ / | | | '_ \ / _ \/ __| '_ \ _ \
|   <| |_| | |_) |  __/ (__| | | | | |
|_|\_\\__,_|_.__/ \___|\___|_| |_| |_|

Find more information at: https://github.com/sunny0826/kubecm

Usage:
  kubecm [command]

Available Commands:
  add         Merge configuration file with ./kube/config
  delete      Delete the specified context from the kubeconfig
  get         Displays one or many contexts from the kubeconfig file.
  help        Help about any command
  use         Sets the current-context in a kubeconfig file
  version     Prints the kubecm version

Flags:
  -h, --help   help for kubecm

Use "kubecm [command] --help" for more information about a command.

Quick Start

Install kubecm

Homebrew:

brew install sunny0826/tap/kubecm

Download the binary:

# linux x86_64
curl -Lo kubecm.tar.gz https://github.com/sunny0826/kubecm/releases/download/v${VERSION}/kubecm_${VERSION}_Linux_x86_64.tar.gz
# macos
curl -Lo kubecm.tar.gz https://github.com/sunny0826/kubecm/releases/download/v${VERSION}/kubecm_${VERSION}_Darwin_x86_64.tar.gz

tar -zxvf kubecm.tar.gz kubecm
sudo mv kubecm /usr/local/bin/

Add configuration to ./kube/config

# Merge example.yaml with ./kube/config.yaml
kubecm add -f example.yaml 

# Merge example.yaml and name contexts test with ./kube/config.yaml
kubecm add -f example.yaml -n test

# Overwrite the original kubeconfig file
kubecm add -f example.yaml -c

Displays contexts

# List all the contexts in your kubeconfig file
kubecm get

# Describe one context in your kubeconfig file.
kubecm get my-context

# example output
$ kubecm get
+------------+-----------------------+---------------------------+------------------------+
|   CURRENT  |          NAME         |          CLUSTER          |          USER          |
+============+=======================+===========================+========================+
|      *     |      al_devops        |    al_devops-0-cluster    |    al_devops-0-user    |
+------------+-----------------------+---------------------------+------------------------+
|            |       al_prod         |     al_prod-0-cluster     |     al_prod-0-user     |
+------------+-----------------------+---------------------------+------------------------+
|            |       al_test         |     al_test-0-cluster     |     al_test-0-user     |
+------------+-----------------------+---------------------------+------------------------+

Delete context

# Delete the context
kubecm delete my-context

Set context

# Use the context for the test cluster
kubecm use test

Contribute

Feel free to open issues and pull requests. Any feedback is highly appreciated!