RBAC Roles and Bindings
This reference documents the Role-Based Access Control (RBAC) configurations that govern permissions within the Kubernetes cluster.Overview
RBAC implements the principle of least privilege by granting each component only the permissions it needs:- ServiceAccounts: Identity for pods and deployments
- Roles: Permissions on resources within a namespace
- RoleBindings: Assign roles to service accounts
Service Accounts
Backend Service Account
The backend service account includes IRSA (IAM Role for Service Account) integration for AWS access:platform/kubernetes/rbac.yaml:28-42
Features
- IRSA Integration: Annotated with AWS IAM role ARN
- Token Mounting: Enabled for AWS Secrets Manager access
- Purpose: Allows backend to access AWS services without hardcoded credentials
Frontend Service Account
platform/kubernetes/rbac.yaml:45-54
Features
- No Token: Service account token not mounted (frontend doesn’t need K8s API access)
- Minimal Privileges: No permissions granted
Database Service Account
platform/kubernetes/rbac.yaml:57-66
Features
- No Token: Database doesn’t access Kubernetes API
- Isolated: No permissions on cluster resources
Deployer Service Account
For CI/CD pipelines (GitHub Actions):platform/kubernetes/rbac.yaml:147-154
Roles
Backend Role
Grants backend read access to ConfigMaps and Secrets:platform/kubernetes/rbac.yaml:75-95
Permissions
| Resource | Verbs | Scope |
|---|---|---|
| configmaps | get, list, watch | govtech-config only |
| secrets | get | govtech-secrets only |
Deployer Role
Grants CI/CD pipeline deployment permissions:platform/kubernetes/rbac.yaml:99-116
Permissions
| Resource | Verbs | Purpose |
|---|---|---|
| deployments | get, list, update, patch | Update container images during deployment |
| pods | get, list, watch | Monitor rollout status |
| pods/log | get, list, watch | View logs for troubleshooting |
Restrictions
- Cannot delete pods: Prevents accidental service disruption
- Cannot create resources: Only updates existing deployments
- Cannot view secrets: No access to sensitive data
Role Bindings
Backend Role Binding
Binds the backend service account to its role:platform/kubernetes/rbac.yaml:127-142
Deployer Role Binding
Binds the deployer service account to its role:platform/kubernetes/rbac.yaml:157-172
IRSA (IAM Roles for Service Accounts)
The backend service account uses IRSA to access AWS services:- Access AWS Secrets Manager for database credentials
- Read from S3 buckets
- Call other AWS APIs
Permission Verification
Check if a service account can perform an action:platform/kubernetes/rbac.yaml:180-185
Security Best Practices
- Least Privilege: Each service account has minimal required permissions
- Resource Scoping: Permissions limited to specific resources (e.g.,
resourceNames) - Token Mounting: Disabled where not needed to reduce attack surface
- IRSA over Keys: Use IAM roles instead of hardcoded AWS credentials
- Namespace Isolation: Roles are namespace-scoped (not cluster-wide)