24 / 25 · Operations and recovery
Network segmentation
Network segmentation limits which systems may communicate across network boundaries. It reduces reachability and blast radius. It does not replace identity checks, encryption or resource-level authorization.
What you will practise
- Map required flows
- separate ingress/egress
- test allowed and denied paths
Before you start: Source, destination, port and application authorization.
About 4 minutes · offline-generated English female narration · captions included. Diagrams are conceptual; timings are illustrative.
Download MP4CaptionsListen without the video
Download audioChapters and full transcript
Let us understand network segmentation. A school separates the public reception, classrooms and locked records room. A visitor can enter reception without getting a path to every room. A classroom door being reachable still does not authorize reading a student file. Network access and application permission remain different checks. Network segmentation limits which systems may communicate across network boundaries. It reduces reachability and blast radius. It does not replace identity checks, encryption or resource-level authorization.
Follow the normal path. The public client needs the web tier, which needs booking. Booking needs the database. Record required ports and dependencies before introducing isolation. The unrelated worker has no business requirement to contact the orders database. Blocking that path reduces reachability and potential blast radius. SeatSpot public web traffic should not directly reach the orders database or administrative services. Booking may need a narrow database connection while an unrelated image worker does not.
Now change one condition. Permit the actual booking workload to use the configured database port. Broad namespace-wide rules may allow more callers than intended. A common misunderstanding is this: NetworkPolicy automatically works in every Kubernetes cluster. Enforcement depends on the network implementation and correct selector semantics. Think about this. A database port is reachable from a booking pod. Does that authorize every SQL operation? Pause the video and make your prediction. No. Network reachability is one boundary. Database credentials and application resource authorization still matter.
Let us reason with a concrete example. Only the booking workload should initiate the database application connection on its configured port. A rule allowing the whole namespace may expose more callers than intended; a narrower pod selector can express the required source if labels and enforcement are trustworthy. Test a permitted booking connection and a denied unrelated-worker connection. Also verify DNS and any cross-namespace behavior in the actual cluster. These figures are teaching examples, not production guarantees.
Turn the idea into a design decision. A policy object is only configuration intent. The cluster network implementation must support and enforce it, and selectors must match the intended workloads. An allowed TCP connection is not permission to read every order. Database credentials, encrypted transport and application ownership checks remain separate controls. When you try the practice task, look for this result. A supporting network implementation must actually enforce the policy; a YAML file alone proves nothing.
Check your understanding. Verify allowed traffic, denied traffic and necessary DNS/monitoring dependencies. Observe unexpected failures and refine the policy without silently opening everything. Here is a challenge. A pod has a NetworkPolicy but unwanted traffic still reaches it. What do you verify? Pause before the answer. Verify enforcement support, labels/selectors, namespace semantics, ingress/egress direction and other allowed rules. Test from the real source workload rather than only inspecting YAML. For an interview, discuss ingress, egress, DNS and actual connection tests. Say what you would measure, not only which tool you would buy.
Start with an everyday picture
A school separates the public reception, classrooms and locked records room. A visitor can enter reception without getting a path to every room. A classroom door being reachable still does not authorize reading a student file. Network access and application permission remain different checks.
Why SeatSpot needs this
SeatSpot public web traffic should not directly reach the orders database or administrative services. Booking may need a narrow database connection while an unrelated image worker does not.
Trace one step at a time
Move through the diagram at your pace. Teal paths are active; unavailable components are labelled.
Map required flows
The public client needs the web tier, which needs booking. Booking needs the database. Record required ports and dependencies before introducing isolation.
Read all six mechanism steps
Map required flows
The public client needs the web tier, which needs booking. Booking needs the database. Record required ports and dependencies before introducing isolation.
Remove unnecessary paths
The unrelated worker has no business requirement to contact the orders database. Blocking that path reduces reachability and potential blast radius.
Allow a narrow connection
Permit the actual booking workload to use the configured database port. Broad namespace-wide rules may allow more callers than intended.
Verify enforcement
A policy object is only configuration intent. The cluster network implementation must support and enforce it, and selectors must match the intended workloads.
Keep identity checks
An allowed TCP connection is not permission to read every order. Database credentials, encrypted transport and application ownership checks remain separate controls.
Test both directions
Verify allowed traffic, denied traffic and necessary DNS/monitoring dependencies. Observe unexpected failures and refine the policy without silently opening everything.
Pause and make a prediction
A database port is reachable from a booking pod. Does that authorize every SQL operation?
Correct a common misunderstanding
Claim to question: NetworkPolicy automatically works in every Kubernetes cluster.
Better explanation: Enforcement depends on the network implementation and correct selector semantics.
Create an allow/deny matrix
- List booking → database and unrelated-worker → database.
- Specify protocol/port and trustworthy selectors.
- Test allowed and denied paths, including required DNS.
Check what you can explain
This is your self-check, not an automated grade. Try again without the diagram tomorrow.
0 of 3 goals checked. Choose one remaining idea to practise next.
Teach it back
Without looking, explain what this component changes, what it does not solve and what happens if it fails. Use the animation to check your explanation, then switch to Engineering.
Engineering model and trade-offs
Map the required flows by source, destination, protocol and port. Apply least privilege and explicitly allow required DNS, monitoring and other dependencies. A deny rule that breaks name resolution can look like an application outage.
Kubernetes NetworkPolicy needs a network implementation that enforces it. Ingress and egress isolation are separate; namespace and pod selectors have specific semantics. Test actual allowed and denied connections from the relevant workloads.
Segmentation can limit lateral movement, but compromised allowed callers still need authentication/authorization boundaries. Protect management access, credentials and encrypted transport separately, and observe unexpected denied flows.
Work through an example
Only the booking workload should initiate the database application connection on its configured port.
Reason with the numbers
A rule allowing the whole namespace may expose more callers than intended; a narrower pod selector can express the required source if labels and enforcement are trustworthy.
Make a decision
Test a permitted booking connection and a denied unrelated-worker connection. Also verify DNS and any cross-namespace behavior in the actual cluster.
Implementation sketch
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata: {name: database-ingress}
spec:
podSelector: {matchLabels: {role: database}}
policyTypes: [Ingress]
ingress:
- from:
- podSelector: {matchLabels: {role: booking}}
ports: [{protocol: TCP, port: 5432}]Example ingress policy within one namespace; it needs an enforcing network plugin and correct labels. It does not configure egress, TLS, database credentials or application ownership checks.
Where this is used
- Restricting unnecessary internal reachability.
- Separating public, service, data and management boundaries.
Common mistakes
- Assuming a policy object guarantees enforcement.
- Blocking DNS or observability accidentally.
- Using network reachability instead of authorization.
Practise a reasoned answer
Answer aloud or write notes before opening the reference. These prompts teach reasoning and trade-offs; they are not claimed questions from a particular company.
How would you design segmentation?
Choose a practice depth
- Foundation
- Explain reducing unnecessary reachability.
- Practical
- Discuss ingress, egress, DNS and actual connection tests.
- Advanced
- Defend lateral-movement limits, workload identity, encrypted transport and policy rollout.
Self-check rubric
- State the required user outcome and the relevant invariant.
- Explain the normal path and one failure path.
- Name a cost or consistency/latency trade-off.
- Say what you would measure or test before trusting it.
For deeper practice, connect this topic to the previous lesson and identify a shared bottleneck. A longer answer is not automatically a better answer.
Try it before viewing the solution
A pod has a NetworkPolicy but unwanted traffic still reaches it. What do you verify?
Check one key idea
Your explanation and interview notes
Saved only in this browser when storage is available. Export a backup from the course page before clearing browser data or moving devices.
Loading your local notes…
Official references and next reading
The explanation, fictional examples and animations are original teaching material. Vendor behavior depends on the specific product/version; use its documentation before deploying.