How to setup Hetzner load balancer on a Kubernetes cluster
TL;DR: Recently (June 2020) Hetzner added a cloud native load balancer with Kubernetes support. Learn how to use it.

Introduction
Until a couple of months ago (June 2020) Germany Hetzner Cloud provider did not have a native cloud load balancer in its portfolio.
To achieve a “LoadBalancer” service in an Hetzner Kubernetes cluster you must to use a software solution like as MetalLB.
I wrote this previous post about how to create a Rancher Kubernetes cluster on Hetzner cloud using MetalLB.
Now we are going to see how to create a Kubernetes cluster using the new Load Balancer service already available in Hetzner.
Hetzner Load Balancer at glance
The new and claimed Load Balancer (LB) service has a entry level price of 4.9€/mo. Not so bad.
For that price you have a LB with a traffic support up to 20 TB/mo, 5 services (“ports”) and 25 targets (nodes). It’s enough for small/medium production services.
For more details visit “Load Balancer — Hetzner Online GmbH”.
Hetzner has its own Kubernetes cloud controller manager and now includes the LB support.
Cloud provider
As probably you know, Kubernetes implements by default the major cloud providers: AWS, Azure, GCP, …
This let’s to create or destroy new nodes, volumes or load balancers on demand.
For the rest of cloud providers, Kubernetes includes a interface that the cloud provider must implement to give support it.
In this case, when we create the cluster we must specify the cloud provider as external and later apply the 3th-party cloud-controller-manager manifest (Hetzner in our case).
Cluster creation
Let’s go. We use Rancher to create the cluster.
First we specify our needs using the UI.

Under “Kubernetes options” we select “External” in “Cloud provider”

Now we switch into YAML mode to add the following as addons:
- A Hetzner API Token as secret.
- The Hetzner cloud-controller-manager manifest URL.


The addons
and addons_include
are children of rancher_kubernetes_engine_config
. Take care of the indentation.
Remember replace <YOUR-HETZNER-API-TOKEN> with the yours!
Now click on “Create” and wait for the cluster creation.
If something goes wrong, you can apply the secret and manifest after.
Usage
We demonstrate its usage with the ingress-nginx controller.
First we create our first load balancer in the Hetzner UI.

Just select your preferred location, give a name (remember that name!) and press on “Create & Buy now”.
Now we need to edit ingress service definition and put the right annotations and service type:
It’s very important to set-up the right health check port. In my case that port was 30787. You can view it the ingress-nginx manifest.
You can check the full list of annotations directly from the source code in GitHub.
If it works, you can see something similar to this screen capture.

I hope this post has been useful to you.
Now Hetzner becomes a 100% Kubernetes solution ;)
Related posts
Please, if you liked it, give it a round of applause. And if you want to know more about DevOps, Kubernetes, Docker, etc … follow me :)
