Go deep on the identity behind a read-only Kubernetes MCP server. Prove least privilege across two independent dimensions — WHAT the agent may do (verbs and subresources) and WHERE it may do it (namespace scope) — close the exec/attach/port-forward escalation paths, and harden the ServiceAccount token and kubeconfig you built in Lesson 1.
This lesson inspects and hardens the exact identity you built in Lesson 1 — it does not create a new one. Confirm the ServiceAccount, Role, RoleBinding, and demo workloads still exist before going further.
kubectl get serviceaccount mcp-readonly -n demokubectl get role,rolebinding mcp-readonly -n demokubectl get pods -n demoEverything below reasons about the mcp-readonly ServiceAccount and its namespace-scoped Role from Lesson 1.
The demo namespace should still hold the web pods and the crashing crasher pod.
If any of these are missing, the RBAC checks in this lesson have nothing to bind to.
The mcp-readonly ServiceAccount, Role, and RoleBinding all print, and the demo namespace lists the web-... pods plus crasher.