6.10 Kubernetes Authorization Intro
π― What is Authorization?
Authentication answers:
"Who are you?"
Authorization answers:
"What are you allowed to do?"
After authentication, Kubernetes evaluates whether the requested action is permitted.
π Why Authorization Matters in Production
In shared clusters:
- Developers should deploy applications, not modify nodes.
- CI/CD systems need scoped namespace access.
- Monitoring tools require read-only permissions.
- Nodes must report status but not manage cluster configuration.
Warning
Poor authorization design can lead to privilege escalation and full cluster compromise.
π§© Supported Authorization Mechanisms
Used for kubelets.
- Allows nodes to read Pods, Services, Endpoints
- Allows nodes to update Node & Pod status
- Requires user in
system:nodesgroup - Username format:
system:node:<node-name>
Attribute-Based Access Control.
- JSON policy file
- Direct user β permission mapping
- Requires API server restart for changes
- Difficult to scale
Role-Based Access Control.
- Define Roles (permissions)
- Bind users/groups via RoleBinding
- Namespace or cluster scope
- No API server restart required
Delegates authorization decision to external service (e.g., Open Policy Agent).
- Used in enterprise environments
- Centralized policy enforcement
π RBAC Model (Production Standard)
- Create a Role (set of verbs + resources)
- Bind users/groups via RoleBinding
- Apply least privilege principle
Example:
Success
RBAC is the recommended and default production authorization mechanism.
β Authorization Modes Configuration
Configured in kube-apiserver:
If not specified:
Danger
Never run production clusters with AlwaysAllow.
Available modes:
- AlwaysAllow
- AlwaysDeny
- Node
- ABAC
- RBAC
- Webhook
π Authorization Evaluation Order
When multiple modes are configured:
- Request hits first authorizer
- If denied β passed to next
- If approved β authorization stops
Example:
- Node checks node requests
- RBAC evaluates user permissions
- Webhook handles custom policies
π Webhook Authorization Flow
- User request sent to API server
- API server calls external webhook (e.g., OPA)
- Webhook returns allow/deny
- API server enforces decision
Tip
Use webhook authorization for enterprise-grade compliance enforcement.
π‘ Production Best Practices
β DO
Success
- Use Node + RBAC combination
- Follow least privilege principle
- Scope permissions to namespaces
- Enable audit logging
- Restrict cluster-admin usage
- Review RoleBindings regularly
β DON'T
Danger
- Do NOT use AlwaysAllow
- Do NOT grant wildcard verbs (*)
- Do NOT use ABAC in new deployments
- Do NOT give cluster-wide access unnecessarily
- Do NOT disable authorization
π¨ Production Risks
| Risk | Impact |
|---|---|
| Over-permissive RBAC | Privilege escalation |
| Excessive cluster-admin | Full control takeover |
| Misconfigured webhook | Denial of service |
| No audit logs | Undetected abuse |
π Authentication vs Authorization
| Authentication | Authorization |
|---|---|
| Validates identity | Validates permission |
| Certificates, Tokens | RBAC, Node, Webhook |
| Who are you? | What can you do? |
π― Summary
- Authorization controls actions after authentication
- Node authorizer handles kubelet requests
- RBAC is the production standard
- Webhook enables external policy control
- AlwaysAvoid AlwaysAllow in real clusters
Quote
Authentication grants entry.
Authorization determines capability.