Back to Blog

Kubernetes NetworkPolicy Isolation: Prove the Rules Work Before Relying on Them

September 19, 2026 8 min read
Kubernetes NetworkPolicy Isolation: Prove the Rules Work Before Relying on Them
Last updated:

Editorial slot: September 17, 2026. Published on September 19, 2026 after review.

The direct answer: a NetworkPolicy manifest is not proof of isolation. Before relying on it, prove four things in the target cluster: the installed network plugin enforces Kubernetes NetworkPolicy, the intended Pods are selected, required paths work, and disallowed paths are denied. Retain a small repeatable evidence set for each release or material policy change. Kubernetes states that creating a NetworkPolicy without a controller that implements it has no effect. Kubernetes Network Policies

This is a release-acceptance review for application isolation. It does not replace cloud security groups, node firewalls, service-mesh authorization, workload identity, API authorization, or host hardening. NetworkPolicy controls traffic to or from Pods at layer 3 or 4. Its actual behavior depends on the network implementation, so identical YAML can have different consequences in clusters with different CNIs or provider-specific policy objects.

Use a written scope and a nonproduction namespace that resembles production in labels, CNI mode, DNS, and admission controls. Create synthetic client, API, database, and denied-client workloads only with the cluster owner's approval. Do not begin by applying a broad default-deny policy to a shared production namespace. Blocking DNS, telemetry, or a service-availability dependency can turn an assurance exercise into an availability incident.

Four evidence stages for Policy intent, CNI support, Fresh traffic, Observed deny

First establish whether enforcement exists

Identify the cluster version, CNI and version, CNI configuration, policy mode, and any implementation-specific policy resources. Ask the platform owner for a documented confirmation that the installed plugin enforces Kubernetes NetworkPolicy in this cluster. The Kubernetes API accepting a NetworkPolicy object is not that confirmation. Kubernetes requires a networking solution with NetworkPolicy support, and says an object without an implementing controller has no effect. Kubernetes Network Policies

Inventory every policy selecting the target Pods. Include NetworkPolicy objects in the namespace, the Pods' current labels, namespace labels referenced by selectors, and any CNI-specific policies that can add or constrain behavior. Cilium, for example, documents support for Kubernetes NetworkPolicy and a separate CiliumNetworkPolicy resource. A review of Kubernetes YAML alone is incomplete where that resource is used. Cilium Kubernetes Network Policy

Treat labels as security configuration. A policy selecting app: payments-api protects only Pods that currently have that exact label. A deployment-template change, Helm value, or namespace migration can silently place a workload outside the selector. At each test, record the selected Pod names, labels, namespace, service account, and workload owner.

Convert architecture into an allow and deny matrix

Write expected flows before testing. A compact matrix makes the team name the direction, protocol, port, source identity, destination identity, and reason for each connection. Include DNS, telemetry, service-availability dependencies, and external egress where they are legitimate. “The application needs the network” is not an acceptance criterion.

Source workload Destination Direction and port Expected result Evidence
Synthetic frontend API service Pods Egress and ingress, TCP application port Allowed Bounded service-availability response
Synthetic API Test database Pods Egress and ingress, TCP database port Allowed only when in scope Approved connection result without credentials in logs
Synthetic denied client API service Pods Egress and ingress, TCP application port Denied Timed-out or refused test with policy and CNI evidence
API Pod Cluster DNS Egress, UDP and where required TCP 53 Allowed when names are required Lookup result and DNS rule record
API Pod Unapproved namespace or external address Egress Denied or an explicit exception Negative result or approved exception record

Ingress and egress isolation are independent. A Pod becomes isolated in a direction only when a selecting policy declares that direction. For standard Kubernetes NetworkPolicy resources, policies are additive, so the effective allowance is the union of applicable standard-policy allowances. For a Pod-to-Pod connection, source egress and destination ingress must both allow it; order does not decide the standard-policy result. CNI-specific and cluster-level policy resources can have their own documented precedence and deny semantics, so review those separately rather than inferring their behavior from this rule. Kubernetes Network Policies This is why a policy that appears restrictive can still permit a path through another matching rule.

Validate in a safe sequence

Start with object evidence: the policy documents, relevant CNI configuration, exact selectors, and target-Pod labels. Check that Services resolve to intended EndpointSlices or backend Pods before attributing a failure to policy. Bad routing, an unavailable endpoint, a wrong target port, or application authentication failure is not proof that NetworkPolicy denied a connection.

