Module Review: Security
[!TIP] Security is not an add-on. It must be built into every layer of your cluster, from the Node (PSA) to the Network (mTLS) to the API (RBAC).
1. Key Takeaways
- RBAC enforces Least Privilege. Always use
RoleBindingfor namespaced access. Only useClusterRoleBindingwhen absolutely necessary. - ServiceAccounts are identities for Pods. Use Workload Identity (OIDC) to access cloud resources securely without long-lived secrets.
- Pod Security Admission (PSA) replaces PSP. Enforce the
restrictedstandard on all application namespaces. - mTLS creates a Zero Trust network. Use a Service Mesh to encrypt traffic between microservices automatically.
- Hardening Containers is mandatory. Always set
runAsNonRoot: true,readOnlyRootFilesystem: true, and dropALLcapabilities.
2. Interactive Flashcards
Test your knowledge. Click to flip.
3. Security Cheat Sheet
RBAC Troubleshooting
# Check if YOU can do something
kubectl auth can-i create deployments
# Check if a ServiceAccount can do something
kubectl auth can-i list secrets --as=system:serviceaccount:default:my-sa
# List all permissions for a user (via plugin 'access-matrix')
kubectl access-matrix --sa default:my-sa
Pod Security Admission (PSA)
# Enforce Restricted standard on 'prod' namespace
kubectl label namespace prod \
pod-security.kubernetes.io/enforce=restricted \
pod-security.kubernetes.io/warn=restricted
Security Context Best Practice
securityContext:
runAsNonRoot: true
readOnlyRootFilesystem: true
allowPrivilegeEscalation: false
capabilities:
drop: ["ALL"]