Skip to content

junchaw/kubectl-cf

Repository files navigation

kubectl-cf logo

Go Report Card License Docker Pulls Releases

Faster way to switch between kubeconfig files.

demo.gif

Usage of kubectl-cf:

  cf           Select kubeconfig interactively
  cf [config]  Select kubeconfig directly
  cf -         Switch to the previous kubeconfig

Installation

# With Homebrew

brew tap junchaw/awesome
brew install kubectl-cf
kubectl-cf -h

# With Docker

docker run junchaw/kubectl-cf -h

# Download from release page

First, download tar file from the release page.

After downloading the tar file, extract it, then put kubectl-cf in your PATH.

# Build from source

git clone https://github.com/junchaw/kubectl-cf.git
cd kubectl-cf && make build
./bin/kubectl-cf -h

# Use as a kubectl plugin

kubectl-cf can be called directly by typing kubectl-cf, or as a kubectl plugin kubectl cf, because it has the kubectl- prefix.

You may want to set an alias for kubectl-cf, like alias cf='kubectl cf'.

Features

# Take control of kubeconfig symlinks

kubectl-cf maintains kubeconfig symlinks for you, and updates the symlink when you switch kubeconfig

# Respect KUBECONFIG environment variable

kubectl-cf respects the KUBECONFIG environment variable, if it's set, kubectl-cf will use it as the kubeconfig file symlink.

# Grep kubeconfig files from multiple paths

By default, kubectl-cf reads kubeconfig files from the directory of the given kubeconfig file, you can change this by setting the KUBECTL_CF_PATHS environment variable, for example:

"@kubeconfig-dir" is a special path, it means the directory of the given kubeconfig file

export KUBECTL_CF_PATHS="~/.kube:~/another-kube-dir:~/yet-another-kube-dir:@kubeconfig-dir"

# Grep kubeconfig files with custom regex pattern

By default, kubectl-cf grep kubeconfig files with regex pattern ^(?P<name>(config)|([^\.]+\.yaml))$, you can change this by setting the KUBECTL_CF_KUBECONFIG_MATCH_PATTERN environment variable, for example:

export KUBECTL_CF_KUBECONFIG_MATCH_PATTERN="^(?P<name>([^\.]+\.kubeconfig))$"

Translations

TODO (PRs are welcomed)

  • Auto completion;
  • krew integration;
  • Tests;

References

  • kubekraken: kubectl that operates multiple contexts concurrently;
  • kubectl-ctx: switch between kubernetes contexts;

About

Faster way to switch between kubeconfig files, no more --kubeconfig chaos.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •