Skip to main content

Configuring a Hetzner Load Balancer

Load Balancer Configuration Examples#

To expose your workload with a Service of type LoadBalancer, annotate the Service so that IPs are assigned correctly:

Annotation key Explanation
load-balancer.hetzner.cloud/location Should match the region set on the Cluster resource
load-balancer.hetzner.cloud/type Should match the type set on the Cluster resource

The following example manifest exposes a web server with a Service of type LoadBalancer:

yaml
		apiVersion: v1
kind: Service
metadata:
  creationTimestamp: null
  labels:
    run: test-loadbalancer
  name: test-loadbalancer
  annotations:
    load-balancer.hetzner.cloud/location: fsn1
    load-balancer.hetzner.cloud/type: lb11
spec:
  ports:
    - port: 80
      protocol: TCP
      targetPort: 80
  selector:
    run: test-loadbalancer
  type: LoadBalancer
---
apiVersion: v1
kind: Pod
metadata:
  labels:
    run: test-loadbalancer
  name: test-loadbalancer
spec:
  containers:
    - image: nginx
      name: test-loadbalancer
  dnsPolicy: ClusterFirst
  restartPolicy: Always
	

The External IP assigned to your Service appears in its status, and you can access nginx through it.