INFRA-DEVOPS Contents

Principle of Least Privilege

Apply least privilege in production with practical access reviews, break-glass flows, and measurable permission reduction.

On this page

Least Privilege as an Operations Practice

  • Grant only what is needed for the task, for the shortest time.
  • Prefer role-based access and group membership over individual grants.
  • Make privilege reduction measurable (who/what still has admin?).

Access Review Checklist

  1. List all admin and cluster-admin bindings.
  2. Identify stale users and service accounts.
  3. Replace broad roles with scoped roles per namespace.
  4. Introduce break-glass admin with approvals and audit.

RBAC Discovery Commands

# Who has cluster-admin?
kubectl get clusterrolebinding -o json | jq -r '.items[]
| select(.roleRef.name=="cluster-admin")
| .metadata.name + " " + (.subjects|tostring)'

# What can I do? (impersonation)
kubectl auth can-i create pods --as system:serviceaccount:ns:sa

# List permissions for a subject (helpful for audits)
kubectl auth can-i --list --as user@example.com

Failure Modes

  • Permanent admin for "temporary" tasks.
  • No break-glass path: operators create unsafe workarounds.
  • Privilege creep: adding permissions without periodic removal.