Simple definition
A Kubernetes NetworkPolicy defines allowed network flows for selected pods when supported by the cluster networking plugin.
Purpose and use
A Kubernetes NetworkPolicy defines allowed network communication for selected pods in supported directions.
How does it work?
Selectors and rules describe permitted sources, destinations and ports. Effect requires a networking component that actually enforces policies.
Example and verification
After restricting egress, test required dependencies, including DNS and calls to permitted services.
Points to watch
Permissions from multiple policies can combine; object ordering is not a conventional ordered firewall rule list. Coverage depends on the network implementation.
In short
Follow policy declaration with actual tests of allowed and denied flows in the relevant cluster.