Summary
v2.12.1 is a small bugfix release for the Network Policy Controller, with two fixes for problems in how it syncs iptables rules.
- The NPC no longer overwrites other programs' iptables rules - a full sync used to restore the entire filter table from an
iptables-savetaken earlier in that same sync, so any changes kube-proxy, flannel, or kube-router's service proxy made during the sync were lost. On k3s this could remove kube-proxy's jumps toKUBE-SERVICESandKUBE-FORWARD, and pods would then time out talking to the API server. The NPC now restores with--noflushand only writes the chains it owns (#1372). - Pods no longer get a partial set of policies during a sync - the NPC read pods from the informer several times during one sync, so a pod that got its IP partway through could match some policies and miss others. In practice, that usually meant
default-deny-allapplied withoutallow-dnsand DNS lookups got refused for a second or two. With--netpol-default-denyenabled, a pod could also be left open until the next sync. Each sync now reads a single snapshot of the pods.
Contributions
Thanks to @Aureliolo and @nikolay-e for both of these fixes, and to @Mahmoud-Masri for reporting and measuring the default deny exposure.
A special welcome to @Aureliolo and @nikolay-e on their first contributions!
Changelog
- b354adc - doc(NPC): add comment to make it obvious what skips non-kube-router rules
<Aaron U'Ren> - ff63faf - test(NPC): cover foreign references, dual-stack and backends in restore
<Aaron U'Ren> - 96efa30 - fix(Makefile): install iptables-legacy and nftables for test-privileged
<Aaron U'Ren> - 82167f3 - test(NPC): skip privileged iptables tests when iptables is missing
<Aaron U'Ren> - bee6b6f - fix(Makefile): install iptables for test-privileged in docker
<Aaron U'Ren> - f353f49 - fix(Makefile): run dirname once per privileged test file
<Aaron U'Ren> - 7062447 - fix(NPC): restore only its own chains so other rules aren't clobbered
<Aurelio> - 931deea - fix(NPC): drop ListPodsByNamespaceAndLabels, accept NamespaceAll
<Nikolay Eremeev> - b6309f1 - fix(NPC): pass the pod snapshot to its readers as a parameter
<Nikolay Eremeev> - 8d414ec - test(NPC): satisfy golangci-lint in the pod snapshot test
<Nikolay Eremeev> - 7046edd - fix(NPC): read one pod snapshot per full policy sync
<Nikolay Eremeev>