MATIH Platform is in active MVP development. Documentation reflects current implementation status.
7. Tenant Lifecycle
Provisioning
Namespace Creation

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

OrderStepDescription
7CREATE_NAMESPACECreate Kubernetes namespace tenant-{slug}
8CREATE_RESOURCE_QUOTAApply CPU/memory/storage quotas
9CREATE_LIMIT_RANGESet default and max container resource limits
10CREATE_NETWORK_POLICYEnforce network isolation between tenants
11CREATE_SERVICE_ACCOUNTCreate service account for workloads
12CREATE_POD_SECURITY_POLICYApply pod security standards
13CREATE_RBAC_BINDINGSBind 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:

ResourceFREEPROFESSIONALENTERPRISE
CPU requests2 cores16 coresCustom
CPU limits4 cores32 coresCustom
Memory requests4 Gi32 GiCustom
Memory limits8 Gi64 GiCustom
PVCs550Custom
Services10100Custom

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

FilePath
Step typescontrol-plane/tenant-service/src/main/java/com/matih/tenant/entity/ProvisioningStep.java
ProvisioningServicecontrol-plane/tenant-service/src/main/java/com/matih/tenant/service/ProvisioningService.java