Practice Exams:

Network Policies: Security Depends on the CNI You Actually Run

 

Kubernetes NetworkPolicy is a powerful example of declarative intent that depends on an implementation. You can create a perfectly valid NetworkPolicy object and see it stored by the API server even when the cluster network does not enforce that policy. The security outcome therefore depends not only on the YAML but on the CNI or network implementation that turns the policy into packet filtering.

This matters because Kubernetes networking is generally open between Pods unless something deliberately restricts it. A NetworkPolicy selects Pods and defines allowed ingress, egress, or both. Once a selected Pod becomes isolated for a direction, traffic not allowed by the applicable policies for that direction is denied. But that behavior only exists if the networking solution supports and enforces NetworkPolicy.

The operational lesson is broader than one API. Security controls should be verified by behavior. Seeing an object in the cluster proves that desired policy was declared; it does not prove that packets are actually being blocked where the organization expects.

NetworkPolicy is application-centric allow policy

A NetworkPolicy uses a podSelector to choose the Pods to which it applies within its namespace. Rules can then allow traffic from or to selected Pods, selected namespaces, or IP blocks, with ports and protocols where appropriate. Policies are additive: multiple policies can contribute allowed traffic for the same Pod.

That additive model means there is no “deny rule” that overrides an allow from another applicable policy. The effective result is the union of allowed flows for the isolated direction. Administrators need to understand all policies selecting a Pod rather than reading one file and assuming it describes the complete behavior.

People learning Kubernetes networking for CKA administration should practice answering two questions first: which Pods are selected, and for which traffic direction have those Pods become isolated?

Isolation begins when a policy selects the Pod for that direction

A Pod is not automatically isolated just because a NetworkPolicy exists somewhere in the namespace. The policy has to select that Pod, and the policyTypes or rule fields determine whether ingress, egress, or both are governed. This is why a “default deny” policy is normally expressed by selecting all Pods with an empty podSelector and allowing no traffic for the relevant direction.

Once isolation applies, explicit allowed flows become important. A database policy may allow ingress from application Pods but forget health-check traffic. An egress policy may allow an API endpoint but forget DNS resolution. The resulting failure can look like an application outage even though the security control is behaving exactly as configured.

The best policy design starts from required communication paths. Security comes from a small, explainable allow set, not from adding rules until an outage stops.

The CNI determines whether the declared policy has any effect

Kubernetes documentation is explicit that NetworkPolicy enforcement is implemented by the network plugin. If the chosen networking solution does not support NetworkPolicy, creating the resource has no effect. That makes the CNI a security dependency, not merely a connectivity component.

Different implementations can also offer capabilities beyond the built-in API. Those extensions may be useful, but they should not be confused with portable Kubernetes NetworkPolicy semantics. A cluster migration can change what proprietary policies mean even when the standard objects remain valid.

The broader discipline described in communication and network security applies here: the organization needs to understand where enforcement occurs, what traffic the control can see, and how the control is validated rather than relying only on configuration intent.

Selectors turn labels into a security boundary

podSelector and namespaceSelector make labels part of the security decision. If a policy allows traffic from namespaces labeled team=payments, a mistaken or overly broad namespace label can expand access. If application labels drift, the intended Pods may no longer match the policy at all.

This makes label governance a security concern. Teams should know who can change the labels that policies trust and whether admission controls protect important label keys. A policy based on mutable metadata is only as strong as the process that governs that metadata.

Namespace selectors and pod selectors can also be combined. The details matter because “Pods with label role=frontend in namespaces labeled environment=prod” is a different security statement from two separate allowed sources that independently match either condition.

Egress policy often fails first at DNS and shared dependencies

Restricting egress sounds simple until the workload’s dependencies are enumerated. Most applications need DNS. They may also need identity providers, package repositories, telemetry collectors, time services, external APIs, or database endpoints. Denying everything except the obvious business destination can break a workload before it attempts its primary connection.

DNS is particularly instructive because applications often report only that a hostname cannot be reached. The root cause may be that the Pod cannot send queries to the cluster DNS service. A narrow egress policy must therefore include the name-resolution path that the application actually uses.

This is where cloud security operations becomes practical: policy design requires dependency discovery, logging, testing, and change control, not just a theoretical least-privilege diagram.

