How to create a Kubernetes cluster with Rancher on Hetzner

The 3 stars of our story

About Kubernetes, Rancher and Hetzner

Kubernetes is a container orchestration tool developed by Google which helps to deploy software solutions with complex architectures like microservices. Since its launch in 2014 it has experienced great growth and a it’s a key piece of many DevOps infrastructures. With Kubernetes (k8s) cluster management is very easy.

Why Rancher?

If you are newbie to Kubernetes or Docker world, you will see soon that it’s a complex world.

0. Prerequisites

You must have installed a recent kubernertes CLI too, kubectl.

1. Prepare your Hetzner Account and get API token

First thing you need is an Hetzner account. It’ simple: sign-up, enter your credit card or PayPal, and voilá!

2. Install Rancher

Among the different types of Rancher installation we use the Docker container.

Hetzner’s create private network wizard
It’s time to create a new cluster!

3. Install Hetzner Cloud driver

Before we can create our cluster, it’s necessary to add Hetzner as provider.

Oh damn it! Where is Hetzner?

4. Cluster node template

In Hetzner we need to create a API Token for 3rd parties access like Rancher.

List of enabled Hetzner API tokens
Hetzner Generate API token dialog

5. Create the cluster

In Rancher, go to “Global” and press onto “Add Cluster”. You can see now “Hetzner” as provider.

Hetzner driver ready to create our cluster!
Add cluster in Hetzner screen
Enter the Hetzner token dialog
Node template dialog
  • Ubuntu 18.04 with CX21 (2 vCPUS / 4 GB RAM) for master node (etcd, control panel)
  • Ubuntu 18.04 with CX31 (2 vCPUS / 8 GB RAM) for worker node (workload pods)
  • 1 Master node named “master” with CX21 template based.
  • 1 Worker node named “worker” with CX31 template based.
Master & Comand Panel

6. Configuring your cluster

To use kubectl from your desktop, we download the cluster config directly from Rancher.

One place to control all your cluster
Kubectl works perfectly

Volume class driver

At this moment your pods are ephemeral. If you want to create deployments which use persistent volume, you need to add CSI driver to allocate volumes on demand.

Native Load Balancer

Recently (June 2020) Hetzner has added the load balancer service with support for kubernetes. In this post he explained how to create a cluster with support for this balancer.

(Soft) Load Balancer with MetalLB

If you don’t want to use the cloud native Hetzner Load Balance service, you can use the software solution MetalLB.

  1. We install it using manifests


I hope this post has been useful for you and allows you to experiment with Rancher and Kubernetes easily.

Related posts

Some claps, pls? Thanks you! :)



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
JM Robles

JM Robles

Backend Platform engineer #go #python #kubernetes #terraform #devops