apiVersion: networking.k8s.io/v1 kind: NetworkPolicy metadata: name: api-netpol spec: podSelector: matchLabels: app: api policyTypes: - Ingress - Egress ingress: - from: - podSelector: matchLabels: app: web ports: - port: 3000 protocol: TCP egress: - to: - podSelector: matchLabels: app: db ports: - port: 5984 protocol: TCP - to: - namespaceSelector: matchLabels: name: kube-system podSelector: matchLabels: k8s-app: kube-dns ports: - port: 53 protocol: UDP