Interview's MateKubernetes
Interview's Mate

Kubernetes

K8s · Workloads · GitOps · Cloud

Visualizer

DSA Visualizer
All 32 lessons
Custom Playground
Try your own examples

Learning

System Design
31 architecture topics
SQL Learning
160 foundations → production topics
AI Engineering
160 LLM → backend topics
Data Science
160 Python → MLOps topics
Data Engineer
160 SQL → streaming topics
Docker
160 Docker learning topics
Kubernetes
160 K8s fundamentals → cloud
Java LearnSoon
Coming soon
Python Learn
Interview Q&A & internals
JavaScript Learn
Closures, async & DOM Q&A
Tech Learn
Search, practise & track Q&A
AI DSA Practice
Solve coding problems
Theme
Home
Kubernetes topics
Lesson 56/ 160
03. Kubernetes Networking & Traffic Management

Zero-Trust Default-Deny Network Policies

Start from default-deny and explicitly allow only required east-west flows.

AdvancedDefault-Deny · Zero Trust · Allowlists3 quiz questions
Practice DevOps Q&A
In plain wordsDiagramTheoryStep by stepWhen to use itInterview cluesMistakes to avoidQuiz (3)Practice

In plain words

Default-deny is issuing no hallway keys at move-in and then granting each team only the doors its work proves it needs. The simple Kubernetes rule is: A zero-trust baseline selects all Pods with default-deny ingress and egress, then adds the minimum rules for DNS, platform endpoints, and observed service flows.

Think of it like…

Default-deny is issuing no hallway keys at move-in and then granting each team only the doors its work proves it needs.

Where you’ve seen it

During a connectivity incident, the network owner runs kubectl apply -f default-deny.yaml; kubectl get netpol -A. Expected evidence: A zero-trust baseline selects all Pods with default-deny ingress and egress, then adds the minimum rules for DNS, platform endpoints, and observed service flows. If the run instead shows this symptom, stop and restore the last known state: Allowing app-to-app traffic while forgetting UDP and TCP port 53 for CoreDNS leaves only a portion of connectivity functional.

Words you’ll hear

Default-Deny
For this lesson, Default-Deny is the controlling idea: A zero-trust baseline selects all Pods with default-deny ingress and egress, then adds the minimum rules for DNS, platform endpoints, and observed service flows.
Zero Trust
Zero Trust is the checkpoint; run kubectl apply -f default-deny.yaml; kubectl get netpol -A and inspect the owner chain. Allowing app-to-app traffic while forgetting UDP and TCP port 53 for CoreDNS leaves only a portion of connectivity functional.
Allowlists
Allowlists is the outcome to preserve; the cost is explicit: Default-deny shrinks blast radius, but it creates an operational dependency on complete inventories, Git-reviewed allowlists, and policy-capable CNI behavior.
Verification evidence
The evidence command is kubectl apply -f default-deny.yaml; kubectl get netpol -A. It connects the declaration to this behavior: Start from default-deny and explicitly allow only required east-west flows.

Visual diagram

Loading interactive diagram

Theory & deep dive

How Default-Deny reaches the intended state

Start from default-deny and explicitly allow only required east-west flows. A zero-trust baseline selects all Pods with default-deny ingress and egress, then adds the minimum rules for DNS, platform endpoints, and observed service flows.

The concrete checkpoint is kubectl apply -f default-deny.yaml; kubectl get netpol -A; compare the Default-Deny owner, Zero Trust state, and Allowlists outcome instead of treating YAML acceptance as proof.

Verify Zero Trust, not only object creation

Run kubectl apply -f default-deny.yaml; kubectl get netpol -A after the change and correlate the result with Events and the owning object. A zero-trust baseline selects all Pods with default-deny ingress and egress, then adds the minimum rules for DNS, platform endpoints, and observed service flows.

Key takeaway: Default-Deny is implemented only when this invariant remains observable: A zero-trust baseline selects all Pods with default-deny ingress and egress, then adds the minimum rules for DNS, platform endpoints, and observed service flows.

Zero Trust: failure boundary and production cost

Allowing app-to-app traffic while forgetting UDP and TCP port 53 for CoreDNS leaves only a portion of connectivity functional. The prerequisite contract is concrete: A zero-trust baseline selects all Pods with default-deny ingress and egress, then adds the minimum rules for DNS, platform endpoints, and observed service flows.

