Provisioning
The TenantInfrastructureService and InfrastructureController manage the complete lifecycle of tenant infrastructure. Provisioning creates isolated namespaces, databases, storage, and service deployments for each tenant. The process follows a state machine pattern with transitions tracked in the InfrastructureStateTransition table.
Provisioning Flow
| Phase | Description |
|---|---|
| 1. Request | Provision request received with tenant ID and configuration |
| 2. Plan | Terraform plan generated for the tenant's infrastructure |
| 3. Apply | Terraform applies the infrastructure changes |
| 4. Deploy | Services are deployed into the tenant namespace |
| 5. Configure | Ingress, DNS, and service mesh configured |
| 6. Verify | Health checks validate the deployment |
| 7. Complete | Infrastructure marked as ready |
Provision Tenant Infrastructure
Endpoint: POST /api/v1/infrastructure/tenants/:tenantId/provision
curl -X POST http://localhost:8089/api/v1/infrastructure/tenants/550e8400/provision \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${TOKEN}" \
-d '{
"tier": "professional",
"region": "eastus",
"cloudProvider": "AZURE",
"configuration": {
"databaseSize": "Standard_D2s_v3",
"storageGb": 100,
"enableHa": false
}
}'Infrastructure State
Endpoint: GET /api/v1/infrastructure/tenants/:tenantId
Returns the current infrastructure state for a tenant.
TenantInfrastructure Entity
| Field | Type | Description |
|---|---|---|
id | UUID | Infrastructure record ID |
tenantId | UUID | Owning tenant |
status | String | Current status (PROVISIONING, ACTIVE, UPDATING, etc.) |
cloudProvider | String | Cloud provider (AZURE, AWS, GCP) |
region | String | Deployment region |
namespace | String | Kubernetes namespace |
configuration | JSON | Infrastructure configuration |
terraformStateKey | String | Terraform state backend key |
Update Infrastructure
Endpoint: PUT /api/v1/infrastructure/tenants/:tenantId
Updates the tenant infrastructure configuration (e.g., scaling, adding resources).
Deprovision
Endpoint: DELETE /api/v1/infrastructure/tenants/:tenantId
Initiates infrastructure teardown for a tenant. This is an irreversible operation that removes all tenant resources.
State Transitions
The InfrastructureStateTransition entity tracks every state change for audit and debugging:
| Field | Type | Description |
|---|---|---|
id | UUID | Transition ID |
tenantId | UUID | Tenant |
fromState | String | Previous state |
toState | String | New state |
trigger | String | What triggered the transition |
details | JSON | Additional context |
timestamp | Instant | When the transition occurred |
Desired State Reconciliation
The DesiredInfrastructureState entity and InfrastructureReconciler implement a Kubernetes-style reconciliation pattern. The desired state is declared, and the reconciler continuously works to match the actual state to the desired state.
The reconciler publishes events via ReconciliationEventPublisher for observability of reconciliation progress.