多个网络策略规则是作为“与”规则还是“或”进行逻辑处理?

tes*_*ter 5 kubernetes kubernetes-networkpolicy

在声明网络策略的文档的基本示例中:https : //kubernetes.io/docs/concepts/services-networking/network-policies/#the-networkpolicy-resource

因此,根据文档,这设置了几条规则:

So, the example NetworkPolicy:

- isolates “role=db” pods in the “default” namespace for both ingress
and egress traffic (if they weren’t already isolated)
- allows connections to TCP port 6379 of “role=db” pods in the “default”
namespace from any pod in the “default” namespace with the
label “role=frontend”
- allows connections to TCP port 6379 of “role=db” pods
in the “default” namespace from any pod in a namespace with
the label “project=myproject”
...
Run Code Online (Sandbox Code Playgroud)

这是否意味着“role=db”标签的 pod 可以从以下位置接收连接:

  • 其他带有标签“role=frontend”和带有标签“project=myproject”的命名空间的pod;或者
  • 其他带有标签“role=frontend”或带有标签“project=myproject”的命名空间的 pod。

谢谢!

Von*_*onC 4

kubernetes 网络配方允许来自使用多个选择器的应用程序的流量很明确:

  • 中指定的规则spec.ingress.fromOR 'ed。
  • 这意味着选择器选择的 pod 会被组合在一起并被列入白名单。