Default-deny shrinks blast radius, but it creates an operational dependency on complete inventories, Git-reviewed allowlists, and policy-capable CNI behavior. A safe design limits blast radius, records the last good configuration, and uses kubectl apply -f default-deny.yaml; kubectl get netpol -A as a deterministic rollback checkpoint.

Recover from Zero Trust drift

Capture the current state with kubectl apply -f default-deny.yaml; kubectl get netpol -A, then correct the controlling manifest rather than patching a child object; the relevant divergence signal is specific: Allowing app-to-app traffic while forgetting UDP and TCP port 53 for CoreDNS leaves only a portion of connectivity functional.

Key takeaway: Accept the trade-off consciously: Default-deny shrinks blast radius, but it creates an operational dependency on complete inventories, Git-reviewed allowlists, and policy-capable CNI behavior.

How it works, step by step

Step 1 of 4
Traffic author

1. Define the reachability contract

Declare selectors, listeners, routes, or policy and keep endpoint readiness explicit: A zero-trust baseline selects all Pods with default-deny ingress and egress, then adds the minimum rules for DNS, platform endpoints, and observed service flows.

Default-Deny contract → owned state
Key numbers at this step
Goal
Start from default-deny and explicitly allow only required east-west flows.
Owner
Default-Deny

When to use it & trade-offs

What it is

Start from default-deny and explicitly allow only required east-west flows. A zero-trust baseline selects all Pods with default-deny ingress and egress, then adds the minimum rules for DNS, platform endpoints, and observed service flows.

Why it matters: Allowing app-to-app traffic while forgetting UDP and TCP port 53 for CoreDNS leaves only a portion of connectivity functional. The invariant at risk is specific: A zero-trust baseline selects all Pods with default-deny ingress and egress, then adds the minimum rules for DNS, platform endpoints, and observed service flows. The quickest fact check before changing the design is kubectl apply -f default-deny.yaml; kubectl get netpol -A.

When to reach for it

  • Use Default-Deny to enforce this invariant: A zero-trust baseline selects all Pods with default-deny ingress and egress, then adds the minimum rules for DNS, platform endpoints, and observed service flows.
  • Use Zero Trust evidence from kubectl apply -f default-deny.yaml; kubectl get netpol -A in reviews and incident timelines. Start from default-deny and explicitly allow only required east-west flows.
  • Choose the managed ingress or mesh route only when this cost is justified by governance or scale: Default-deny shrinks blast radius, but it creates an operational dependency on complete inventories, Git-reviewed allowlists, and policy-capable CNI behavior.

When to avoid or be careful

  • Avoid assuming Default-Deny is complete after YAML submission; the required behavior is concrete: A zero-trust baseline selects all Pods with default-deny ingress and egress, then adds the minimum rules for DNS, platform endpoints, and observed service flows.
  • Avoid treating the next symptom as random; check the owner and state with kubectl apply -f default-deny.yaml; kubectl get netpol -A first: Allowing app-to-app traffic while forgetting UDP and TCP port 53 for CoreDNS leaves only a portion of connectivity functional.
  • Avoid adopting a heavier platform wrapper before measuring its cost: Default-deny shrinks blast radius, but it creates an operational dependency on complete inventories, Git-reviewed allowlists, and policy-capable CNI behavior.

Native, manual, and managed paths for Default-Deny

Built-in API path
Best for: Start from default-deny and explicitly allow only required east-west flows. A concrete incident check is kubectl apply -f default-deny.yaml; kubectl get netpol -A.

Strengths: A zero-trust baseline selects all Pods with default-deny ingress and egress, then adds the minimum rules for DNS, platform endpoints, and observed service flows.

Watch out: Default-deny shrinks blast radius, but it creates an operational dependency on complete inventories, Git-reviewed allowlists, and policy-capable CNI behavior. Recovery must also recognize this signal: Allowing app-to-app traffic while forgetting UDP and TCP port 53 for CoreDNS leaves only a portion of connectivity functional.

Datapath-specific extension
Best for: Quickly testing the Zero Trust assumption with kubectl apply -f default-deny.yaml; kubectl get netpol -A; the expected invariant is: A zero-trust baseline selects all Pods with default-deny ingress and egress, then adds the minimum rules for DNS, platform endpoints, and observed service flows.

