Explore our new Cybersecurity Terms Glossary, explained by our experts.

View the Glossary View the Glossary
PRIVIA

Cybersecurity Terms Glossary

What Are Kubernetes Network Policies?

A Kubernetes NetworkPolicy controls which pods may talk to which. Without one, every pod in the cluster can reach every other pod, on every port.

Illustration for the cybersecurity term Kubernetes Network Policies
Home / Blog / Cybersecurity Terms / What Are Kubernetes Network Policies?
17 November 2026

What Are Kubernetes Network Policies?

What Are Kubernetes Network Policies?

By default, a Kubernetes cluster is a flat network. Every pod can open a connection to every other pod, in every namespace, on every port, regardless of what the two workloads have to do with each other. A NetworkPolicy is the resource that changes that, specifying which traffic is permitted to and from a selected group of pods. For an attacker who has compromised a single container, the presence or absence of these policies is the difference between a contained incident and free movement across the cluster.

How the Resource Behaves

Policies are namespaced and select pods by label. The behaviour catches people out at first because it is allow-list based with a switch: a pod that no policy selects accepts all traffic, and a pod selected by any policy accepts only what that policy and any other policy selecting it permit. Policies are additive—there is no deny rule and no ordering—so the effective permission is the union of every policy that applies.

Each policy declares policyTypes of Ingress, Egress, or both, and omitting egress from a policy that only lists ingress rules leaves outbound traffic entirely unrestricted. Peers are selected by podSelector, namespaceSelector, or ipBlock, with ports and protocols attached.

Start With Default Deny

The standard pattern is to apply a default-deny policy per namespace and then permit what is needed:

apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: default-deny-all
  namespace: payments
spec:
  podSelector: {}
  policyTypes:
  - Ingress
  - Egress

With no rules listed, nothing is allowed. You then add policies permitting the application pods to receive traffic from the ingress controller, to reach their database, and to resolve DNS. That last one is the classic first failure: deny egress without allowing UDP and TCP port 53 to the cluster DNS service, and every workload in the namespace stops working in a way that takes an hour to diagnose.

Roll this out namespace by namespace, starting with the least critical. Where your network plugin supports a policy audit or logging mode, use it to observe what would have been dropped before you enforce.

Egress Deserves Equal Attention

Most teams write ingress rules and stop. Outbound control is what limits an attacker who already has code running inside a pod: command and control, data exfiltration, tool download, and reaching the cloud metadata endpoint described in our entry on the IMDS attack are all egress. Blocking the link-local range 169.254.169.254/32 for pods that do not need instance credentials is a short policy with a large effect.

The Plugin Has to Support It

Kubernetes defines the API; enforcement is the job of the container network interface plugin. Calico, Cilium, Antrea, and the managed network plugins in the major cloud providers all enforce policies. Flannel, in its default configuration, does not—it accepts the resources and silently ignores them, which produces the worst possible outcome: policies that appear to exist and enforce nothing. Confirm enforcement empirically on a new cluster by applying a deny policy and attempting the connection yourself.

Known Limitations

Keeping Them Honest

Generate policies from observed traffic where your tooling supports it, rather than writing them from an architecture diagram that is already out of date. Keep them in version control beside the workload manifests so a new dependency is added in the same pull request as the code that needs it. Test them in CI against the expected connections, and re-test after a cluster upgrade or a plugin change.

Finally, treat cluster segmentation as one layer within the broader design described in cloud network segmentation. A policy preventing pod-to-pod traffic is worth little if both pods hold cloud credentials that reach the same data through the provider API.

At Privia Security, we validate cluster segmentation by trying to cross it, through our cloud security services.

FAQ – Frequently Asked Questions

What Happens if I Apply No Network Policies at All?

Every pod can reach every other pod in the cluster, in any namespace, on any port. A single compromised container can scan the whole cluster, reach databases and internal APIs directly, and attempt to exploit anything it finds. That is the default behaviour of Kubernetes, not a misconfiguration, which is why a default-deny policy per namespace is one of the highest-value changes available.

Why Did Everything Break When I Applied Default Deny?

Almost always DNS. A default-deny policy that includes egress blocks resolution against the cluster DNS service, so every outbound connection fails in a confusing way. Add a policy permitting UDP and TCP port 53 to the DNS pods in kube-system before enforcing anything else, then add rules for each legitimate dependency one at a time.

Do Network Policies Work With Every CNI Plugin?

No. Calico, Cilium, Antrea, and the managed plugins from the major cloud providers enforce them. Flannel in its default configuration does not: it accepts the resources and ignores them, so policies appear to exist while enforcing nothing. Verify enforcement empirically on any new cluster by applying a deny rule and testing the connection rather than trusting the documentation.

Do I Need a Service Mesh as Well?

Only if you need what the mesh adds. Network policies give you layer 3 and 4 control by label, which covers most containment requirements. A mesh adds mutual TLS with cryptographic workload identity, layer 7 authorisation on paths and methods, and detailed traffic telemetry, at a significant operational cost. Start with network policies, and adopt a mesh when a specific requirement justifies it.

Related Terms

You May Be Interested In These

What Is the ROBOT Attack?

Cybersecurity Terms

17 November 2026

What Is the ROBOT Attack?

Read More
What Are Physical Access Control Systems?

Cybersecurity Terms

17 November 2026

What Are Physical Access Control Systems?

Read More
What Is Third-Party Risk Management?

Cybersecurity Terms

17 November 2026

What Is Third-Party Risk Management?

Read More