Core Track Guardrails-first chapter in core learning path.

Estimated Time

  • Reading: 25 min
  • Lab: 40 min
  • Quiz: 5 min

Prerequisites

What You Will Produce

On your own kind cluster: proof that the platform’s policies hold - a probe without the frontend’s label cannot reach the backend, a probe with it can, and a pod in develop cannot reach the production database even when it pretends to be the backend. Then, in the namespace lab, a service you isolate step by step: open, denied, one connection allowed on one port, and the “allow everything” shortcut that undoes it all. The lab ends with lab empty again and every Kustomization Ready and none suspended.

Chapter 06: Network Policies (Production Isolation)

Learning Objectives

By the end of this chapter, you will be able to:

  • Explain what NetworkPolicies protect: how far one compromised or misused pod can reach, and why a flat network makes every pod as dangerous as the most exposed one
  • Read the platform’s policies and prove with a probe which connections they allow and which they block - telling a blocked connection from a failed name lookup
  • Write an allow rule for one connection: the right pods on both ends, the right direction, the right port
  • Explain why policies only add allowances - and why one “allow everything” policy undoes every other rule

Recall Check

Before continuing, quickly recall:

  • Who may write to develop, and who may only read production? (Chapter 01)
  • What does Flux do with a NetworkPolicy someone deleted by hand? (Chapter 03)
  • Where does a change to a shared base folder land - in one environment, or in all of them? (Chapter 03)

If you can’t answer these, revisit the corresponding chapter before proceeding.

Context

Chapter 01 limited what a person may do in each namespace. This chapter limits what a pod may reach. Without a NetworkPolicy, every pod in a Kubernetes cluster can open a connection to every other pod, in every namespace: the frontend to the production database, a load-test tool in develop to Postgres in production, a debugging container to anything with an open port. The network is flat.

That matters on the day something goes wrong in one pod - and that day comes:

  • A mistake travels. A test run in develop with the production database’s address copied into its config writes test data into production. Nothing stopped it but luck.
  • A compromise travels. A vulnerability in one application lets an attacker run code in its pod. On a flat network, that pod is a door to every database and internal API in the cluster.
  • Data leaves. A pod that may connect anywhere may also send anything anywhere - to any address on the internet.

NetworkPolicies turn the flat network into the paths the platform actually uses. In each environment (develop, staging, production) the default is nothing, and every allowed connection is written down: the frontend may call the backend on 8080; the backend may call its own database on 5432; nothing may call the database of another environment. The policies are also the platform’s map of who talks to whom - reviewed in Git like everything else.

They have a cost, and the chapter does not hide it: a missing rule breaks a working path, and a policy has to be read, not guessed. But a blocked connection is a visible failure in one place, found with a probe. A connection that should never have been possible is invisible - until the day it is used.

Work through each lesson section; the chapter video, once it is published, gives the concept overview.

From a Flat Network to Written-Down Paths

Diagram: without NetworkPolicies; frontend; backend; database; any pod in any namespace; with the platform's policies; TCP 8080; TCP 5432; any other pod; blocked

Detailed Lessons

Hands-On Materials

Labs, quizzes and runbooks for this chapter are free - sign in with your email, Google or GitHub to open them.

  • Lab: Written-Down Paths Free · sign in
  • Quiz: Chapter 06 (Network Policies) Free · sign in