EKS 全球网络策略默认拒绝,并带有 pod 例外



目前我有一个全球网络政策'默认拒绝'来限制集群中的所有流量,所有入口/出口都设置为拒绝all((。

我试图使用"order"允许某些标签 pod 的例外。 当我不指定"action"参数以允许所有通信时,策略有效。 尽管如下所述,当我在允许中指定参数时,pod 不允许出口流量。

apiVersion: projectcalico.org/v3
kind: GlobalNetworkPolicy
metadata:
name: allow-pod-ingress
spec:
order: 50
selector: name == 'egresspod'
types:
- Egress
ingress:
- action: Allow
protocol: TCP
source:
selector: some-pod-label == 'some-pod-label-value'
destination:
ports:
- 80

此策略配置是否正确?

类型:必须与规范匹配。已将其设置为"出口",同时定义了入口规则。

如果希望 egresspod 接受端口 80 上的入站流量,请尝试将类型更改为入口。(如果要实现相反的效果,请将两者更改为"出口"。

apiVersion: projectcalico.org/v3
kind: GlobalNetworkPolicy
metadata:
name: allow-pod-ingress
spec:
order: 50
selector: name == 'egresspod'
types:
- Ingress #Has to match
ingress:  # With this guy.
- action: Allow
protocol: TCP
source:
selector: some-pod-label == 'some-pod-label-value'
destination:
ports:
- 80

有关更多信息,请查看此页面:https://docs.projectcalico.org/v3.7/reference/calicoctl/resources/globalnetworkpolicy

最新更新