Hetzner load balancers in Syself Autopilot perform distinct roles depending on whether they serve platform infrastructure or application traffic. The control-plane load balancer sits in front of the Kubernetes API server and is managed through `Cluster` topology variables. Workload load balancers route public traffic directly to application pods and are configured through annotations on `type: LoadBalancer` Services. If you are deciding how to expose a specific workload, start with [Choose how to expose an application](/docs/hetzner/apalla/network/expose/choose-how-to-expose). | Kind | Who creates it | How you configure it | | --------------------------- | --------------------------------------------------------- | ------------------------------------------ | | Control-plane load balancer | Syself Autopilot, at cluster creation | Topology variables on the `Cluster` object | | Application load balancer | The Hetzner CCM, when you create a `LoadBalancer` Service | Annotations on the Service | ```mermaid flowchart LR A(["kubectl and API clients"]):::you --> CPLB["Control-plane LB :443"]:::external --> API["Control-plane nodes :6443"]:::platform U(["Internet clients"]):::external --> APPLB["Per-Service LB"]:::external --> NP["Node NodePort"]:::platform --> POD["Pods"]:::app ``` > [!NOTE] > Hetzner Load Balancers support TCP-based protocols only (including HTTP and HTTPS, which run on TCP at Layer 4). UDP is not supported. To expose a UDP service, route traffic directly to the nodes with a `NodePort` instead; see [UDP is not supported](/docs/hetzner/apalla/network/expose/choose-how-to-expose#udp-is-not-supported). ## The control-plane load balancer Syself Autopilot creates one Hetzner load balancer for the Kubernetes API server when it builds the cluster. It listens on port `443`, forwards to port `6443` on the control-plane nodes, and carries only API traffic. The Hetzner CCM does not manage this one. The platform creates and reconciles it from your topology variables, so you configure it on the `Cluster` object, not with Service annotations. ```yaml title="cluster.yaml" spec: topology: variables: - name: clusterLoadBalancerType value: lb21 # lb11 (default) | lb21 | lb31 - name: clusterLoadBalancerName value: my-apiserver-lb # optional; Syself names it if you omit this - name: region value: nbg1 # fsn1 (default) | nbg1 | hel1 | ash | hil ``` `clusterLoadBalancerType` sets the Hetzner product. A load balancer type is defined by two limits: how many **targets** (the servers behind it) it can hold, and how many simultaneous **connections** it can carry. | Type | Max targets | Max connections | | ------ | ----------- | --------------- | | `lb11` | 25 | 10,000 | | `lb21` | 75 | 20,000 | | `lb31` | 150 | 40,000 | For the control plane, `lb11` is sufficient for almost all deployments because standard control planes only maintain 3 to 5 nodes and rarely exceed 10,000 concurrent API connections. The same load balancer types and capacity thresholds apply to workload Services via the `load-balancer.hetzner.cloud/type` annotation. For up-to-date specifications and pricing, see [Hetzner Load Balancers](https://www.hetzner.com/cloud/load-balancer/). Changing the type on a running cluster resizes the load balancer in place, so it keeps its IP addresses. The `region` variable sets both the control plane's placement and the load balancer's region at once; the load balancer cannot live in a different region from the cluster. Read the current settings from the `HetznerCluster` object: ```console $ kubectl get hetznercluster -o jsonpath='{.spec.controlPlaneLoadBalancer}' ``` The output shows `enabled`, `algorithm`, `type`, `port`, `region`, `targetAddressFamily`, `enableProxyProtocol`, and the `healthCheck` settings. Fill in your cluster's fields in the Cluster Configurator and export a ready-to-apply manifest — no hand-written YAML required. ## Application load balancers The Hetzner Cloud Controller Manager (CCM) automatically provisions a dedicated Hetzner Load Balancer whenever you create a Service with `type: LoadBalancer`. It registers cluster nodes as backend targets through an allocated `NodePort` and writes the assigned public IP addresses to `status.loadBalancer.ingress`. > [!NOTE] > Hetzner Cloud Load Balancers are the standard, managed way to expose `type: LoadBalancer` Services on the platform. However, you can also self-host an in-cluster load balancing controller like [MetalLB](https://metallb.io/) to announce Service IPs directly from your nodes. The remainder of this page covers tuning Hetzner's managed load balancers. ```yaml title="service.yaml" apiVersion: v1 kind: Service metadata: name: my-app annotations: load-balancer.hetzner.cloud/location: fsn1 load-balancer.hetzner.cloud/name: my-app-lb spec: type: LoadBalancer selector: app: my-app ports: - port: 80 targetPort: 8080 ``` The CCM reconciles a Service whenever it changes, so most annotation edits take effect within seconds. ### Defaults you get with no annotations The platform configures the CCM so a bare `LoadBalancer` Service already works: - **Dual-stack address.** Every load balancer receives a public IPv4 and a public IPv6 address, and bridges IPv6 clients to the IPv4-only nodes. Disable IPv6 per Service with `load-balancer.hetzner.cloud/ipv6-disabled: "true"`. See [Serve IPv6 clients](/docs/hetzner/apalla/network/load-balancing/serve-ipv6). - **Public-IP targeting.** The load balancer reaches nodes over their public IP, because the platform runs no private network. You never set `use-private-ip`. - **Default region.** A Service with no `location` receives a load balancer in the cluster's region. Set `location` regardless, so the region is explicit and does not drift from where your workload runs. - **Default type.** A Service with no `type` annotation receives an `lb11`. If you resize such a load balancer in the Hetzner console, the CCM changes it back to `lb11`. Set the `type` annotation to keep a larger type. See [Keep a larger load balancer type](#keep-a-larger-load-balancer-type). - **NodePort limited to the load balancer.** By default, only the Service's own load balancer can reach its NodePort from outside the cluster. See [Limit the NodePort to the load balancer](#limit-the-nodeport-to-the-load-balancer). ### Keep a larger load balancer type The `type` annotation on the Service decides the load balancer type. To get a larger type, set the annotation. The CCM resizes the load balancer in place. It keeps its addresses, and single requests fail at the moment of the change. A Service without the annotation gets an `lb11`, whatever type the load balancer has at Hetzner: ```yaml metadata: annotations: load-balancer.hetzner.cloud/type: lb21 ``` > [!WARNING] > Change the type with the annotation only, not in the Hetzner console. A load balancer that was resized in the console, on a Service without the annotation, is changed back to `lb11`. If it no longer fits an `lb11`, for example because the Service has more than 5 ports, the change to `lb11` fails with the event `changeType: number of existing services is higher than load balancer type max services`. From then on the CCM does not update this load balancer: new nodes are not added as targets, and once the old nodes are replaced it has no targets left. Set the `type` annotation to the type the load balancer has, and the CCM updates it again. For the limits of each type, see [What are a Hetzner load balancer's real limits?](/support/what-are-a-hetzner-load-balancer-s-real-limits-and-how-does-multi-lb-balancing-work) ### Limit the NodePort to the load balancer The load balancer sends traffic to the Service's NodePort, which is open on every node. The nodes have public IPs, and Cilium handles NodePort traffic before the host firewall sees it. Without a limit, anyone could skip the load balancer and connect to `:` directly. The platform closes that path for every `type: LoadBalancer` Service: 1. The CCM adds the load balancer's public IPv4 address to the Service's `spec.loadBalancerSourceRanges` as a `/32` entry. The IPv6 address is not added, because the load balancer connects to the nodes over IPv4. 2. Cilium applies `loadBalancerSourceRanges` to the NodePort and drops every other source. Clients inside the cluster are not affected. The CCM lists the entries it added in the read-only annotation `load-balancer.hetzner.cloud/node-port-source-ranges`. It replaces them when the load balancer's IP changes, and removes them when you turn the restriction off or delete the load balancer. To turn the restriction off for one Service, add this annotation. Its NodePort then answers every source again: ```yaml metadata: annotations: load-balancer.hetzner.cloud/restrict-node-port-source: "false" ``` The CCM can add its entry only once the load balancer has an address. Until then the NodePort answers every source. That is under a second on a new Service, but it lasts as long as the load balancer cannot be created, for example because of a wrong annotation value or an invalid Hetzner token. To have the NodePort closed from the start, create the Service with a placeholder entry. Cilium then drops every outside source until the CCM adds the load balancer's address next to it: ```yaml spec: type: LoadBalancer loadBalancerSourceRanges: - 127.0.0.1/32 ``` Only `type: LoadBalancer` Services are limited. A plain `type: NodePort` Service answers every source, as before. Keep these rules in mind when you work with `loadBalancerSourceRanges`: - **Your own entries are kept.** The CCM adds its entry next to yours and never removes yours. If you turn the restriction off and keep your own entries, Cilium still filters the NodePort by them. Include the load balancer's address in them, or its traffic is dropped too. - **Client ranges do not filter clients.** The load balancer opens its own connection to the node, so a client range in `loadBalancerSourceRanges` never matches traffic that comes through the load balancer. To allow or block clients by address, turn on PROXY protocol and filter in the ingress controller. See [Preserve the client source IP](/docs/hetzner/apalla/network/load-balancing/preserve-client-source-ip#recover-the-client-ip-with-proxy-protocol). - **A malformed entry is skipped.** Cilium skips an entry with a leading or trailing space, for example `" 198.51.100.0/24"`, and applies the rest. While the restriction is on, the CCM records a `NodePortSourceRangeNotCanonical` warning event on the Service. If the restriction is off and every entry is malformed, the NodePort answers every source. Fix the entry. - **Remove the ranges to change the Service type.** The API server accepts `loadBalancerSourceRanges` only on `type: LoadBalancer` Services. Remove `loadBalancerSourceRanges` in the same request that changes the type. Or turn the restriction off first, and change the type once the CCM has removed its entries. - **Deny-list Services are skipped.** On a Service with `service.cilium.io/src-ranges-policy: deny`, Cilium treats the ranges as a deny-list, so the CCM adds nothing. ### Keep the address with a Primary IP A load balancer normally gets new public addresses when it is created, and loses them when it is deleted. To keep an address when you delete and recreate a Service, for example so that DNS records stay valid, create the load balancer on Hetzner Primary IPs that you own. Create the Primary IPs Create one Primary IP for each address family you want to keep, in the location of the load balancer. It must have the assignee type `load_balancer`, and `auto_delete` set to `false`, or Hetzner deletes the Primary IP together with the load balancer. This call creates an IPv4 address through the [Hetzner Cloud API](https://docs.hetzner.cloud/reference/cloud#tag/primary-ips). Use `"type": "ipv6"` for an IPv6 address. ```console $ curl -s -X POST https://api.hetzner.cloud/v1/primary_ips \ -H "Authorization: Bearer $HCLOUD_TOKEN" -H "Content-Type: application/json" \ -d '{"name":"my-app-ipv4","type":"ipv4","assignee_type":"load_balancer","location":"fsn1","auto_delete":false}' ``` The response contains the `id` of the Primary IP and its address. Reference them on the Service Set the IDs, not the addresses, in the annotations. Set `location` to the location of the Primary IPs. ```yaml title="service.yaml" apiVersion: v1 kind: Service metadata: name: my-app annotations: load-balancer.hetzner.cloud/location: fsn1 load-balancer.hetzner.cloud/public-net-ipv4: "4711" load-balancer.hetzner.cloud/public-net-ipv6: "4712" spec: type: LoadBalancer selector: app: my-app ports: - port: 80 targetPort: 8080 ``` The two annotations are independent. If you set only one, the load balancer gets a new address for the other address family. When you delete the Service, the load balancer is deleted and the Primary IPs stay in your project, unassigned. A new Service with the same annotations gets the same addresses. The NodePort restriction works as on any other load balancer. Keep these rules in mind: - **Set the annotations when you create the Service.** The CCM assigns Primary IPs only when it creates the load balancer. If you add, change, or remove an annotation later, the Service gets a `PrimaryIPChangeUnsupported` warning event and the addresses stay as they are. To move to other addresses, delete and recreate the Service. - **The Primary IP must be free and in the same location.** If it is assigned to another resource, does not exist, or is in another location, the load balancer is not created and the Service's events say why. See [Troubleshoot load balancers and service traffic](/docs/hetzner/apalla/network/debug/troubleshoot-load-balancers-and-services#the-service-is-stuck-on-pending). - **Hetzner bills a Primary IPv4 address while it is unassigned too.** Delete Primary IPs you no longer need. ### Set the idle timeout of HTTP connections A load balancer service with the protocol `http` or `https` closes a connection that has been idle for 50 seconds. Change this with the `http-timeout-idle` annotation, to a value between `30s` and `300s`: ```yaml metadata: annotations: load-balancer.hetzner.cloud/protocol: http load-balancer.hetzner.cloud/http-timeout-idle: 120s ``` - **Use it only with `protocol: http` or `https`.** Services use the protocol `tcp` unless you set the `protocol` annotation. On a `tcp` Service, or with a value outside `30s` to `300s`, the CCM cannot reconcile the Service and records the event `invalid input in field 'http'`. A new Service then gets no address. Fix or remove the annotation. - **Removing the annotation keeps the last value.** To go back to the default, set `50s`. ### Annotation reference Every annotation goes on `metadata.annotations` of the Service. | Annotation (`load-balancer.hetzner.cloud/…`) | What it does | Notes | | -------------------------------------------- | ------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `location` | Region for the load balancer (`fsn1`, `nbg1`, `hel1`, `ash`, `hil`) | Defaults to the control-plane load balancer's region. Set it explicitly. | | `type` | Product: `lb11`, `lb21`, or `lb31` | `lb11` is the default. | | `name` | Name shown in the Hetzner console | Optional. | | `algorithm-type` | Target selection: `round_robin` or `least_connections` | `round_robin` is the default. | | `ipv6-disabled` | `"true"` removes the public IPv6 | IPv6 is on by default. | | `hostname` | Publishes a hostname in `status.loadBalancer.ingress` instead of the IPs | With this set, the IP and `ipMode` reads on the Service return nothing. | | `uses-proxyprotocol` | `"true"` enables PROXY protocol | The backend must also parse the header. See [Preserve the client source IP](/docs/hetzner/apalla/network/load-balancing/preserve-client-source-ip#recover-the-client-ip-with-proxy-protocol). | | `health-check-protocol` | `tcp`, `http`, or `https` | `tcp` is the default. | | `health-check-interval` | Interval between checks, a Go duration such as `"15s"` | A bare number is rejected and the Service fails to reconcile. | | `health-check-timeout` | Timeout of a single check, a Go duration such as `"10s"` | | | `health-check-retries` | Failed checks before a target is marked unhealthy | | | `health-check-http-path` | Path requested by `http` and `https` checks | | | `protocol` | Protocol of the load balancer services: `tcp`, `http`, or `https` | `tcp` is the default. | | `http-timeout-idle` | Idle timeout of `http` and `https` connections, `30s` to `300s` | Hetzner's default is 50 seconds. See [Set the idle timeout of HTTP connections](#set-the-idle-timeout-of-http-connections). | | `public-net-ipv4` | ID of the Primary IP to use as the public IPv4 address | Only read when the load balancer is created. See [Keep the address with a Primary IP](#keep-the-address-with-a-primary-ip). | | `public-net-ipv6` | ID of the Primary IP to use as the public IPv6 address | Only read when the load balancer is created. | | `robot-target-address-family` | Address family for bare-metal (Robot) targets | Platform default `ipv4`. | | `restrict-node-port-source` | `"false"` lets every source reach the Service's NodePort | On by default. See [Limit the NodePort to the load balancer](#limit-the-nodeport-to-the-load-balancer). | | `node-port-source-ranges` | Lists the `loadBalancerSourceRanges` entries the CCM added | Read-only. The CCM writes it. Do not set it. | ## Load balance to bare-metal nodes A Hetzner load balancer serves bare-metal (Robot) nodes like cloud nodes, so there is nothing extra to set up. The CCM adds the two kinds as different target types: - **Cloud nodes join as server targets**, referenced by their server ID. - **Bare-metal nodes join as IP targets**, by their public IPv4 address. A pool can mix both, and the load balancer spreads traffic across them. Bare-metal targets stay IPv4. The platform sets `HCLOUD_LOAD_BALANCERS_ROBOT_TARGET_ADDRESS_FAMILY=ipv4` on the CCM, because nodes have no usable IPv6 and an IPv6 target would never pass its health check. Leave this default unchanged. The `robot-target-address-family` annotation sets it per Service. With `externalTrafficPolicy: Local`, the load balancer only sends traffic to bare-metal servers that run a ready pod. Spread your pods across them, or run them as a DaemonSet, so no server sits idle. See [Preserve the client source IP](/docs/hetzner/apalla/network/load-balancing/preserve-client-source-ip#eliminate-the-in-cluster-hop-with-externaltrafficpolicy-local) and [Tune health checks for node replacement](/docs/hetzner/apalla/network/load-balancing/health-checks-and-node-replacement). For why you would run bare metal, and how to add it, see [Bare-metal nodes](/docs/hetzner/apalla/servers-and-nodes/bare-metal/overview) and [Add bare-metal servers](/docs/hetzner/apalla/servers-and-nodes/bare-metal/add-bare-metal-servers). ## Where to go next - [Tune health checks for node replacement](/docs/hetzner/apalla/network/load-balancing/health-checks-and-node-replacement) - [Preserve the client source IP](/docs/hetzner/apalla/network/load-balancing/preserve-client-source-ip) - [Serve IPv6 clients](/docs/hetzner/apalla/network/load-balancing/serve-ipv6) For where load balancers sit in the wider networking picture, see [Networking](/docs/hetzner/apalla/concepts/internals/networking).