CICD-283 · RBAC permission testing
Encyclopedia · Advanced Kubernetes operations · All snippets
Previous · CICD-282 · Next · CICD-284
1. Where it fits
- Placement CI permission check.
- Prerequisites kubectl, isolated cluster or namespace and installed CRDs when named.
- Platforms kubernetes, local-lab.
2. Copy the snippet
bash
kubectl auth can-i patch deployments -n staging --as system:serviceaccount:staging:deployer | grep -Fx yes
kubectl auth can-i get secrets -n staging --as system:serviceaccount:staging:deployer | grep -Fx no3. How it works
kubectl asks authorization for the named service account in a single namespace. Compare explicit yes and no results to check both allowed patching and denied secret reads.
4. Verify the result
Requires impersonation rights for the tester. The deployer should patch workloads without being able to read Secret objects.
Watch for. Use the intended trusted execution context. Keep secret values out of traces, artifacts and debug output.
Validation syntax-validated (Bash parse). Status definitions.