Service translation and IP-based rules can create implementation-dependent edges

NetworkPolicy is defined around traffic to and from Pods, but Service networking can translate addresses before packets reach the enforcement point. For example, an external client may reach a Service address that is then translated to a Pod address. The source IP visible to policy can depend on the network path and implementation.

That is why IPBlock rules deserve care. They are useful for CIDR-based traffic, but operators should verify how the chosen platform handles source and destination translation around Services, load balancers, and nodes. A policy that assumes an original client IP will always be visible may behave differently behind a particular load-balancer or proxy path.

The safe approach is empirical: document the intended source and destination identities, then test the actual traffic as it traverses the platform that will run in production.

Policy rollout should be staged because a deny-by-default posture changes failure behavior immediately. One safe method is to inventory required flows first, apply policy in a non-production namespace or representative environment, and verify both expected successes and expected denials. A policy that only tests the “allow” cases can still leave accidental paths open.

Observability matters after deployment. Flow logs or CNI-specific visibility can help explain why a packet was allowed or denied, especially when multiple policies select the same Pods. Standard Kubernetes events do not provide a complete per-packet audit trail, so teams should know which data-plane tools can prove enforcement in their chosen implementation.

NetworkPolicy is also limited in scope. It primarily addresses layer 3 and layer 4 traffic for Pods. Application-layer authorization, mTLS identity, API permissions, and egress governance for richer protocols may require additional controls. A strong design uses NetworkPolicy for the boundary it can actually enforce instead of assuming it replaces every other security layer.

Test policies from the same places real traffic originates

A useful verification exercise creates a server Pod and several client Pods with different labels and namespaces. Confirm connectivity before policy, apply isolation, then add only the intended allows. Test both successful and denied flows. If egress is restricted, verify DNS separately from the application endpoint.

Do not stop at inspecting the NetworkPolicy object. If a supposedly denied connection still succeeds, check whether the Pod is actually selected, whether another policy allows the flow, and whether the CNI supports enforcement. If an allowed connection fails, separate policy from Service, DNS, and application readiness problems.

This evidence-driven style is also central to Kubernetes work beyond the CKA: security controls are operational systems that need tests, ownership, and observability.

Policy ownership should be explicit because network access is shared responsibility between application and platform teams. Application owners know which dependencies are legitimate; platform teams know how the CNI implements policy and how cluster services such as DNS are addressed. If one team writes policy without the other, rules often become either overly permissive or brittle. A review process that captures the business purpose of each allowed path makes later cleanup safer because an old CIDR or namespace selector can be traced to the dependency it was meant to support.

Change management matters because network policy failures can look indistinguishable from application failures to end users. Rolling out a new egress restriction during an unrelated deployment complicates diagnosis and rollback. Teams should version policies, review diffs, and know which release introduced each connectivity change. That discipline also helps security teams prove that an allowed path was intentional rather than an accidental exception that survived because nobody knew why it existed.

CKA practice should connect policy intent to packet behavior

The current CKA exam includes Services & Networking as a major domain, and NetworkPolicy is most useful when treated as part of the traffic path rather than as a standalone manifest. A candidate should be able to identify selected Pods, required flows, the policy direction, and the network implementation responsible for enforcement.

That same model matters across CNCF certifications. A policy object represents the desired security boundary; the CNI and data plane make the boundary real. Strong administration connects those two layers and validates the outcome from the perspective of the workloads that rely on it.

Security therefore depends on the CNI you actually run, the labels you actually govern, and the dependencies your applications actually use. NetworkPolicy becomes trustworthy only when those implementation details are part of the design instead of assumptions left outside the YAML.

Related Posts

• Start With Risk When Choosing Security Controls

• Why Azure VNets Fail: Address Spaces, Routes, and DNS

• NSGs, ASGs, and Azure Firewall: Put the Control in the Right Place

• Troubleshoot an Azure VM Before You Redeploy It

• Wireless Roaming, Channels, and the Physics of a Good WLAN

• Inside a Well-Designed Small Enterprise Network

• Prompt Management Becomes an Engineering Problem at Scale

• CI/CD for Prompts, Models, and AI Logic

• High Availability Is a System Property

• Multicast Without Mystery