Strengths: kubectl apply -f default-deny.yaml; kubectl get netpol -A gives immediate feedback without first building a platform layer.

Watch out: A manual change can hide drift, and unlike Default-Deny, it does not make this symptom self-documenting: Allowing app-to-app traffic while forgetting UDP and TCP port 53 for CoreDNS leaves only a portion of connectivity functional.

Managed ingress or mesh
Best for: Teams that need Allowlists integrated with guardrails; the evidence path is kubectl apply -f default-deny.yaml; kubectl get netpol -A.

Strengths: Platform controls can wrap this exact behavior in policy or dashboards: A zero-trust baseline selects all Pods with default-deny ingress and egress, then adds the minimum rules for DNS, platform endpoints, and observed service flows.

Watch out: The added platform ownership buys value at this cost: Default-deny shrinks blast radius, but it creates an operational dependency on complete inventories, Git-reviewed allowlists, and policy-capable CNI behavior.

Interview signals & numbers to know

When this topic comes up

  • Interview anchor: A zero-trust baseline selects all Pods with default-deny ingress and egress, then adds the minimum rules for DNS, platform endpoints, and observed service flows.
  • Trace Default-Deny to Allowlists through Zero Trust; the invariant is: A zero-trust baseline selects all Pods with default-deny ingress and egress, then adds the minimum rules for DNS, platform endpoints, and observed service flows.
  • Recognize the symptom: Allowing app-to-app traffic while forgetting UDP and TCP port 53 for CoreDNS leaves only a portion of connectivity functional.
  • Justify the cost: Default-deny shrinks blast radius, but it creates an operational dependency on complete inventories, Git-reviewed allowlists, and policy-capable CNI behavior.
  • Verify with kubectl apply -f default-deny.yaml; kubectl get netpol -A instead of only inspecting YAML.

Benchmarks & rules of thumb

53 -
CoreDNS requires explicit port 53 UDP and TCP allows
2 -
deny policies cover ingress and egress
0 -
unlisted flows should be allowed in a mature baseline

Common mistakes & follow-ups

Common interview mistakes

  • Debugging only the child object misses the Default-Deny owner contract: A zero-trust baseline selects all Pods with default-deny ingress and egress, then adds the minimum rules for DNS, platform endpoints, and observed service flows.
  • Ignoring this telltale condition leads to unrelated changes: Allowing app-to-app traffic while forgetting UDP and TCP port 53 for CoreDNS leaves only a portion of connectivity functional.
  • Repeating kubectl apply -f default-deny.yaml; kubectl get netpol -A without an owner for remediation wastes retry cost. Default-deny shrinks blast radius, but it creates an operational dependency on complete inventories, Git-reviewed allowlists, and policy-capable CNI behavior.

Likely interviewer follow-ups

  • How would API output and runtime evidence prove this behavior: A zero-trust baseline selects all Pods with default-deny ingress and egress, then adds the minimum rules for DNS, platform endpoints, and observed service flows?
  • Which owner object, logs, and Events would you inspect for this symptom-Allowing app-to-app traffic while forgetting UDP and TCP port 53 for CoreDNS leaves only a portion of connectivity functional-?
  • At what threshold would this cost become unacceptable: Default-deny shrinks blast radius, but it creates an operational dependency on complete inventories, Git-reviewed allowlists, and policy-capable CNI behavior?
Interview tip: Interview sequence: state the invariant, run kubectl apply -f default-deny.yaml; kubectl get netpol -A, name the failure, then justify the cost. Invariant: A zero-trust baseline selects all Pods with default-deny ingress and egress, then adds the minimum rules for DNS, platform endpoints, and observed service flows. Failure: Allowing app-to-app traffic while forgetting UDP and TCP port 53 for CoreDNS leaves only a portion of connectivity functional. Cost: Default-deny shrinks blast radius, but it creates an operational dependency on complete inventories, Git-reviewed allowlists, and policy-capable CNI behavior.

Knowledge check

Loading quiz

Put it into practice

Practice related interview Q&A

Apply Zero-Trust Default-Deny Network Policies with generative AI interview Q&A and hands-on practice.

Open DevOps Q&A →Tech Learn Q&A
Previous topic
NetworkPolicies: Layer 3/4 Micro-Segmentation (Ingress & Egress Rules)
Next topic
ExternalDNS for Automatic Cloud DNS Record Management