In this article
Read selector grouping as a set operation and test partial matches, because valid YAML can permit a different peer population.
A model namespace should reach only a registry helper carrying a specific label inside an approved namespace. Moving a dash in a NetworkPolicy peer list can change that intersection into a union. The YAML remains valid, so syntax validation alone does not establish the intended set of permitted connections.
Name the intended set
Describe the allowed peers as Pods with the required label inside namespaces with the required label. Record the labels actually present on both object types. Namespace selection uses namespace labels, not a convenient interpretation of its name. A namespace name can be represented by the documented namespace label where appropriate, but the effective selector remains the source of truth.
Read a combined peer
A single peer entry containing namespaceSelector and podSelector selects Pods satisfying both parts. This expresses the intended intersection. Inspect the parsed list structure in the admitted object rather than reviewing only indentation in an editor. Both fields must belong to the same peer object for this meaning; visual proximity alone is insufficient evidence.
Read separate peer entries
Separate entries permit alternatives. A namespace-only peer admits Pods in the selected namespaces, while a pod-only peer selects matching Pods in the policy’s own namespace. Combining those alternatives does not mean matching Pods exclusively in selected remote namespaces. Review a small peer matrix to expose the unexpected local and remote cases before applying the policy.
Include the surrounding allow rules
NetworkPolicy permissions are additive. Another applicable rule can permit traffic that this carefully scoped peer does not. For a connection, relevant source egress and destination ingress must both allow it when isolated. Protocol and port conditions also matter. Verify a supporting network implementation rather than assuming accepted policy objects guarantee enforcement.
Test positive and negative peers
In an isolated fixture, vary namespace label and Pod label independently with a harmless endpoint. Test the intended match, each partial match and neither match. Observe fresh connections and the complete applicable policy set. Success establishes that selector structure produces the chosen allowed set; it does not provide application authentication, artifact integrity or a general-purpose rule for external registry addresses.
Primary references
Kubernetes Labels and Selectors.
Related reading: Pod stays unready after deny-all: init container network dependencies; Some DNS queries fail: why TCP and UDP port 53 both matter.
Earn rental income from GPUs
Have idle GPUs or looking to fund AI infrastructure? Retrivium finds a rental platform, sets up the server and helps you assess income and costs with a pilot.