What NetworkPolicy Identifies
It is important to be precise about what a NetworkPolicy can and cannot actually see and control, so you do not reach for it to solve a problem it was never designed to address. Policies identify traffic by Pod and namespace labels - they have no concept of a Service's name, and no concept of an authenticated human or application-level user identity; those are entirely different layers of the stack. It is also worth knowing that the source address a policy dataplane actually observes for a connection can be rewritten along the way by a load balancer, a node's own networking, or the CNI itself (for example, via SNAT - source address translation) - so the "source" your policy needs to match against is not always the same as the original client's real address, and this can produce confusing results if assumed otherwise. Most fundamentally, NetworkPolicy operates at layer 3/4 of the network stack - IP addresses, protocols, and ports - it has no visibility into HTTP methods, URL paths, request headers, or the content of traffic at all, and standard NetworkPolicy provides no encryption whatsoever. Anything requiring that finer-grained, application-layer control needs a purpose-built tool sitting above NetworkPolicy, like an API gateway, application-level authorization, or a service mesh with mutual TLS.
Analogy: Kubernetes is a thermostat, not a remote control. You declare the temperature; independent controllers measure reality and keep acting. Debugging means finding which sensor, rule or actuator prevents convergence.
Read the object as evidence
kubectl get RESOURCE NAME -n NAMESPACE -o yaml
kubectl describe RESOURCE NAME -n NAMESPACE
kubectl get events -n NAMESPACE --sort-by=.metadata.creationTimestamp
kubectl explain RESOURCE.spec
Do not memorize these as a ritual. The first command exposes desired and observed state, the second connects conditions and events, the third supplies a timeline, and the fourth checks the server's schema. Compare what the controller was asked to do with what it reports doing. Then test the narrowest hypothesis.
Scenario: A team wants a policy that allows only HTTP GET requests to a backend service, while blocking POST and DELETE - a perfectly reasonable-sounding security goal. NetworkPolicy can express "allow TCP traffic on port 8080" without any difficulty, but it fundamentally has no concept of an HTTP method at all, because that information lives inside the HTTP request itself, a layer above anything NetworkPolicy inspects. Achieving that specific goal requires an application-layer gateway or a service mesh capable of actually reading and filtering on HTTP semantics - NetworkPolicy alone can never express it, no matter how it is written.
Know what selectors cannot express
NetworkPolicy works at IP, protocol and port around Pod and namespace identity. It cannot authorize HTTP methods, JWT claims or Service names, and standard policy does not provide encryption. External traffic source addresses may be changed by load balancers or node forwarding, making ipBlock behavior implementation-dependent. Use an ingress gateway, application authorization or service mesh for higher-layer identity and mTLS.
Scenario: A policy allows traffic from the ingress-controller namespace, but the CNI observes the node IP after SNAT. Inspect the real dataplane source before widening the rule to the entire cluster.
Warning: Namespace names are not automatically selectable labels. Apply and protect an explicit namespace label used by policy.
Production reasoning
Ask four questions: Who owns this object? What dependency must become ready next? Which controller reports the blocking condition? What evidence would disprove my current theory? This prevents symptom-driven changes. Record the context, namespace, object generation, image digest and recent rollout before mutation; a recreated Pod may erase the evidence you needed.
Warning: Running is not the same as ready, healthy, durable or correct. Kubernetes status is layered. Confirm the application-level outcome as well as the object state.
Goal: Put this model into practice in the Kubernetes lab networkpolicy-kong-routing. Open/labs/kubernetes, choosenetworkpolicy-kong-routing, predict the failure path before changing anything, then use the simulator'scheckcommand to validate the finished state.
Deliberate practice
Before the lab, write the expected object relationship and the first three commands you will run. Afterward, explain why the fix converged and name one tempting change that would only mask the symptom. Repeat using an explicit namespace and a structured output format. This prediction-observation-explanation loop is what turns command familiarity into production judgment.
45-minute investigation
- Map (5 min): draw the owner-to-child chain and mark every namespace, selector, identity and dependency involved.
- Predict (5 min): write one expected status condition, one likely event and one log or metric signal before opening the lab.
- Observe (10 min): collect YAML, describe output and ordered events. Do not mutate state. Record which observation disproves your first theory.
- Repair (15 min): make the smallest declarative correction, watch the responsible controller converge, and verify the user-facing path rather than stopping at
Running. - Stress (10 min): change one relevant constraint - replica count, label, readiness, resource value or placement rule - predict the outcome, observe it, then restore the known-good declaration.
Tip: Keep a short incident note with symptom, evidence, hypothesis, change, result. Across four sections this produces a reusable runbook instead of a pile of remembered commands.