Helm from Java!

If you work with Kubernetes, you have surely encountered Helm, the more-official-than-the-alternatives package manager for the Kubernetes platform.

Helm is a command-line tool, written in Go, that interacts with a Kubernetes cluster to make managing all the various Kubernetes resources a little easier and less of a frantic exercise in watching things break and restart automatically.  It is indispensable.  You can read more about it at its Github repository.

Helm’s machinery consists of two parts: the command line tool, helm, and the server-side componentry that stays mostly hidden behind the scenes (Tiller).  (The nautical imagery gets very old very fast but there’s no escaping it.)

When you install helm, the first thing you do (typically) is to run helm init.  This sets up some housekeeping directories and such locally, and also, very conveniently, programmatically constructs Kubernetes Deployment, Service and (optionally) Secret resources that together cause Tiller to be deployed into Kubernetes so that the helm command line tool can talk to it.  It’s a very simple idempotent bootstrap operation and is key to helm‘s simplicity.

Once you have Tiller running in your Kubernetes cluster, the helm command line tool talks to it to do the heavy lifting.  Tiller, in other words, is the real workhorse, and helm is a glorified curl for it.  (Representing it this way is a great disservice to the Helm team, of course, and I’m not actually serious, but it should help you to put the pieces together mentally.)

Now suppose you wanted for whatever crazy reasons to do the following from a Java library:

  • Install Tiller if it isn’t already there
  • Talk to it using a Java API

If you use my (early days!) microbean-helm project, you can now do this—no command line tooling required.

The Tiller API itself is defined using protocol buffers, which means you can generate it using gRPC.  That is handled by microbean-helm’s pom.xml file, which arranges for the protocol buffers files to be checked out of the official Helm Github repository and compiled appropriately. (Then, because they’re now part of a regular old Maven Java project, you can make Javadocs out of them too.)

So the generated Tiller API lets you talk to Tiller, which is the real heart of the whole Helm system.  With that, you can write any number of helm-like tools in Java.

Of course, you need a Tiller server to talk to.  The installation part is something that I hand-tooled by following the logic in the Helm installer code (invoked indirectly via helm init) and making it idiomatic for a Java library.  Just as with helm init, you can install Tiller if it isn’t there, or upgrade it if it is.

The net effect is that armed with this Java library you can now install or upgrade Tiller, install Helm charts, and otherwise work with Helm artifacts without having to drop down to the command line. Happy Helming—from Java!


Author: Laird Nelson

Devoted husband and father; working on Helidon at the intersection of Java, Jakarta EE, architecture, Kubernetes and microservices at Oracle; open source guy; Hammond B3 player and Bainbridge Islander.

One thought on “Helm from Java!”

Comments are closed.

%d bloggers like this: