Kubernetes Network Policy Egress only allow to certain IP and port Kubernetes Network Policy Egress only allow to certain IP and port kubernetes kubernetes

Kubernetes Network Policy Egress only allow to certain IP and port


I was not paying enough attention to multiple blocks for the cidr and ports. This is what I was looking for.

---apiVersion: networking.k8s.io/v1kind: NetworkPolicymetadata:    name: test-network-policy    namespace: devspec:    podSelector:      matchLabels:        app: plem-network-policy  policyTypes:  - Egress  egress:  - to:    - ipBlock:        cidr: 10.2.0.0/16    - ipBlock:        cidr: 10.3.0.10/32    ports:    - protocol: UDP      port: 53    - protocol: TCP      port: 53  - to:    - ipBlock:        cidr: 10.49.100.37/32    - ipBlock:        cidr: 10.49.100.137/32    - ipBlock:        cidr: 10.49.100.85/32    ports:    - protocol: TCP      port: 8200  - to:    - ipBlock:        cidr: 10.29.30.56/32    ports:    - protocol: TCP      port: 5439