apiVersion: networking.k8s.io/v1 kind: NetworkPolicy metadata: name: my-network-policy spec: podSelector: matchLabels: role: db ingress: - from: - podSelector: matchLabels: app: db egress: - to: - namespaceSelector: matchLabels: app: web ports: - protocol: TCP port: 80