NetworkPolicy — network rules in Kubernetes.
1apiVersion: networking.k8s.io/v12kind: NetworkPolicy3metadata:4 name: deny-all5 namespace: production6spec:7 podSelector: {}8 policyTypes:9 - Ingress10 - Egress11---12apiVersion: networking.k8s.io/v113kind: NetworkPolicy14metadata:15 name: allow-frontend16 namespace: production17spec:18 podSelector:19 matchLabels:20 app: backend21 ingress:22 - from:23 - podSelector:24 matchLabels:25 app: frontend26 ports:27 - protocol: TCP28 port: 808029 egress:30 - to:31 - podSelector:32 matchLabels:33 app: database34 ports:35 - protocol: TCP36 port: 5432
Why: