27 Jul 2016
Kelsey Hightower gave a really interesting talk at ContainerSched about how to create your own scheduler using the Kubernetes HTTP API.
The talk was awesome. It's incredible to see what kind of things you can do with a base system as good as Kubernetes.
However, I missed one thing. The example provided by Kelsey was a Go application. Which is the main language used with Kubernetes. So, if you look at that code without any context, you might think it's using some kind of Kubernetes internal packages. But it's not! It's a standalone piece of code that happens to make some HTTP calls.
To illustrate this point, I decided to write my own scheduler, in a different language. In my case, Elixir, because that's the language I happen to be learning at the moment.
This post isn't an intro to Elixir, but the code should be easy to follow.
Also, I'm going to use
localhost when accessing the Kubernetes API. Why? For simplicity. If we run
kubectl proxy on a computer connected to the Kubernetes master, we will not need to deal with authorization, hosts, and so on. The
proxy command will do it for us.
So, let's dive in.