AWS has eksctl tool for creating kubernetes cluster - Hetzner Cloud have no official tool for creating kubernetes cluster. This tool will create new production ready kubernetes clusters on Hetzner Cloud with minimum user interaction. New cluster will be available in High availability mode with automatic cluster autoscaling and automatic volume creation
- login to https://console.hetzner.cloud and create new project
- select project, select in menu Security -> API Tokens and create new "Read & Write" token
- save token to
.hcloudauth
file in current directory
MacOS
brew install maksim-paskal/tap/hcloud-k8s-ctl
for other OS download binnary from release pages
This will create kubernetes cluster in Hetzner Cloud Europe region with 3 instances, 1 load balancer for the kubernetes control plane and 1 kubernetes worker node, after successful installation the cluster will have:
- Kubernetes v1.30
- Kubernetes Autoscaler
- Flannel
- Kubernetes Cloud Controller Manager for Hetzner Cloud
- Container Storage Interface driver for Hetzner Cloud
- Kubernetes Metrics Server
- Simple CSR approver for Kubernetes
- Docker registry (optional)
- NFS Provisioner for Kubernetes (optional)
for HA needs odd number of master nodes (minimum 3) https://etcd.io/docs/v3.4/faq/#why-an-odd-number-of-cluster-members
Create a simple configuration file config.yaml
full configuration example here
# Kubeconfig path
kubeConfigPath: ~/.kube/hcloud
# Hetzner Cloud internal network CIDR
ipRange: "10.0.0.0/16"
# Servers for Kubernetes master (recommended 3)
# For development purposes, the cluster can have 1 master node
# In this case, the cluster will be created without a load balancer, and pods can be scheduled on the master
masterCount: 3
customize configuration file for your needs
# Kubeconfig path
kubeConfigPath: ~/.kube/hcloud
# Hetzner Cloud internal network CIDR
ipRange: "10.0.0.0/16"
# Servers for Kubernetes master (recommended 3)
# For development purposes, the cluster can have 1 master node
# In this case, the cluster will be created without a load balancer, and pods can be scheduled on the master
masterCount: 3
# Server components for all nodes in the cluster
serverComponents:
kubernetes:
# Customize Kubernetes version
version: 1.30.5-1.1
docker:
# Customize apt package version for Docker install
# apt-cache madison docker-ce
version: 5:27.3.1-1~ubuntu.$(lsb_release -rs)~$(lsb_release -cs)
containerd:
# Customize apt package version for containerd install
# apt-cache madison containerd.io
version: 1.7.22-1
# Add autoscaler chart extra values
cluster-autoscaler:
replicaCount: 3
resources:
requests:
cpu: 200m
memory: 300Mi
# Add a custom script for all nodes in the cluster
preStartScript: |
# Add a custom cron job on the node
crontab <<EOF
0 0 * * * /usr/bin/docker system prune -af
EOF
# Add containerd config for some registries
mkdir -p /etc/containerd/certs.d/some-registry.io
cat > /etc/containerd/certs.d/some-registry.io/hosts.toml <<EOF
server = "https://some-registry.io"
[host."http://10.10.10.10:5000"]
capabilities = ["pull", "resolve"]
EOF
Kubernetes: v1.28, Arch: amd64, Ubuntu: 20.04, Region: eu
masterCount: 3
serverComponents:
ubuntu:
version: ubuntu-20.04
architecture: x86
kubernetes:
version: 1.28.2-1.1
docker:
version: 5:24.0.6-1~ubuntu.$(lsb_release -rs)~$(lsb_release -cs)
containerd:
version: 1.6.24-1
Kubernetes: v1.28, Arch: amd64, Ubuntu: 22.04, Region: eu
masterCount: 3
serverComponents:
ubuntu:
version: ubuntu-22.04
architecture: x86
kubernetes:
version: 1.28.2-1.1
docker:
version: 5:24.0.6-1~ubuntu.$(lsb_release -rs)~$(lsb_release -cs)
containerd:
version: 1.6.24-1
Kubernetes: v1.28, Arch: amd64, Ubuntu: 22.04, Region: us
masterCount: 3
networkZone: us-east
location: ash
datacenter: ash-dc1
masterServers:
servertype: cpx21
serverComponents:
ubuntu:
version: ubuntu-22.04
architecture: x86
kubernetes:
version: 1.28.2-1.1
docker:
version: 5:24.0.6-1~ubuntu.$(lsb_release -rs)~$(lsb_release -cs)
containerd:
version: 1.6.24-1
cluster-autoscaler:
autoscalingGroups:
- name: cpx51-ash
minSize: 1
maxSize: 20
instanceType: cpx51
region: ash
Kubernetes: v1.28, Arch: arm64, Ubuntu: 20.04, Region: eu
masterCount: 3
serverComponents:
ubuntu:
version: ubuntu-20.04
architecture: arm
kubernetes:
version: 1.28.2-1.1
docker:
version: 5:24.0.6-1~ubuntu.$(lsb_release -rs)~$(lsb_release -cs)
containerd:
version: 1.6.24-1
masterServers:
servertype: cax11
cluster-autoscaler:
autoscalingGroups:
- name: cax-fsn1
minSize: 1
maxSize: 20
instanceType: cax41
region: fsn1
Kubernetes: v1.28, Arch: arm64, Ubuntu: 22.04, Region: eu
masterCount: 3
serverComponents:
ubuntu:
version: ubuntu-22.04
architecture: arm
kubernetes:
version: 1.28.2-1.1
docker:
version: 5:24.0.6-1~ubuntu.$(lsb_release -rs)~$(lsb_release -cs)
containerd:
version: 1.6.24-1
masterServers:
servertype: cax11
cluster-autoscaler:
autoscalingGroups:
- name: cax-fsn1
minSize: 1
maxSize: 20
instanceType: cax41
region: fsn1
Kubernetes: v1.29, Arch: amd64, Ubuntu: 20.04, Region: eu
masterCount: 3
serverComponents:
ubuntu:
version: ubuntu-20.04
architecture: x86
kubernetes:
version: 1.29.3-1.1
docker:
version: 5:24.0.6-1~ubuntu.$(lsb_release -rs)~$(lsb_release -cs)
containerd:
version: 1.6.24-1
Kubernetes: v1.29, Arch: amd64, Ubuntu: 22.04, Region: eu
masterCount: 3
serverComponents:
ubuntu:
version: ubuntu-22.04
architecture: x86
kubernetes:
version: 1.29.3-1.1
docker:
version: 5:24.0.6-1~ubuntu.$(lsb_release -rs)~$(lsb_release -cs)
containerd:
version: 1.6.24-1
Kubernetes: v1.29, Arch: amd64, Ubuntu: 22.04, Region: us
masterCount: 3
networkZone: us-east
location: ash
datacenter: ash-dc1
masterServers:
servertype: cpx21
serverComponents:
ubuntu:
version: ubuntu-22.04
architecture: x86
kubernetes:
version: 1.29.3-1.1
docker:
version: 5:24.0.6-1~ubuntu.$(lsb_release -rs)~$(lsb_release -cs)
containerd:
version: 1.6.24-1
cluster-autoscaler:
autoscalingGroups:
- name: cpx51-ash
minSize: 1
maxSize: 20
instanceType: cpx51
region: ash
Kubernetes: v1.29, Arch: arm64, Ubuntu: 20.04, Region: eu
masterCount: 3
serverComponents:
ubuntu:
version: ubuntu-20.04
architecture: arm
kubernetes:
version: 1.29.3-1.1
docker:
version: 5:24.0.6-1~ubuntu.$(lsb_release -rs)~$(lsb_release -cs)
containerd:
version: 1.6.24-1
masterServers:
servertype: cax11
cluster-autoscaler:
autoscalingGroups:
- name: cax-fsn1
minSize: 1
maxSize: 20
instanceType: cax41
region: fsn1
Kubernetes: v1.29, Arch: arm64, Ubuntu: 22.04, Region: eu
masterCount: 3
serverComponents:
ubuntu:
version: ubuntu-22.04
architecture: arm
kubernetes:
version: 1.29.3-1.1
docker:
version: 5:24.0.6-1~ubuntu.$(lsb_release -rs)~$(lsb_release -cs)
containerd:
version: 1.6.24-1
masterServers:
servertype: cax11
cluster-autoscaler:
autoscalingGroups:
- name: cax-fsn1
minSize: 1
maxSize: 20
instanceType: cax41
region: fsn1
Kubernetes: v1.30, Arch: amd64, Ubuntu: 20.04, Region: eu
ipRange: "10.0.0.0/16"
masterCount: 3
serverComponents:
ubuntu:
version: ubuntu-20.04
architecture: x86
kubernetes:
version: 1.30.5-1.1
docker:
version: 5:27.3.1-1~ubuntu.$(lsb_release -rs)~$(lsb_release -cs)
containerd:
version: 1.7.22-1
Kubernetes: v1.30, Arch: amd64, Ubuntu: 20.04, Region: us
ipRange: "10.0.0.0/16"
masterCount: 3
networkZone: us-east
location: ash
datacenter: ash-dc1
masterServers:
servertype: cpx21
serverComponents:
ubuntu:
version: ubuntu-20.04
architecture: x86
kubernetes:
version: 1.30.5-1.1
docker:
version: 5:27.3.1-1~ubuntu.$(lsb_release -rs)~$(lsb_release -cs)
containerd:
version: 1.7.22-1
cluster-autoscaler:
autoscalingGroups:
- name: cpx51-ash
minSize: 1
maxSize: 20
instanceType: cpx51
region: ash
Kubernetes: v1.30, Arch: amd64, Ubuntu: 22.04, Region: eu
ipRange: "10.0.0.0/16"
masterCount: 3
serverComponents:
ubuntu:
version: ubuntu-22.04
architecture: x86
kubernetes:
version: 1.30.5-1.1
docker:
version: 5:27.3.1-1~ubuntu.$(lsb_release -rs)~$(lsb_release -cs)
containerd:
version: 1.7.22-1
Kubernetes: v1.30, Arch: arm64, Ubuntu: 20.04, Region: eu
ipRange: "10.0.0.0/16"
masterCount: 3
serverComponents:
ubuntu:
version: ubuntu-20.04
architecture: arm
kubernetes:
version: 1.30.5-1.1
docker:
version: 5:27.3.1-1~ubuntu.$(lsb_release -rs)~$(lsb_release -cs)
containerd:
version: 1.7.22-1
masterServers:
servertype: cax11
cluster-autoscaler:
autoscalingGroups:
- name: cax-fsn1
minSize: 1
maxSize: 20
instanceType: cax41
region: fsn1
Kubernetes: v1.30, Arch: arm64, Ubuntu: 22.04, Region: eu
ipRange: "10.0.0.0/16"
masterCount: 3
serverComponents:
ubuntu:
version: ubuntu-22.04
architecture: arm
kubernetes:
version: 1.30.5-1.1
docker:
version: 5:27.3.1-1~ubuntu.$(lsb_release -rs)~$(lsb_release -cs)
containerd:
version: 1.7.22-1
masterServers:
servertype: cax11
cluster-autoscaler:
autoscalingGroups:
- name: cax-fsn1
minSize: 1
maxSize: 20
instanceType: cax41
region: fsn1
# create 3 instance with 1 load balancer
# kubernetes autoscaler will create 1 worker node
hcloud-k8s-ctl -action=create
all nodes in cluster initialized with official kubeadm - for all nodes use this script, for master initializing this script, for initial applications in cluster this script
export KUBECONFIG=$HOME/.kube/hcloud
kubectl get no
hcloud-k8s-ctl -action=patch-cluster
hcloud-k8s-ctl -action=list-configurations
hcloud-k8s-ctl -action=delete
You can easy install NFS provisioner for your cluster adding to your config.yaml
next lines
deployments:
nfs:
nfs-subdir-external-provisioner:
enabled: true
server:
enabled: true
It will install NFS Provisioner for Kubernetes (optional) with NFS Server and Storage Class
you can easy create new NFS volumes to your pod with this PersistentVolumeClaim
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: pvc-nfs
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 10Gi
storageClassName: nfs