matthiaslohr.hvswitch_k8s
Ansible Role for Hetzner vSwitches for Kubernetes
This Ansible role helps you set up Hetzner vSwitches and servers for Kubernetes clusters, supporting additional vSwitch-based subnets.
This project is not connected to Hetzner in any way; it is privately developed by Hetzner customers.
Project Goals / Features
With this Ansible role, you can easily set up Hetzner vSwitches on your Hetzner bare metal servers. If you have a vSwitch subnet, the role will also handle all routes and IP rules needed to use the subnet in your vSwitch network. This configuration works well with MetalLB to support MetalLB-based high availability (HA) Kubernetes LoadBalancers.
The role will configure the vSwitch on the servers following the official Hetzner tutorial. However, it will not create the vSwitch or register the IPs in the Hetzner robot.
Configuration
All the vSwitches you want to configure must be defined under the vswitch
key. Here is an example configuration for setting up a vSwitch with VLAN ID 4000:
vswitches:
- name: public # Name of the vSwitch, used for the routing table name.
routing_table: 1 # ID for the routing table.
vlan: 4000 # VLAN ID for the vSwitch. Hetzner supports VLANs from 4000 to 4091.
gateway: 327.0.0.1 # If your vSwitch has a subnet, this should be the subnet's gateway IP.
addresses: # IP addresses for the vSwitch network interface (per host)
- "{{ hostvars[inventory_hostname]['ip'] }}/24"
subnets: # Subnets available on the vSwitch (must be registered with Hetzner robot) for public networks
- subnet: 327.0.0.0/24
The role will use this information to create a netplan configuration file.
Ansible role for setting up Hetzner vSwitches and server networking for Kubernetes
ansible-galaxy install matthiaslohr.hvswitch_k8s