kubernetes - 多个网络策略规则是否按逻辑处理为 "and"规则或 "or"?

标签 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”
...

这是否意味着“role=db”标签的 pod 可以从以下位置接收连接:
  • 其他带有标签“role=frontend”和带有标签“project=myproject”的命名空间的pod;或
  • 其他带有标签“role=frontend”或带有标签“project=myproject”的命名空间的 pod。

  • 谢谢!

    最佳答案

    kubernetes network recipe "ALLOW traffic from apps using multiple selectors"清楚了:

    • Rules specified in spec.ingress.from are OR'ed.
    • This means the pods selected by the selectors are combined are whitelisted altogether.

    关于kubernetes - 多个网络策略规则是否按逻辑处理为 "and"规则或 "or"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49123203/

    相关文章:

    kubernetes - 如何在不删除 Pod 的情况下从服务中移除 Pod

    docker - Kubernetes - 未启用 - 桌面版 Docker(Windows 10)但 "kubectl cluster-info"可以工作吗?为什么?

    python - 从Google Composer( Airflow )检索Kubernetes的 secret

    kubernetes - GKE 中的容器无法 ping 同一网络上的计算实例

    kubernetes - Kubernetes Pod 无法建立 RTSP session ,UDP 端口不可达

    kubernetes - GKE Dataplane v2 NetworkPolicies 不工作

    kubernetes - 为Kubernetes命名空间设置部署锁定?

    kubernetes - 如何检查网络策略是否已应用于Pod?

    kubernetes - 使用 NetworkPolicy 将 "kube-system"命名空间列入白名单

    Kubernetes:Prometheus 上下文期限超过错误