A pod selector identifies the pods governed by a NetworkPolicy by matching their labels. The selector appears under .spec.podSelector and determines where ingress or egress isolation applies. section 6.6
Use pod selectors to control policy scope:
- Leave .spec.podSelector empty ({}) to select every pod in the namespace, commonly for default-deny policies. section 6.6
- Combine multiple NetworkPolicies because their rules are additive; each policy can target different pods and policy types. section 6.6
Allow busybox to reach nginx
A NetworkPolicy with podSelector.matchLabels.run: nginx targets the nginx pod. Its ingress rule permits traffic from a pod selected by run: busybox on TCP port 80. A corresponding egress policy can select busybox and permit traffic to nginx.
