OSX, Brew, Kubernetes helm and Azure

I think I typed enough keywords as blog title 😉

So it happened that I had to deal with kubernetes, helm and Azure. To discover that both client and server version of kubernetes helm MUST be the same.

$ helm install ./something -n somename-000 -f ./some-config.yaml
To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code XXXXXXX to authenticate.
Error: incompatible versions client[v2.14.1] server[v2.13.1]

The problem lies in the fact that I installed kubernetes-helm with brew on osx. Which is an amazing tool but not always keep in a easy accessible way older versions.

So the question now would be: how do I install the older version 2.13.1 so that I can work?

First, brew allows you to install from URL. Specially git URLs pointing to the raw ruby script.

With that we can point to a specific point in time on GH (hashcode) for the right formulae. First we have to find it out.

# clone the homebrew GH repo
$ git clone https://github.com/Homebrew/homebrew-core.git

# go through the logs (manually in this case) for the right commit id
$ git log master -- Formula/kubernetes-helm.rb
...
 commit c3a105c41a8f8be942bf97554466af236c2fac72
 Author: BrewTestBot homebrew-test-bot@lists.sfconservancy.org
 Date:   Fri Mar 22 02:21:09 2019 +0000
 kubernetes-helm: update 2.13.1 bottle.
 commit fd2c01c0cd6ba9a32c5a84b9b914debd077c7498
 Author: Igor Kapkov igasgeek@me.com
 Date:   Fri Mar 22 11:03:08 2019 +1100
 kubernetes-helm 2.13.1 Closes #38158. Signed-off-by: FX Coudert <fxcoudert@gmail.com># clone the homebrew GH repo
...

Now we have the commit we want: c3a105c41a8f8be942bf97554466af236c2fac72.

You can verify it by accessing https://raw.githubusercontent.com/Homebrew/homebrew-core/c3a105c41a8f8be942bf97554466af236c2fac72/Formula/kubernetes-helm.rb.

which now lead us to a set of commands

# will install the 2.13.1 version as currently brew moved to 2.14.1
$ brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/c3a105c41a8f8be942bf97554466af236c2fac72/Formula/kubernetes-helm.rb

# will switch to 2.13.1 and pin it so that future update of brew won't update the formulae
$ brew switch kubernetes-helm 2.13.1
$ brew pin kuberntes-helm