kubectls is a kubectl version manager.
This is a kubectl version of tools like *env(kubectlenv).

Installation

You can install it with the following command: Think it will work if you have bash, ln, readlink, curl, and git installed.

$ git clone https://github.com/tkuchiki/kubectls ~/.kubectls

Set the PATH to give priority to ~/.kubectls/bin in .bashrc. If you are using zsh, replace it with .zshrc.

# for bash
$ echo "PATH=~/.kubectls/bin:\$PATH" >> ~/.bashrc
$ echo "export $PATH" >> ~/.bashrc

Usage

kubectls consists of 5 subcommands. Introduction to them one by one.

$ kubectls --help
Usage: kubectls

kubectls is kubectl version manager

Commands:
  install   Install kubectl
  path      Show current kubectl's abs path
  update    Update kubectls
  use       Set version
  versions  Show installed versions

Options:
  --version Show version

install

The install subcommand is an installing kubectl.

$ kubectls install --help
Usage: kubectl install (VERSION|stable) [--set]

Install kubectl

Options:
  --set     Set version

You can install the stable version of kubectl with kubectl install stable.

$ kubectls install stable
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 44.1M  100 44.1M    0     0  16.3M      0  0:00:02  0:00:02 --:--:-- 16.3M

v1.20.4 is installed

You can install the specified version of kubectl with kubectls install VERSION.

$ kubectls install v1.20.0
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 44.0M  100 44.0M    0     0  17.5M      0  0:00:02  0:00:02 --:--:-- 17.5M

v1.20.0 is installed

kubectls install just installs it. It will not become usable. To switch to the specified version, you can run kubectls use(see below) or kubectls install with the option --use.

$ kubectls install v1.20.1 --use
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 44.0M  100 44.0M    0     0  20.7M      0  0:00:02  0:00:02 --:--:-- 20.7M

v1.20.1 is installed
v1.20.1 selected

$ kubectl version --client --short
Client Version: v1.20.1

use

This is a subcommand to switch to the version of kubectl that you installed with kubectls install.

$ kubectls use --help
Usage: kubectl use [VERSION]

Set version

You can switch to the specific version with kubectls use VERSION.

$ kubectls use v1.20.4
v1.20.4 selected

You can switch to the specific version by selecting from the list of installed versions.

$ kubectls use
1) v1.20.0
2) v1.20.1
3) v1.20.2
4) v1.20.4
Which version? 3
v1.20.2 selected

path

Print the absolute path of the kubectl currently be used.

$ kubectls path --help
Usage: kubectl path

Show current kubectl's abs path
$ kubectls path
/Users/tkuchiki/.kubectls/versions/v1.20.2/kubectl

versions

Prints a list of installed versions.

$ kubectls versions --help
Usage: kubectl versions

Show installed versions
$ kubectls versions
v1.20.0
v1.20.1
v1.20.2
v1.20.4

update

Update kubectls.

$ kubectls update --help
Usage: kubectl update

Update kubectls

Conclusion

This article was an introduction to kubectls. You may not switch between multiple versions very often, but I hope this helps you!