我已在容器中启用特权模式并向其中添加规则,
iptables -N udp2rawDwrW_191630ce_C0
iptables -F udp2rawDwrW_191630ce_C0
iptables -I udp2rawDwrW_191630ce_C0 -j DROP
iptables -I INPUT -p tcp -m tcp --dport 4096 -j udp2rawDwrW_191630ce_C0
和kt exec
放入容器并使用iptables --table filter -L
,我可以看到添加的规则。
/ # iptables --table filter -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
udp2rawDwrW_191630ce_C0 tcp -- anywhere anywhere tcp dpt:4096
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Chain udp2rawDwrW_191630ce_C0 (1 references)
target prot opt source destination
DROP all -- anywhere anywhere
当我登录到容器所在的节点并运行sudo iptalbes --table filter -L
时,看不到相同的结果。
我在默认情况下考虑删除previleged
,因为容器可能会利用它来更改节点中的iptables之类的东西,但是看起来不是那样。
因此,我的问题是“ K8S iptables和Pod内的容器之一之间的关系是什么,以及“为什么我们要阻止用户在没有privileged
字段的情况下修改容器的iptables”?