Skip to content

Cluster API (CAPI) on Hetzner

Provision Kubernetes clusters using Cluster API with the Hetzner infrastructure provider (CAPH).

Prerequisites

  • lok8s CLI installed
  • A CAPI management cluster (or use lo to bootstrap one)
  • clusterctl installed
  • Hetzner Cloud API token exported as HCLOUD_TOKEN

Cluster configuration

Create a cluster.lok8s.yaml with kind: Capi:

yaml
apiVersion: cluster.lok8s.dev/v1beta1
kind: Capi
metadata:
  name: capi-cluster
spec:
  kubernetes:
    version: "v1.35.5"
  provider: hetzner
  hcloud:
    region: fsn1
    sshPublicKeyFile: "~/.ssh/id_ed25519.pub"
    network:
      cidr: "10.0.0.0/16"
  controlPlane:
    replicas: 3
    type: cx33
  workers:
    platform:
      replicas: 2
      type: cpx31

How CAPI provisioning works

When you run lo provision with kind: Capi, lok8s:

  1. Generates CAPI Cluster and MachineDeployment manifests
  2. Applies them to the management cluster
  3. CAPH creates Hetzner Cloud servers
  4. Kubeadm bootstraps Kubernetes on the nodes
  5. The kubeconfig is extracted and saved locally

Provision

bash
lo provision

Template structure

lok8s generates these CAPI resources from your config:

  • Cluster — cluster-level settings (network, region)
  • HetznerCluster — Hetzner-specific infrastructure
  • KubeadmControlPlane — control plane machines
  • MachineDeployment — worker node pools
  • HetznerMachineTemplate — server type and image

Verify

bash
# Check CAPI cluster status
kubectl get clusters -A

# Check workload cluster nodes
kubectl --kubeconfig=kubeconfig get nodes

When to use CAPI vs KubeOne

AspectKubeOneCAPI
Management clusterNot requiredRequired
Declarative lifecyclePartialFull
Multi-clusterManualNative
ComplexityLowerHigher

Use KubeOne for single clusters with simple requirements. Use CAPI for multi-cluster environments or GitOps-driven infrastructure.

Next steps


Doc status

AspectDetail
Stateactive
Last reviewed2026-07-10