Kubernetes Authorizer Alwaysdeny Behavior Explained and Fixed
The AlwaysDeny authorizer mode in Kubernetes does not deny requests as expected due to its design to return NoOpinion.
The AlwaysDeny authorizer mode in Kubernetes does not deny requests as expected due to its design to return NoOpinion, requiring configuration adjustments.
Problem Context
The kube-apiserver’s AlwaysDeny authorizer mode returns NoOpinion instead of a direct deny decision. This allows subsequent authorizers in the chain to override the decision, making it unsuitable for production environments where explicit denials are required.
Diagnosis Steps
- Check authorizer configuration: Verify the
--authorization-modeflag on the kube-apiserver. Common modes includeRBAC,Node,Webhook, orAlwaysDeny. - Review logs: Look for
authorizer.DecisionDenyorNoOpinionentries in kube-apiserver logs:kubectl logs -n kube-system <apiserver-pod-name> | grep -i authorizer - Validate authorizer chain order: Ensure
AlwaysDenyis positioned correctly if used alongside other authorizers.
Repair Workflow
- Adjust authorizer chain: Place
AlwaysDenyfirst in the chain to enforce denials:--authorization-mode=AlwaysDeny,RBAC,Node,WebhookNote: Requires restarting the kube-apiserver.
- Test with AlwaysAllow: Temporarily use
AlwaysAllowto validate chain behavior before enforcing denials. - Update policies: Replace
AlwaysDenywith explicit RBAC policies or admission controllers for production environments.
Prevention
- Policy reviews: Regularly audit authorization policies to avoid reliance on non-production-safe modes.
- Staging testing: Validate authorizer changes in non-production clusters before rolling to production.
- Monitoring: Alert on unexpected
NoOpiniondecisions in audit logs.
Tooling
- kubectl: Inspect API server flags and logs.
- Audit logs: Enable with
--audit-policy-fileto track authorization decisions. - Policy generators: Use tools like
kubectl create rolebinding --dry-runto test RBAC rules.
Tradeoffs
- Strict policies vs. flexibility: Enforcing
AlwaysDenyearly in the chain reduces attack surface but may break legitimate workflows if not carefully ordered. - Operational overhead: Modifying the authorizer chain requires API server downtime, impacting availability during rollout.
Troubleshooting
- Misconfigured chain order: If
AlwaysDenyis last, subsequent authorizers may override its decisions. - Missing RBAC rules: Ensure roles and role bindings are correctly defined to avoid accidental denials.
- Log verbosity: Increase log level to
--v=4on the API server to capture detailed authorizer decisions.
AlwaysDeny is a diagnostic tool, not a production control. Replace it with granular RBAC or admission webhooks for reliable access enforcement.
Source thread: [Question] Am I missing something or a core feature of K8s kube-apiserver is not working as intended??

Share this post
Twitter
Google+
Facebook
Reddit
LinkedIn
StumbleUpon
Pinterest
Email