About this scenario
payments in the payments namespace answers anyone today. Security wants two callers and no more: checkout in shop may create charges with POST /charge, and reconciler in finance may read them with GET /charges. storefront in shop and the old legacy-batch job in default, which has no sidecar, must be refused.
A teammate drafted an AuthorizationPolicy in payments-authz.yaml that allows checkout by its identity, cluster.local/ns/shop/sa/checkout. It isn't applied yet.
Apply it, see what it breaks, and finish the job. Test with kubectl exec -n shop deploy/checkout -- curl -s -X POST http://payments.payments:8080/charge.
Objectives
- See why the payments sidecar refuses a call
- checkout can create a charge, with an ALLOW policy on payments
- reconciler can list charges
- reconciler can't create a charge
- storefront is refused
- legacy-batch, outside the mesh, is refused
What you'll practice
- Without an AuthorizationPolicy, a sidecar allows everything. As soon as one ALLOW policy applies to a workload, everything its rules don't match gets a 403. DENY policies are checked first and win.
principals match the SPIFFE identity from the client's mTLS certificate: cluster.local/ns/NAMESPACE/sa/SERVICEACCOUNT. The service account comes from the client's Pod spec, so a workload on default shares its identity with every other Pod in the namespace that also runs as default.- A client without a sidecar sends plain text and has no principal. A policy that names principals refuses it even while PeerAuthentication is still PERMISSIVE.
- The server's sidecar enforces the policy, and its access log names the decision:
rbac_access_denied_matched_policy[none] for no matching ALLOW rule, or the policy and rule that denied it. spec: {} is an ALLOW policy with no rules, which allows nothing. It's the usual way to start from deny-all.
How the playground works
The cluster runs entirely in your browser: a simulated API server, scheduler, kubelets and controllers, with virtual nodes in three zones. kubectl output follows the real formats, errors use the real messages, and the add-ons (CSI storage, Traefik, Envoy Gateway, cert-manager, Helm, Flux, Argo CD, Kyverno, Cilium, Istio) behave like their real counterparts for the common paths. It's a simulation, so some behavior is simplified. Your progress is saved in this browser.