Namespace Creation
Phase 2 of the provisioning pipeline creates the Kubernetes namespace and configures isolation boundaries for the tenant. This phase consists of 7 steps that establish the tenant's compute environment.
Steps in Phase 2
| Order | Step | Description |
|---|---|---|
| 7 | CREATE_NAMESPACE | Create Kubernetes namespace tenant-{slug} |
| 8 | CREATE_RESOURCE_QUOTA | Apply CPU/memory/storage quotas |
| 9 | CREATE_LIMIT_RANGE | Set default and max container resource limits |
| 10 | CREATE_NETWORK_POLICY | Enforce network isolation between tenants |
| 11 | CREATE_SERVICE_ACCOUNT | Create service account for workloads |
| 12 | CREATE_POD_SECURITY_POLICY | Apply pod security standards |
| 13 | CREATE_RBAC_BINDINGS | Bind roles for tenant administrators |
Namespace Naming
For shared clusters (FREE/STARTER tier), namespaces follow the pattern tenant-{slug}:
String namespace = "tenant-" + tenant.getSlug();
tenant.setKubernetesNamespace(namespace);For dedicated clusters (PROFESSIONAL/ENTERPRISE), the namespace is typically matih since the entire cluster is dedicated to one tenant.
Resource Quota Configuration
Resource quotas are applied per tier to prevent any single tenant from consuming excessive cluster resources:
| Resource | FREE | PROFESSIONAL | ENTERPRISE |
|---|---|---|---|
| CPU requests | 2 cores | 16 cores | Custom |
| CPU limits | 4 cores | 32 cores | Custom |
| Memory requests | 4 Gi | 32 Gi | Custom |
| Memory limits | 8 Gi | 64 Gi | Custom |
| PVCs | 5 | 50 | Custom |
| Services | 10 | 100 | Custom |
Network Policy
Network policies enforce tenant isolation at the pod level:
- Default deny: All ingress traffic is denied by default
- Allow within namespace: Pods within the same tenant namespace can communicate
- Allow from ingress: Traffic from the tenant's ingress controller is permitted
- Allow to shared services: DNS, monitoring, and platform services are accessible
- Deny cross-tenant: Traffic between tenant namespaces is blocked
Rollback
All Phase 2 steps support rollback. When rolled back:
- RBAC bindings are removed
- Pod security policies are deleted
- Service accounts are deleted
- Network policies are removed
- Limit ranges and resource quotas are deleted
- The namespace is deleted (which cascades deletion of all contained resources)
Source Files
| File | Path |
|---|---|
| Step types | control-plane/tenant-service/src/main/java/com/matih/tenant/entity/ProvisioningStep.java |
| ProvisioningService | control-plane/tenant-service/src/main/java/com/matih/tenant/service/ProvisioningService.java |