Course contentsShow
← Cloud and Infrastructure
Lesson 1388 of 2,98928. Kubernetes SecurityFree lesson

RBAC Best Practices

Apply principle of least privilege, regular audits, and avoid wildcard permissions.

RBAC Best Practices

What you'll learn: How to design secure, maintainable RBAC configurations that minimize security risks and operational overhead.

Core Principles

Now that you understand how to build RBAC policies, let's focus on how to do it safely. RBAC best practices revolve around three fundamental principles that work together to create a secure authorization model.

Principle of Least Privilege

Grant only the minimum permissions necessary for a subject to perform their function—nothing more. If a ServiceAccount only needs to read ConfigMaps in the dev namespace, don't give it cluster-wide read access or write permissions.

Analogy: Like giving a warehouse worker a key to their assigned section, not a master key to the entire building.

Avoid Wildcard Permissions

Never use * for resources, verbs, or API groups unless absolutely required (and document why). Wildcards create security holes because they automatically grant access to future resources or actions you haven't considered yet.

# ❌ Bad: overly permissive
rules:
- apiGroups: ["*"]
  resources: ["*"]
  verbs: ["*"]

# ✅ Good: explicit and scoped
rules:
- apiGroups: [""]
  resources: ["configmaps"]
  verbs: ["get", "list"]

Regular Audits

Periodically review who has access to what. Use kubectl auth can-i commands to verify permissions, check for unused ServiceAccounts, and remove stale RoleBindings. Permissions accumulate over time—prune them regularly.

Additional Guidelines

  • Use Roles (namespace-scoped) instead of ClusterRoles when possible
  • Separate permissions by function (read-only, admin, deployer)
  • Document why each permission exists

Key Takeaway: Apply least privilege, avoid wildcards, and audit regularly—these three practices prevent most RBAC security incidents and keep your cluster authorization model clean and understandable.