Skip to content
Merge multiple kubeconfig
Go
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
cmd
.gitignore
.goreleaser.yml
.travis.yml
LICENSE Initial commit Jul 23, 2019
README.md update README.md doc Aug 13, 2019
example.yaml
go.mod
go.sum add config check & show Aug 8, 2019
main.go

README.md

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
  merge       Merge the kubeconfig files in the specified directory.
  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

Merge the kubeconfig

# Merge kubeconfig in the test directory
kubecm merge -f test 

# Merge kubeconfig in the test directory and overwrite the original kubeconfig file
kubecm merge -f test -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!

You can’t perform that action at this time.