Project challenges / verified progress
Beacon: give it somewhere to live

The engineering notebook

Limit two blast radii

How do RBAC and NetworkPolicy give Beacon only the access it needs?

Loading statusStage 9 of 10

  • Workspace not ready
  • Agent not ready
Focus25:00
A small focus ritual

0 focus sessions completed. Every fourth session offers a longer break. Start each phase when you are ready.

Study time never unlocks verified lesson progress.

Loading...

Loading verified progress...

Loading GitHub account...
Phase 4 — Lock down and expose

Step 01 of 06

Learn the concept

Least privilege appears twice. One version asks what Beacon may do to the Kubernetes API. The other asks which packets may reach or leave it. Attackers are famously willing to use either door.

LEAST PRIVILEGE TWICEBeacon Podone workload identityRBACAPI verbs and objectscan-i tells truthIngress policywho may call Beacondefault denyEgress policywhere Beacon may callinternet needed
RBAC controls what a Pod identity can ask the Kubernetes API to do. NetworkPolicy controls which network flows are allowed. They solve different problems and both default too open for comfort.
Step 01

The ideas this is made of

ServiceAccounts are workload identities

Every Pod runs as a ServiceAccount. If you do not name one, it uses the namespace's default ServiceAccount. That default identity is convenient and ambiguous. A named beacon ServiceAccount makes intent visible, gives RBAC bindings a narrow subject, and prevents future workloads in the namespace from inheriting permissions meant for Beacon.

Roles are namespaced; ClusterRoles can cross namespaces

A Role grants verbs on resources inside one namespace. A ClusterRole can grant cluster-wide resources or be reused across namespaces. RoleBinding connects a subject, such as a ServiceAccount, to a Role or ClusterRole. Beacon does not need to mutate the Kubernetes API to serve HTTP, so its Role should be tiny or absent until a real API need exists.

`kubectl auth can-i` tests the identity, not your optimism

RBAC is easy to overgrant because YAML looks harmless. kubectl auth can-i list pods --as=system:serviceaccount:beacon:beacon -n beacon asks the API authorizer what that identity can do. Use it before and after bindings. A good answer for Beacon listing Pods is usually no. Services rarely need to inspect their neighbors.

NetworkPolicy defaults to allow-all until you say otherwise

In namespaces with a policy-capable CNI, Pods can usually receive and send traffic freely until NetworkPolicies select them. A default-deny ingress policy changes the baseline: nothing can call selected Pods unless a later policy allows it. Egress needs special care for Beacon because Beacon's job is making outbound HTTP and HTTPS checks to the internet.

A badge is not a firewall
badge: may enter records room
firewall: may call address 203.0.113.8
one stolen badge does not open every network path

RBAC and NetworkPolicy are orthogonal. One limits API authority; the other limits packets. You want both because attackers enjoy whichever one you skipped.

RBAC and NetworkPolicy

ControlProtectsCommon mistake

ServiceAccount

Workload identity

Using default forever

Role

Namespaced API access

Granting * verbs

RoleBinding

Who receives role

Binding whole groups

Ingress policy

Inbound traffic

Forgetting DNS/controller callers

Egress policy

Outbound traffic

Blocking the app's purpose

What these are called on the job

  • ServiceAccount — The Kubernetes identity assigned to Pods for API authentication.

  • Role — Namespaced RBAC permissions over resources and verbs.

  • RoleBinding — A binding from users, groups or ServiceAccounts to a Role or ClusterRole.

  • NetworkPolicy — A namespaced network rule selecting Pods and allowing specific ingress or egress flows.