Next establish a DNS baseline from a synthetic source Pod. Kubernetes service-debugging guidance separates name lookup from service-IP connectivity and notes that a cross-namespace call may need a namespace-qualified or fully qualified Service name. Kubernetes Debug Services If DNS fails, investigate resolver configuration and the DNS service path before changing application policy. Do not open all egress merely to make a lookup succeed.

Test one intended path at a time with a harmless, pre-agreed service-availability response. Record the source Pod identity, destination Service and actual backend identity, timestamp, protocol and port, policy revision, and observed result. Follow it with one denied path from a synthetic workload that has no business relationship with the destination. The useful outcome is a clear allow/deny pair against the same destination and port, plus selection evidence that explains it.

A denial can be inconclusive. A timeout may result from policy, an unavailable endpoint, DNS, service routing, application failure, or the test tool. Mark it inconclusive until a separate safe check shows the target is available and reachable from an approved source. Conversely, one successful request does not prove every replica, namespace, protocol, or egress destination is covered. Test the agreed representative paths and retain the stated limits.

Stop conditions and rollout constraints

Stop immediately if an expected production-critical flow fails, DNS or telemetry becomes unavailable, the test selects Pods outside scope, or an unapproved path becomes reachable. Stop when CNI state cannot be identified, when a result needs production data or credentials to interpret, or when a policy would need broader access without an owner decision. Preserve minimal evidence, restore the approved configuration, and escalate through the application and platform change process.

Do not assume policy takes effect simultaneously everywhere. Kubernetes says a plugin can take time to handle a new NetworkPolicy, Pods can temporarily see different connectivity, and the Kubernetes API has no signal for the exact completion instant. Kubernetes Network Policies Automated checks should wait for a provider-supported readiness signal or a defined observation window before recording allow and deny results. After that window, make each TCP or UDP acceptance probe a fresh connection or flow; avoid persistent client sessions and connection pools for the acceptance result. Kubernetes defines the effect of changed policy on existing connections as implementation-dependent, so record any existing-session behavior separately when it matters to the design. A transient result is not stable proof of success or failure.

hostNetwork workloads need a separate decision. Kubernetes describes their NetworkPolicy behavior as undefined, with common implementations treating their traffic as node traffic. Node-origin traffic also has documented exceptions. Do not assume a namespace policy isolates node agents, host-network Pods, cloud load-balancer paths, or all control-plane dependencies. Kubernetes Network Policies

Remediate by reducing ambiguity

Fix missing enforcement before refining rules. If the CNI does not implement behavior the design needs, choose and validate a supported implementation with the platform owner. Next fix selectors: make workload labels stable, namespace labels intentional, and policy ownership clear. Add baseline isolation only after mapping DNS, service availability, observability, service-mesh, and approved egress dependencies.

For an unexpected allowed flow, find every policy selecting source and destination, then remove or narrow the rule permitting it. For standard Kubernetes NetworkPolicy resources, adding a restrictive policy does not cancel a broad allow because those policies combine additively. CNI-specific or cluster-level policies require the implementation's documented precedence and deny semantics. For an unexpected denied flow, check source egress and destination ingress separately, including protocol, named or numeric ports, namespace labels, Service routing, and the CNI's documented behavior. Web security helps when the flow exposes an API, but NetworkPolicy never replaces the API's authentication and object authorization.

Make the matrix part of change control. When a label, namespace, port, DNS provider, CNI version, service mesh, or external dependency changes, rerun the relevant pair of tests. Retain a concise release record with policy revision, selected workloads, allowed results, denied results, exceptions, reviewer, and residual limits. Reporting and risk helps turn the matrix, exceptions, owners, and residual limits into a review record that a release decision can use.

FAQ

Does creating a NetworkPolicy automatically block traffic? No. A supporting network plugin is required, and isolation is directional. Pods are non-isolated for ingress and egress by default until a selecting policy declares the relevant direction. Kubernetes Network Policies

Why did a default-deny rollout break DNS? A Pod selected for egress isolation can send traffic only through allowed egress rules. If it resolves Service names, include the actual DNS path and protocol in the reviewed matrix, then validate it separately from application connectivity. Kubernetes Debug Services

Can a denied test prove the policy works? Only if the destination is independently known to be healthy and the test is limited to a specific source, destination, port, and protocol. A timeout alone is inconclusive; pair it with approved-source success and selection evidence.

Vid Grosek

Vid Grosek

Ethical Hacker & Penetration Tester

I help Slovenian companies discover security vulnerabilities before attackers do. With 18+ years of experience in cybersecurity.

All Posts

Comments

No comments yet. Be the first!

Leave a Comment

Enjoyed this article?

Subscribe to the newsletter for monthly security insights.

Subscribe