Part IV — Expert Production Engineering · Chapter 22 · Lesson 3 of 5 · 2 min read
Lesson 3: Network Policies, Disruption Budgets, Topology Spread, and Anti-Affinity
Lesson level: Expert
Purpose: Availability and network isolation depend on enforced policies and real cluster topology. Defaults express intent but do not prove restrictions or failure tolerance.
Learning Objectives
- Identify guarantees and best-effort behavior.
- Adapt the source templates to the application.
- Prove the failure path with controlled tests.
3.1 Concepts
NetworkPolicy constrains traffic only when the cluster networking implementation enforces it. The secure template selects allowed ingress Pods by labels and permits specified DNS and HTTPS egress toward namespaces; that is not a precise allowlist of registry, secret-service, or external destinations. Review namespace scope and actual traffic. A PodDisruptionBudget limits voluntary disruption, not node crashes. The generated topology spread uses ScheduleAnyway and anti-affinity is preferred, so placement diversity is best effort.
3.2 Annotated Example
SecureKubernetesConfig exposes allowed_ingress_labels, topology_key, min_available, namespace, and replicas. With the default ingress label app=ingress, confirm the intended ingress Pods are in the selected scope. If they run in a different namespace, compose explicit namespace and Pod selectors. Confirm the budget leaves a feasible eviction path for your actual replica count.
3.3 Guided Practice
Trace a request from the approved ingress, a denied test Pod, a DNS query, and an artifact fetch. Explain the difference between preferred spread and a hard scheduling requirement.
3.4 Common Mistakes
Do not describe ScheduleAnyway as guaranteed separation, use a disruption budget that prevents maintenance indefinitely, or rely on NetworkPolicy when the cluster plugin does not enforce it.
3.5 Hands-On Lab
- Deploy the reviewed policies in an isolated namespace using harmless test traffic.
- Verify approved ingress and required egress, then demonstrate denial of an unapproved connection.
- Inspect Pod placement and deliberately constrain available nodes to observe preferred-placement behavior.
- Exercise a voluntary maintenance event and record readiness, availability, and budget decisions.
Deliverable: Policy or shutdown test matrix, observed evidence, and the adapted resources.
3.6 Review Questions
Which failures does a disruption budget not cover? Why might a label-only ingress selector miss a controller? What do preferred anti-affinity and ScheduleAnyway promise?
3.7 Applied Challenge
Create a minimal traffic matrix with source namespace, destination, port, purpose, identity, and denial test. Tighten egress without breaking health and artifact loading.
Lesson Summary
Availability and network isolation depend on enforced policies and real cluster topology. Defaults express intent but do not prove restrictions or failure tolerance.
Lesson status: Draft complete; ready for review. Source-checked, not cluster-validated.