When you work with multiple clients, or maybe with one company that has clusters in different versions of Kubernetes, you need to have a
kubectl (Kubernetes client) binary on your Mac that is not necessarily the only that
brew package manager offers (which is usually the latest). Kubernetes has a lee way of one version back and forth between the kubernetes server side and the kubernetes client side, but the 3 month release cycle is quite aggressive for stable companies. So how can you keep multiple versions of kubectl and switch to the one you need on demand? Enter
asdf is like
rbenv, it’s a version manager. Unlike the others though, it is extendable which is why there is a kubectl plugin.
How to get it working?
brew install asdf
asdf plugin-add kubectl
asdf install kubectl 1.13.4or
asdf install kubectl 1.15.0
asdf global kubectl 1.13.4
asdf local kubectl 1.15.0
The way it does it is with a file called
.tool-versions in the relevant path.
~ $ cat .tool-versions kubectl 1.15.0
Which means that you can also use
asdf to control the versions of other tools simultaneously, like ruby for example!
Want to play around more? Here is the commands list
I hope this helps!