DEV Community

cosckoya
cosckoya

Posted on

ASDF or how to manage multiple runtime versions.

ASDF is a linux tool that allows you to manage multiple runtime versions. But.. what that means?.

Imagine that you have to work with different Helm charts and Terraform infrastructures; or maybe you want to test a new cli release for Popeye, Etcd, Github Cli o Firebase. You should download latest release try it and go back to the last one that worked fine.

With ASDF you can switch between versions whenever you want, set that version at three stages: Global, Local and Shell.

Are you interested? OK! Then you should try it. Download you release from it's official Github page: https://github.com/asdf-vm/asdf

You will need to clone the repo:

git clone https://github.com/asdf-vm/asdf.git ${HOME}/.asdf
Enter fullscreen mode Exit fullscreen mode

And then add that path to your $PATH:

export PATH=$PATH:${HOME}/.asdf
Enter fullscreen mode Exit fullscreen mode

Now you need to update the plugin list:

CMD> asdf plugin list all

Output sample:
[...]
kubebuilder                   https://github.com/virtualstaticvoid/asdf-kubebuilder.git
kube-capacity                 https://github.com/looztra/asdf-kube-capacity.git
kubectl                      *https://github.com/Banno/asdf-kubectl.git
kubectl-bindrole              https://github.com/looztra/asdf-kubectl-bindrole.git
kubectx                      *https://gitlab.com/wt0f/asdf-kubectx.git
kubefedctl                    https://github.com/kvokka/asdf-kubefedctl.git
kubeseal                      https://github.com/stefansedich/asdf-kubeseal.git
kubesec                       https://github.com/vitalis/asdf-kubesec.git
kubespy                       https://github.com/jfreeland/asdf-kubespy.git
kubeval                       https://github.com/stefansedich/asdf-kubeval.git
terraform                    *https://github.com/Banno/asdf-hashicorp.git
terraform-docs               *https://github.com/looztra/asdf-terraform-docs.git
terraform-lsp                 https://github.com/bartlomiejdanek/terraform-lsp.git
terraform-validator           https://github.com/looztra/asdf-terraform-validator.git
terragrunt                    https://github.com/lotia/asdf-terragrunt.git
[...]
Enter fullscreen mode Exit fullscreen mode

We want to install Kubectl so let's check which versions are available:

CMD> asdf list all kubectl 

Output:
1.17.14
1.17.15
1.17.16
1.17.17
1.18.12
1.18.13
1.18.14
1.18.15
1.18.16
1.18.17
1.19.4
1.19.5
1.19.6
1.19.7
1.19.8
1.19.9
1.20.0-rc.0
1.20.0-beta.2
1.20.0
1.20.1
1.20.2
1.20.3
1.20.4
1.20.5
1.21.0-beta.0
1.21.0-rc.0
1.21.0-alpha.1
1.21.0-beta.1
1.21.0-alpha.2
1.21.0-alpha.3
Enter fullscreen mode Exit fullscreen mode

Mmm... lot of them, so lets install 1.17.15 version and 1.18.13:

CMD> asdf install kubectl 1.17.15
CMD> asdf install kubectl 1.18.13
Enter fullscreen mode Exit fullscreen mode

Done. Let's check that everything is installed properly:

CMD> asdf list

Output:

kubectl
  1.17.15
  1.18.13
Enter fullscreen mode Exit fullscreen mode

Nice! Seems that both versions are installed properly, now let's work with them:

First, let's try and set v1.17.15:

CMD> asdf shell kubectl 1.17.15
CMD> kubectl version --client=true --short=true

Client Version: v1.17.16-rc.0
Enter fullscreen mode Exit fullscreen mode

OK! Let's try v1.18.13:

CMD> asdf shell kubectl 1.18.13
CMD> kubectl version --client=true --short=true

Client Version: v1.18.13
Enter fullscreen mode Exit fullscreen mode

Nice! So I managed to install both versions ans switch in the same shell session. If I would like to set for as a recurrent version, I would run "asdf local kubectl 1.1x.y" or maybe for a global environment.

This is one of the best linux tools ever. I could manage almost any runtime just in seconds. Really useful and productive!

If you want to check how I manage my tools, check my dotfile Github repository: https://github.com/cosckoya/.dotfiles

Enjoy!

Top comments (0)