Identity & Zero Trust for Platform Engineers›Assurance and response · Cheat sheet & self-check

Assurance and response · wrap-up

Cheat sheet & self-check

Every command from this section on one page.

10 · Tenant isolation in a multi-tenant SaaS

PostgreSQL row-level security

ALTER TABLE accounts ENABLE ROW LEVEL SECURITY;Turn on RLS for a table
ALTER TABLE accounts FORCE ROW LEVEL SECURITY;Apply RLS to the table owner too
CREATE POLICY tenant_isolation ON accounts USING (tenant_id = current_setting('app.tenant_id')::uuid);Only rows for the session's tenant
SET app.tenant_id = '…';Set the tenant for this connection or transaction (from the verified token)

Quick isolation tests

curl -H "Authorization: Bearer $TENANT_A_TOKEN" https://api.example.com/tenants/B/usersMust be 403/404, never data
kubectl get resourcequota,limitrange -n <tenant-ns>Compute limits for a dedicated namespace

11 · Compliance as code

Evidence you can pull from the platform

kubectl get policyreport,clusterpolicyreport -AKyverno policy results per namespace (pass/fail)
kube-bench run --targets node,policies --jsonCIS Kubernetes Benchmark results
trivy image --format cyclonedx --output sbom.json <image>SBOM for an image
cosign verify --key cosign.pub <image>@<digest>Proof an image was signed by your pipeline
git log --merges --format='%h %an %s' -- clusters/prodReviewed, merged changes to production config

12 · Threat modelling a platform

STRIDE at a glance

S: SpoofingPretending to be someone else → strong authentication, mTLS, MFA
T: TamperingChanging data or code → signing, integrity checks, GitOps
R: RepudiationDenying an action → audit logs, signed commits, tamper-resistant logs
I: Information disclosureLeaking data → encryption, tenant isolation, least privilege
D: Denial of serviceExhausting resources → rate limits, quotas, cells
E: Elevation of privilegeGaining more rights → least privilege, Pod Security, admission control

13 · Responding to a compromised workload

Contain

kubectl label pod <pod> -n shop quarantine=true app-Remove from Service endpoints (stop new traffic) and mark it
kubectl apply -f quarantine-netpol.yamlDeny all ingress and egress for quarantine=true pods
kubectl cordon <node>No new pods on the affected node

Preserve and scope

kubectl get pod <pod> -n shop -o yaml > pod.yamlSpec, image digest, ServiceAccount, node
kubectl logs <pod> -n shop --all-containers --timestamps > logs.txtContainer logs before anything restarts
kubectl debug node/<node> -it --image=busyboxInspect the node from a debug pod (host filesystem under /host)
kubectl auth can-i --list --as=system:serviceaccount:shop:<sa>What the workload's identity could do in the cluster
kubectl get clusterrolebindings,mutatingwebhookconfigurations,daemonsets -A --sort-by=.metadata.creationTimestampRecently created high-risk objects (persistence)

14 · Capstone: zero-trust design review

Review questions per layer

HumansSSO + MFA everywhere? Standing admin? JIT? Reviews?
WorkloadsOne identity per service? Static cloud keys anywhere?
Service to serviceDefault deny? Strict mTLS? Identity-based L7 policy?
Edge and usersToken checks complete (aud, alg, tenant)? Identity headers stripped?
DataTenant enforced in the database? Per-tenant keys where needed?
DeliverySigned images verified at admission? Pipeline credentials short-lived?
Detect and respondRuntime detection? Audit logs central? Quarantine runbook?