Repository navigation
k3s nftables rule of ingress controller bypasses host nftables #10693
Replies: 3 comments
|
These rules are all managed by kube-proxy. I would probably take your question upstream to the Kubernetes project. |
|
I think your document or k8s document should tell which tool should be used as firewall A few days ago when I added a rule using Second thing is if we try # Warning: iptables-legacy tables present, use iptables-legacy-save to see thembecause of these two, I tried |
|
I found great detail here KEP-3866: Add an nftables-based kube-proxy backend kube-proxy uses iptables but in its nftable API mode 1 -- which means the API being used is nftable but only iptables feature can be used . Kube-proxy has planned to move to nftable 2 |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
A new traefik entrypoint (5050/tcp) has been added via helm
The ingress-controller (traefik) should load-balance 5050/tcp to some pods (using ingressRouteTCP CRD) but not always. Sometime there is need to block all incoming ports.
The issue is that when the
inetchain of nftable policy set todropthe port5050/tcpis still accessibletable inet filter { chain input { type filter hook input priority filter; policy drop; iifname "lo" counter accept ct state invalid counter drop ip saddr 192.168.0.0/16 ip daddr 192.168.0.0/16 counter accept ct state invalid counter drop ct state established,related counter accept ip saddr a.b.c.d counter accept comment "server-nfs" ip saddr a.b.c.d counter accept comment "server-204" ip6 saddr 2a01:4f8:c012:e50d::1 counter accept tcp dport { 22, 80, 443, 989 } accept comment "ssh, http, https, xyz" } }further checking shows that k3s (or upstream k8s) nftable rules are added to
nattabletable ip nat { chain KUBE-SERVICES { meta l4proto tcp ip daddr 10.43.21.114 tcp dport 443 counter jump KUBE-SVC-CVG3OEGEH7H5P3HQ meta l4proto tcp ip daddr public-ip tcp dport 443 counter jump KUBE-EXT-CVG3OEGEH7H5P3HQ meta l4proto tcp ip daddr 10.43.0.10 tcp dport 53 counter jump KUBE-SVC-ERIFXISQEP7F7OF4 meta l4proto tcp ip daddr 10.43.0.10 tcp dport 9153 counter jump KUBE-SVC-JD5MR3NA4I4DYORP meta l4proto tcp ip daddr 10.43.49.240 tcp dport 443 counter jump KUBE-SVC-Z4ANX4WAEWEBLCTM meta l4proto tcp ip daddr 10.43.21.114 tcp dport 5050 counter jump KUBE-SVC-EYFF4NBLALWK2FPX meta l4proto tcp ip daddr 10.43.21.114 tcp dport 80 counter jump KUBE-SVC-UQMCRMJZLI3FTLDP meta l4proto tcp ip daddr public-ip tcp dport 80 counter jump KUBE-EXT-UQMCRMJZLI3FTLDP meta l4proto tcp ip daddr 10.43.0.1 tcp dport 443 counter jump KUBE-SVC-NPX46M4PTMTKRN6Y meta l4proto udp ip daddr 10.43.0.10 udp dport 53 counter jump KUBE-SVC-TCOU7JCQXEZGVUNU meta l4proto tcp ip daddr public-ip tcp dport 5050 counter jump KUBE-EXT-EYFF4NBLALWK2FPX fib daddr type local counter jump KUBE-NODEPORTS } }the cause are
because of these rules , the
filtertableinetchain is ignored andpolicy drophas no effect for80,443,5050or any other entrypointsI am curious why this way ?
It is possible to block these ports in
mangletable but filtering should be done infiltertable notmangleby the way if we delete the
natrule, a few minutes later the rule will be added tonattableAll reactions