【发布时间】:2021-01-14 08:15:09
【问题描述】:
我对全球网络策略的这种行为感到困惑。采取以下措施。
apiVersion: projectcalico.org/v3
kind: GlobalNetworkPolicy
metadata:
name: allow-dns-for-all-policy
spec:
namespaceSelector: has(projectcalico.org/name) && projectcalico.org/name not in {"kube-system", "calico-system"}
order: 0
egress:
# allow all namespaces to communicate to DNS pods
- action: Allow
protocol: UDP
destination:
ports:
- 53
ingress:
- action: Allow
当我在“测试”命名空间中从一个 pod 到另一个 pod 执行 wget 时,它显然可以解析 dns 但不返回包:
Resolving nginx-test (nginx-test)... 10.233.8.253
Connecting to nginx-test (nginx-test)|10.233.8.253|:80... failed: Connection timed out.
集群上没有其他策略,尤其是没有默认拒绝策略。我也没有使用 namespaceSelector 进行测试。只有当我添加第二个匹配 * 的 Allow 规则时,或者当我删除整个策略时,我才能成功返回。
这是为什么呢?我原以为此策略对通信没有影响,因为不存在 DENY 规则。
【问题讨论】:
标签: nginx kubernetes calico