Skip to content

Force nftables usage when Talos Ingress Firewall is enabled #77

@ivanfed0t0v

Description

@ivanfed0t0v

There's a potential issue where Kubernetes components, such as kubelet and kube-proxy, are using legacy iptables, while the Talos Ingress Firewall is utilizing nftables. That means both x_tables and nf_tables kernel subsystems get used at the same time, which could potentially lead to unpredictable behavior or conflicts.

I've been able to track the cause of this down to kubelet base image:

FROM registry.k8s.io/build-image/debian-iptables:bookworm-v1.0.0 as container

On the first invocation of iptables in that image /usr/sbin/iptables-wrapper script gets run. That script decides between _legacy and _nft version of iptables, based on the length of the already created rules. If they are empty (which I think is the case when kubelet on Talos starts up) the script chooses legacy version:

$ docker run --rm -it registry.k8s.io/build-image/debian-iptables:bookworm-v1.0.0 iptables --version
iptables v1.8.9 (legacy)

To fix the issue please consider one of the following solutions:

  1. Force iptables-nft at build time in the Dockerfile:
update-alternatives --set iptables "/usr/sbin/iptables-nft"
update-alternatives --set ip6tables "/usr/sbin/ip6tables-nft"
  1. Use an image with updated version of /usr/sbin/iptables-wrapper which favors nftables. For example this one:
$ docker run --rm -it registry.k8s.io/build-image/distroless-iptables:v0.5.2 iptables --version
iptables v1.8.9 (nf_tables)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions