Overview
ThePersonalOrganizationController watches for User resources and automatically creates:
- A personal Organization for each user
- An OrganizationMembership granting the user owner permissions
- A default personal Project within the organization
Reconciliation Logic
The controller performs the following steps during reconciliation:1. User Validation
- Fetches the User resource
- Skips reconciliation if user is not found or is being deleted
2. Personal Organization Creation
- Name is generated using a hash of the user’s UID:
personal-org-<hash> - Display name uses the user’s given name and family name
- Type is set to
Personal(cannot be changed) - Controller reference is set to the User resource (organization is deleted when user is deleted)
3. Organization Membership Creation
- Created in the organization’s namespace
- Grants the configured owner role to the user
- Default role:
datum-cloud-ownerin namespacedatum-assignable-organization-roles
4. Personal Project Creation
- Only created if user’s registration approval is
Approved - Uses user impersonation to trigger project webhook correctly
- Project webhook automatically creates PolicyBinding granting ownership
- Requeues every 5 seconds if user is not yet approved
Configuration
The controller is configured via theDatumControllerManager configuration:
The name of the role to assign to users for their personal organization.Default:
datum-cloud-ownerThe namespace where the role exists.Default:
datum-assignable-organization-rolesExample Configuration
RBAC Permissions
The controller requires the following Kubernetes RBAC permissions:Verbs:
get, list, watchRequired to watch User resources and retrieve user information.Verbs:
createRequired to create personal organizations.Verbs:
create, get, list, watch, update, patchRequired to create and manage personal projects.Reconciliation Behavior
Idempotency
The controller usesCreateOrUpdate operations, making reconciliation idempotent:
- Organizations are only created once per user
- Existing resources are updated if specifications change
- Safe to run multiple reconciliation loops
User Impersonation
For project creation, the controller impersonates the user to ensure:- Project webhook sees the correct user identity
- PolicyBinding is created with the right owner
- Proper RBAC validation occurs
Requeue Logic
RequeueAfter: 5 secondsIf the user’s registration approval is not
Approved, the controller requeues to check again later.RequeueAfter: NeverSuccessful reconciliation does not trigger automatic requeue. The controller only reconciles on User resource changes.
Error Handling
User Not Found
Project Already Exists
User Being Deleted
Hash Generation
The controller uses FNV-32a hashing to generate unique, deterministic names:- Consistent naming across reconciliation loops
- No name collisions between users
- Human-readable hash format (8 hex characters)
Watch Configuration
The controller watches User resources:- User creation
- User updates (e.g., registration approval changes)
- Does NOT watch Organization or Project resources directly
Examples
Viewing Created Resources
Monitoring Controller Logs
Source Reference
Source:internal/controller/resourcemanager/personal_organization_controller.go:37-215