Skip to content

Commit b9a02f7

Browse files
authored
feat: Add use_nftables option, bump Kubernetes and addons (#40)
* feat: Add use_nftables option, bump Kubernetes and addons - Add `use_nftables` variable (default true) controlling kube-proxy mode and wigglenet's firewall backend; defaults give nftables on both, false falls back to iptables on both. Gate wigglenet's xtables-lock mount behind iptables mode. - Bump wigglenet to v0.6.1, Kubernetes default to v1.35.3, Hetzner CCM to v1.30.1, CSI driver to v2.20.0, sidecars updated to match. - Install nftables userland on all distros so admins can inspect rules regardless of the active backend. - Bump default server type from cpx31 to cpx32 across the module and all examples; bump tested Fedora image to fedora-43. - Fix `vars.hetzner_token` typo in examples/{simple,cloud_init,private_network}.tf. - README: drop stale ipvs/LoadBalancer hostname caveat, refresh example kubectl output to v1.35.3. * change server sku
1 parent 13b7b7c commit b9a02f7

17 files changed

Lines changed: 182 additions & 99 deletions

README.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@ and check the access by viewing the created cluster nodes:
6969
```cmd
7070
$ kubectl get nodes --kubeconfig=kubeconfig.conf
7171
NAME STATUS ROLES AGE VERSION
72-
k8s-control-plane-0 Ready control-plane 31m v1.34.1
73-
k8s-worker-0 Ready <none> 31m v1.34.1
74-
k8s-worker-1 Ready <none> 31m v1.34.1
72+
k8s-control-plane-0 Ready control-plane 31m v1.35.3
73+
k8s-worker-0 Ready <none> 31m v1.35.3
74+
k8s-worker-1 Ready <none> 31m v1.35.3
7575
```
7676

7777
## Supported base images
@@ -80,7 +80,7 @@ The module should work on most major RPM and DEB distros. It been tested on thes
8080

8181
- Ubuntu 24.04 (`ubuntu-24.04`)
8282
- Debian 13 (`debian-13`)
83-
- Fedora 42 (`fedora-42`)
83+
- Fedora 43 (`fedora-43`)
8484

8585
Others may work as well, but have not been tested.
8686

@@ -192,15 +192,13 @@ See [example](./examples/private_network.tf) for more details.
192192
Read these notes carefully before using this module in production.
193193

194194
- Control plane services that use host networking, such as etcd, kubelet and api-server bind on a public IP. This is not a problem per se since these components all use mTLS for communication, but appropriate Hetzner Firewall rules can be added (make sure to allow UDP port 24601 for Wireguard node-to-node tunnels)
195-
- Wigglenet is a custom network plugin with a smaller community than mainstream alternatives like Cilium or Calico. It has been used successfully for several years,
196-
though primarily in smaller-scale deployments. NetworkPolicy support was added in v0.5.0 and is relatively new, so don't use it as your only line of defense.
195+
- Wigglenet is a custom network plugin with a smaller community than mainstream alternatives like Cilium or Calico. It has been used successfully for several years, though primarily in smaller-scale deployments.
197196
- kubelet serving certificates are self-signed. This can be an issue for metrics-server. See [here for details and workarounds](https://kubernetes.io/docs/tasks/administer-cluster/kubeadm/kubeadm-certs/#kubelet-serving-certs).
198197
- Some restrictions on day-2 operations. The following are supported seamlessly, but other changes will likely require the manual steps:
199198
- Node replacement (see notes above for control plane nodes)
200199
- Vertical scaling of node (changing the server type)
201200
- Horizontal scaling (changing node count).
202201
- Changing cluster addons settings (Wigglenet firewall settings, Hetzner API token for the Hetzner CCM and CSI).
203-
- As kube-proxy is configured to use IPVS mode, `load-balancer.hetzner.cloud/hostname: <hostname>` must be set on all `LoadBalancer` services, otherwise healthchecks will fail and the service will not be accessible from outsie the cluster (see [this issue](https://github.com/kubernetes/kubernetes/issues/79783) for more details)
204202

205203
In addition some caveats for dual-stack clusters in general:
206204

addons.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ resource "null_resource" "install_addons" {
77
wigglenet_manifest = templatefile("${path.module}/templates/wigglenet.yaml.tpl", {
88
filter_pod_ingress_ipv6 = var.filter_pod_ingress_ipv6
99
native_routing_ipv4 = var.use_hcloud_network
10+
firewall_backend = var.use_nftables ? "nftables" : "iptables"
1011
})
1112
ccm_manifest = templatefile("${path.module}/templates/hetzner_ccm.yaml.tpl", {
1213
use_hcloud_network = var.use_hcloud_network

control_plane.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ resource "null_resource" "cluster_bootstrap" {
6565
service_cidr_ipv6 = var.service_cidr_ipv6
6666
primary_ip_family = var.primary_ip_family
6767
kubernetes_version = var.kubernetes_version
68+
kube_proxy_mode = var.use_nftables ? "nftables" : "iptables"
6869
})
6970
destination = "/root/cluster.yaml"
7071
}

examples/cloud_init.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ terraform {
1212
variable "hetzner_token" {}
1313

1414
provider "hcloud" {
15-
token = vars.hetzner_token
15+
token = var.hetzner_token
1616
}
1717

1818
resource "hcloud_ssh_key" "key" {
@@ -25,9 +25,9 @@ module "cluster" {
2525

2626
name = "k8s"
2727
hcloud_ssh_key = hcloud_ssh_key.key.id
28-
hcloud_token = vars.hetzner_token
28+
hcloud_token = var.hetzner_token
2929
location = "hel1"
30-
server_type = "cpx31"
30+
server_type = "cpx32"
3131
}
3232

3333
// After control plane is set up, additional workers can be joined
@@ -37,7 +37,7 @@ resource "hcloud_server" "instance" {
3737
ssh_keys = [hcloud_ssh_key.key.id]
3838
image = "ubuntu-20.04"
3939
location = "hel1"
40-
server_type = "cpx31"
40+
server_type = "cpx32"
4141

4242
user_data = module.cluster.join_user_data
4343
}

examples/ha_dns_name.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ module "cluster" {
3737
hcloud_ssh_key = hcloud_ssh_key.key.id
3838
hcloud_token = var.hetzner_token
3939
location = "nbg1"
40-
server_type = "cpx31"
40+
server_type = "cpx32"
4141
node_count = 3
4242

4343
control_plane_endpoint = "k8s.example.com"
@@ -53,7 +53,7 @@ module "workers" {
5353
hcloud_ssh_key = hcloud_ssh_key.key.id
5454
location = "nbg1"
5555

56-
server_type = "cpx31"
56+
server_type = "cpx32"
5757
}
5858

5959
resource "aws_route53_record" "api_server_aaaa" {

examples/ha_load_balancer.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ module "cluster" {
2828
hcloud_ssh_key = hcloud_ssh_key.key.id
2929
hcloud_token = var.hetzner_token
3030
location = "nbg1"
31-
server_type = "cpx31"
31+
server_type = "cpx32"
3232
node_count = 3
3333

3434
load_balancer_type = "lb11"
@@ -44,7 +44,7 @@ module "workers" {
4444
hcloud_ssh_key = hcloud_ssh_key.key.id
4545
location = "nbg1"
4646

47-
server_type = "cpx31"
47+
server_type = "cpx32"
4848
}
4949

5050
output "load_balancer_ipv4" {

examples/private_network.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ terraform {
1212
variable "hetzner_token" {}
1313

1414
provider "hcloud" {
15-
token = vars.hetzner_token
15+
token = var.hetzner_token
1616
}
1717

1818
resource "hcloud_ssh_key" "key" {
@@ -25,9 +25,9 @@ module "cluster" {
2525

2626
name = "k8s"
2727
hcloud_ssh_key = hcloud_ssh_key.key.id
28-
hcloud_token = vars.hetzner_token
28+
hcloud_token = var.hetzner_token
2929
location = "hel1"
30-
server_type = "cpx31"
30+
server_type = "cpx32"
3131

3232
# The default pod_cidr_ipv4 is 10.96.0.0/16. This can be customized,
3333
# but it should be within the range of the private network. Also, it should
@@ -49,7 +49,7 @@ module "workers" {
4949
hcloud_ssh_key = hcloud_ssh_key.key.id
5050
location = "hel1"
5151

52-
server_type = "cpx31"
52+
server_type = "cpx32"
5353

5454
use_hcloud_network = true
5555
hcloud_network_id = hcloud_network.my_net.id

examples/simple.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ terraform {
1212
variable "hetzner_token" {}
1313

1414
provider "hcloud" {
15-
token = vars.hetzner_token
15+
token = var.hetzner_token
1616
}
1717

1818
resource "hcloud_ssh_key" "key" {
@@ -25,9 +25,9 @@ module "cluster" {
2525

2626
name = "k8s"
2727
hcloud_ssh_key = hcloud_ssh_key.key.id
28-
hcloud_token = vars.hetzner_token
28+
hcloud_token = var.hetzner_token
2929
location = "hel1"
30-
server_type = "cpx31"
30+
server_type = "cpx32"
3131
}
3232

3333
module "workers" {
@@ -40,7 +40,7 @@ module "workers" {
4040
hcloud_ssh_key = hcloud_ssh_key.key.id
4141
location = "hel1"
4242

43-
server_type = "cpx31"
43+
server_type = "cpx32"
4444
}
4545

4646
output "simple_kubeconfig" {

modules/kubernetes-node/scripts/prepare-node.sh.tpl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ install_prerequisites() {
2020
# Install prerequisites
2121
apt-get -qq update
2222
apt-get -qq -y upgrade
23-
apt-get -qq -y install apt-transport-https ca-certificates curl gnupg lsb-release ipvsadm wireguard apparmor
23+
apt-get -qq -y install apt-transport-https ca-certificates curl gnupg lsb-release ipvsadm nftables wireguard apparmor
2424
curl -fsSL "https://download.docker.com/linux/$os_id/gpg" | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
2525
curl -fsSL "https://pkgs.k8s.io/core:/stable:/v${kubernetes_minor_version}/deb/Release.key" | gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
2626
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/$os_id $(lsb_release -cs) stable" \
@@ -55,15 +55,15 @@ EOF
5555

5656
if [ "$os_id" == "fedora" ]; then
5757
addrepo https://download.docker.com/linux/fedora/docker-ce.repo
58-
dnf -qy install containerd.io ipvsadm wireguard-tools iproute-tc
58+
dnf -qy install containerd.io ipvsadm nftables wireguard-tools iproute-tc
5959
elif [ "$(. /etc/os-release && echo "$PLATFORM_ID")" = "platform:el9" ]; then
6060
# Wireguard is installed by default on EL9-like systems
6161
addrepo https://download.docker.com/linux/centos/docker-ce.repo
62-
dnf -qy install containerd.io ipvsadm wireguard-tools iproute-tc
62+
dnf -qy install containerd.io ipvsadm nftables wireguard-tools iproute-tc
6363
else
6464
addrepo https://download.docker.com/linux/centos/docker-ce.repo
6565
dnf -qy install elrepo-release epel-release
66-
dnf -qy install containerd.io ipvsadm kmod-wireguard wireguard-tools iproute-tc
66+
dnf -qy install containerd.io ipvsadm nftables kmod-wireguard wireguard-tools iproute-tc
6767
fi
6868
fi
6969
}

modules/worker-node/variables.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ variable "hcloud_ssh_key" {
1313
}
1414

1515
variable "server_type" {
16-
description = "Server SKU (default: 'cpx31')"
16+
description = "Server SKU (default: 'cpx32')"
1717
type = string
18-
default = "cpx31"
18+
default = "cpx32"
1919
}
2020

2121
variable "image" {
@@ -51,7 +51,7 @@ variable "labels" {
5151
variable "kubernetes_version" {
5252
description = "Kubernetes version"
5353
type = string
54-
default = "1.34.1"
54+
default = "1.35.3"
5555

5656
validation {
5757
condition = can(regex("^1\\.([0-9]+)\\.([0-9]+)$", var.kubernetes_version))

0 commit comments

Comments
 (0)