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

OSX Restarting GDrive App

If you use Google Drive and the OSX app, and like me you often travel and change network connection (VPNs count as well), you may have noticed that it won’t connect anymore.

While I don’t know why exactly, it may be due to some security things in the app itself, I noticed that by restarting the app it connects successfully.

Having to do it more than once a day, here is a simple script that with a double-click will restart it.


execute shell command via java

It happened to me that working via an extranet on a citrix environment in a WSAD workspace, that I needed to remove the attribute to at least 200 files in different directories.

Since do it one by one via WSAD is unthinkable, and I didn’t have time to going to the client, loggin into the net in order to have a shell and I dind’t have a shell by my hands, I did it via java.

The environment is Windows machine and here is the source

package tests.runners;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;

public class ShellCommandRunner {
	public static void main(String[] args) throws IOException{
		OutputStream stdin = null;
		BufferedReader br = null;
		String line = null;
		String command = null;

		command = "cmd.exe /C attrib -r /S /D X:\\workspaces\\tuc-workspace\\*.*";

		Process p = Runtime.getRuntime().exec(command);
		stdin = p.getOutputStream(); //use this to push commands

		//processing stdout
		br = new BufferedReader(new InputStreamReader(p.getInputStream()));
		while((line=br.readLine())!=null) System.out.println(line);

		//processing stderr
		br = new BufferedReader(new InputStreamReader(p.getErrorStream()));
		while((line=br.readLine())!=null) System.err.println(line);