Question
Create a NetworkPolicy which allows ALL outgoing traffic to dev namespace.
Answer
Make sure you label the namespace dev with label name=dev. Create netpol:
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: allow-to-ns
spec:
podSelector: {}
policyTypes:
- Egress
egress:
- to:
- namespaceSelector:
matchLabels:
name: dev
Apply and verify:
kubectl apply -f netpol.yaml
kubectl describe netpol allow-to-ns