如何验证集群网络策略 configuration/support

How to verify cluster network policy configuration/support

我正在尝试找出验证给定集群的网络策略配置的最佳方法。 According to the documentation

Network policies are implemented by the network plugin, so you must be using a networking solution which supports NetworkPolicy - simply creating the resource without a controller to implement it will have no effect.

假设我只能通过 kubectl 访问我的集群,我应该怎么做才能确保部署到集群中的网络策略资源得到遵守?

我知道可用的 CNI 和 related matrix capabilities
我知道您可以检查与那些 CNI 相关的部署在 kube-system 下的 pod,并使用 for ex 验证相关功能。我分享的矩阵,但我想知道是否有更结构化的方法来验证当前安装的 CNI 和相关功能。

关于"controller to implement it",有没有办法获取与网络策略相关的add-on/controller列表?

Which the best approach to verify the network policy configuration for a given cluster?

如果您有权访问 pods,您可以 运行 测试以确保您的 NetworkPolicies 是否有效。您可以通过两种方式查看:

  • 正在使用 kubectl 读取您的 NetworkPolicy (kubectl get networkpolicies)。
  • 正在测试您的端点以检查 NetworkPolicies 是否有效。

I wonder if there's a more structured approach to verify the current CNI installed and the related capabilities.

没有结构化的方法来检查您的 CNI。您需要了解 CNI 的工作原理才能在集群上识别它。以 Calico 为例,您可以通过检查 calico pods 是否 运行ning 来识别它。 (kubectl get pods --all-namespaces --selector=k8s-app=calico-node)

Regarding the "controller to implement it", is there a way to get the list of add-on/controller related to the network policy?

"controller to implement it" 是对您正在使用的 CNI 的引用。

有一个名为 Kubernetes Network Policies Viewer 的工具可以让您以图形方式查看您的 NetworkPolicy。这与您的问题无关,但它可能会帮助您可视化您的 NetworkPolicies 并了解它们在做什么。