官方截图: 三个from 代表三个策略的叠加
考题要求:
错误示范:
正确示范
点击查看 yaml 文件
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: allow-port-from-namespace
namespace: fubar
spec:
podSelector:
matchLabels: {}
policyTypes:
- Ingress
ingress:
- from:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: corp-net
podSelector:
matchLabels: {}
ports:
- protocol: TCP
port: 8080