mirror of
https://github.com/floci-io/floci.git
synced 2026-11-22 21:50:46 -05:00
Pods running without hostNetwork: true run in isolated network namespaces managed by the CNI plugin (e.g. flannel in k3s). When pods send requests to link-local addresses such as IMDS (169.254.169.254:80), the packets reach the host node network namespace where CNI portmap installed -A PREROUTING -m addrtype --dst-type LOCAL -j CNI-HOSTPORT-DNAT. Because 169.254.169.254 is assigned to lo, the kernel evaluates its addrtype as LOCAL, causing non-host-network pods to misroute or drop link-local traffic if an ingress controller binds the same port. This introduces EksPodNetworkRouting and an opt-in configuration setting floci.services.eks.imds-pod-network (defaulting to false to preserve default pod network isolation). When enabled alongside floci.services.eks.imds, DNAT iptables rules are programmed in a dedicated FLOCI-LINK-LOCAL chain inserted at rule 1 of PREROUTING. Requests originating from the cluster pod CIDR targeting configured link-local endpoints (such as IMDS at 169.254.169.254:80, and extensible for Pod Identity at 169.254.170.23:80) are explicitly DNATed to the node's loopback listener, preempting CNI-HOSTPORT-DNAT without conflicting with CNI portmap or flannel routing. LinkLocalEndpoint strictly validates IPv4 literal format to reject non-IPs or malformed strings. Rules are idempotent and degrade gracefully if iptables configuration fails, ensuring cluster startup is never aborted.