kxd

command module
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 25, 2023 License: MIT Imports: 1 Imported by: 0

README

kxd - Kubeconfig Switcher

kxd is a command-line utility that allows you to easily switch between Kubernetes configuration files (kubeconfig) and contexts. This tool is designed to simplify the management of multiple Kubernetes clusters and contexts.

Features

  • Switch between different kubeconfig files.
  • Switch between Kubernetes contexts within a kubeconfig file.

Installation

Make sure you have Go installed. You can download it from here.

Homebrew
brew tap radiusmethod/kxd
brew install kxd

or just

brew install radiusmethod/kxd/kxd
Makefile
make install
To Finish Installation

Add the following to your bash profile or zshrc then open new terminal or source that file

alias kxd="source _kxd"

Ex. echo -ne '\nalias kxd="source _kxd"' >> ~/.zshrc

Configuration

By default, Kubeconfig Switcher looks for files with an extension of .conf. You can customize the behavior by setting an environment variable:

  • KXD_MATCHER: The file extension used to identify kubeconfig files (default is .conf).

Usage

  • See docs for more info kxd
Switching Kubeconfig Files

To switch between different kubeconfig files, use the following command:

kxd f s

This command will display a list of available kubeconfig files in your ~/.kube directory. Select the one you want to use.

Switching Kubernetes Contexts

To switch between Kubernetes contexts within a kubeconfig file, use the following command:

kxd ctx s

This command will display a list of available contexts in your current kubeconfig file. Select the one you want to switch to.

Listing Current Kubeconfig or Kubernetes Context

To list the currently set Kubeconfig or Kubernetes Context, use the following commands:

kxd f c

This command will display the currently set kubeconfig file.

kxd ctx c

This command will display the currently set Kubernetes Context.

Version

To check the version of Kubeconfig Switcher, use the following command:

kxd version
Show your set kubeconfig in your shell prompt

For better visibility into what your shell is set to it can be helpful to configure your prompt to show the value of the env variable KUBECONFIG.

Here's a sample of my zsh prompt config using oh-my-zsh themes

# Kubeconfig info
local kxd_info='$(kxd_config)'
function kxd_config {
  local config="${KUBECONFIG:=}"
    if [ -z "$config" ]
    then
          echo -n ""
    else
          config=$(basename $config)
          echo -n "%{$fg_bold[blue]%}kx:(%{$fg[cyan]%}${config}%{$fg_bold[blue]%})%{$reset_color%} "
    fi
}
PROMPT='OTHER_PROMPT_STUFF $(kxd_info)'

Contributing

If you encounter any issues or have suggestions for improvements, please open an issue or create a pull request on GitHub.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
src
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL