Scenario
An SRE team discovers that a developer account has full cluster-admin privileges, allowing arbitrary pod exec and secret access, posing a major security risk.
Symptoms
- Audit logs show unexpected
kubectl execorkubectl get secretscalls from non-admin users. - Developers report being able to access namespaces beyond their scope.
- Security scans flag excessive ClusterRoleBindings.
Diagnosis
- Run
kubectl auth can-i --list --as=developerto list capabilities for a specific user. - Execute
kubectl get clusterrolebindings -o wideto identify subjects bound to high-privilege roles like cluster-admin. - Use
kubectl describe clusterrolebinding <name>to inspect bindings. - Check Pod Security Policies:
kubectl get psp— no output means PSPs are not enforced.
Example Commands
# Check user permissions
kubectl auth can-i --list --as=developer
# Apply a restricted PodSecurityPolicy
kubectl apply -f restricted-psp.yaml
# Create a read-only ClusterRole
kubectl create clusterrole readonly --verb=get,list,watch --resource=pods,services,endpoints
# Bind to developers group
kubectl create clusterrolebinding dev-readonly --clusterrole=readonly --group=developers
# Rollback: delete the policy
kubectl delete -f restricted-psp.yaml
Risk Controls
- Implement least privilege: create dedicated ServiceAccounts and RoleBindings per team or application.
- Enable Pod Security Admission (PSA) or OPA Gatekeeper for policy enforcement.
- Enable cluster audit logs and centralize monitoring (e.g., ELK or OpsGlobal SIEM integration).
- Use NetworkPolicies to restrict pod-to-pod communication.
Rollback Plan
- Save existing ClusterRoleBindings:
kubectl get clusterrolebinding dev-admin -o yaml > backup.yaml - Delete restrictive policy:
kubectl delete -f restricted-psp.yaml - Restore the binding:
kubectl apply -f backup.yaml
Verification
- As developer, run
kubectl auth can-i delete pods— should return 'no' if properly restricted. - Check audit logs for any denied operations.
- Attempt to create a privileged pod — should be rejected.
When to Submit an OpsGlobal Ticket
- Your internal team lacks Kubernetes security expertise.
- You need 24/7 monitoring and rapid incident response.
- An active breach or misconfiguration requires immediate expert intervention.
- Regular security audits and compliance (e.g., SOC2, PCI-DSS) need external validation.
Use cases
Useful for teams handling Security issues and needing a clear troubleshooting and delivery workflow.
Problem background
This post walks through a real-world scenario of excessive cluster permissions, covering diagnosis via kubectl auth, implementing least privilege with ClusterRoles and Pod Security Admission, rollback steps, and when to engage OpsGlobal.
Troubleshooting steps
Confirm impact and recent changes, collect logs, configuration and metrics, then apply fixes from low to high risk.
Command examples
Replace sample resource names with real values and store passwords, tokens and keys in environment variables.
Risks
Before production changes, confirm backups, access boundaries, change windows and rollback paths.
Rollback plan
Keep original configuration and release versions; roll back config, images or database changes if metrics degrade.
Deliverables
Root-cause notes, key commands, remediation steps, verification results and follow-up recommendations.
Need help with a similar technical issue?
If your servers, Kubernetes, Docker, CI/CD, databases or monitoring systems have similar issues, submit logs and config files for remote diagnosis.