Verify network enforcement
Separate API acceptance from enforcement
A valid YAML file can be rejected by the API; an accepted NetworkPolicy can be ineffective if the network implementation does not enforce it. Even with support, policy changes take time to reach the data plane. There is no generic NetworkPolicy status field proving that every node has applied the rule. Record the Kubernetes version, network implementation and version, data-plane mode, enabled policy features, address family and test scope before claiming enforcement.
YAML parsed -> API accepted -> implementation reconciled -> observed traffic matches intentRead configuration and establish a positive control
In a separately authorized disposable lab, inspect namespaces, Pod labels and policies using the explicit lab configuration. The following read-only commands are examples only; the fictional context is not present here. Confirm a known listening backend and a permitted client can communicate. A failed request could instead be a missing endpoint, DNS failure or application crash. Do not interpret a timeout alone as proof of policy enforcement.
kubectl --kubeconfig ./lab.kubeconfig --context policy-study get namespaces --show-labelskubectl --kubeconfig ./lab.kubeconfig --context policy-study -n shop-study get pods --show-labelskubectl --kubeconfig ./lab.kubeconfig --context policy-study -n shop-study describe networkpolicy api-ingressTest both allowed and denied flows
For each matrix row record source identity, target identity, destination port, protocol, expected result and observed result, with a bounded timeout. Use fresh connections from distinct authorized lab Pods and test UDP/TCP DNS independently. Check the positive control before interpreting a blocked flow. Repeat on relevant nodes and IP families, and test the actual Service path separately from a direct Pod path. Keep application authentication enabled. A successful allowed request plus a failed denied request is evidence only for those conditions, not every possible network path.
case expected observed (synthetic)frontend -> api TCP/8080 allow successother -> api TCP/8080 deny blockedfrontend -> resolver UDP/53 allow successKnow what the portable model omits
Policy behavior for hostNetwork Pods, node-originated traffic, non-TCP/UDP/SCTP protocols, address rewriting and existing connections can differ or be outside the portable API contract. NetworkPolicy is not a substitute for host firewalls, workload authentication, encryption or application-layer controls. Dual-stack clusters require separate evidence for both address families. Vendor policy CRDs can provide different scopes and precedence; do not assume their rules compose like standard NetworkPolicy. Check the selected implementation before relying on any extension.
Make a defensible decision
The verification fixtures use four invented outcomes. If the permitted request fails, diagnose application and network prerequisites before accepting the result. If the forbidden request succeeds, hold release and review the policy and implementation. Unknown enforcement support is also a hold. Even a candidate pass needs the full approved test matrix, version evidence and rollback plan. The checker evaluates these decision gates, not packets or CNI behavior.
positive success + negative blocked + known support = candidate passanything else = hold in this teaching gatePractice
Review verification-cases.json and write a short decision for every case. Include one reason that an accepted object might not filter traffic and one reason a failed connection might be unrelated to policy. Explain why a namespace alone is not network segmentation.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Verify network enforcement — knowledge check
Reason about synthetic segmentation and enforcement evidence.
What proves that a stored policy is enforced?
Both permitted and forbidden requests fail. What should you conclude?
The forbidden request succeeds. What is the next decision?
Which behavior requires implementation-specific verification?
Why test both IP families in a dual-stack environment?