Multi-tenant SaaS Platforms cheat sheet
110 commands from every lesson of Multi-tenant SaaS Platforms — Cells, Rings & Progressive Delivery, on one page.
Cell design rules
No cross-cell calls on the request path | A cell serves its tenants with only its own components |
Thin global layer | Routing, identity, tenant directory: small, simple, highly available |
Static stability | Cells keep serving if the global control plane is down |
Same code everywhere | Cells differ by parameters, never by forks |
Cells are cattle | Built from code, replaceable, added when needed |
Limits to measure per cell
Database | Write IOPS, storage, max connections, replication lag under load |
Messaging | Partitions per broker, throughput, consumer lag |
Kubernetes | Nodes, pods, API server latency, etcd size, pod IPs per subnet |
Cloud account | Load balancers, ENIs/IPs, instance and KMS request quotas |
Edge and services | Requests per second, connection pools, cache memory |
Blast radius | Max tenants, max revenue or max top-tier customers per cell |
Ways to identify the tenant
Subdomain: acme.app.example.com | Easy to route on at the edge; visible to users |
Token claim: tenant=acme | Works for APIs; needs token parsing at the router |
Path prefix: /t/acme/… | Simple, but leaks into every URL |
Dedicated hostname per cell | Clients told which cell to use (after a lookup) |
Move checklist
1 provision | Tenant config, schema and storage ready in the target cell |
2 copy | Bulk copy of the tenant's data (database rows, objects, search index) |
3 stream | Change data capture from source to target until lag ≈ 0 |
4 pause | Short write pause for this tenant only; drain in-flight writes |
5 flip | Update the tenant → cell map; routers refresh |
6 verify | Row counts, checksums, smoke tests as the tenant |
7 keep | Source read-only for N days as the rollback point, then clean up |
A typical ring plan
Ring 0 | Internal and test tenants (dogfooding) |
Ring 1 | Canary cells: low-risk or opted-in tenants, a few percent of traffic |
Ring 2 | Broad shared cells, in waves (for example 25%, 50%, 100%) |
Ring 3 | Regulated and largest-customer cells, after the longest soak |
Argo CD
applicationsetcontroller.enable.progressive.syncs: "true" | Turn on RollingSync (argocd-cmd-params-cm) |
kubectl -n argocd get applicationset <name> -o jsonpath='{.status.applicationStatus}' | Where the rollout stands |
kubectl argo rollouts
kubectl argo rollouts get rollout tenant-api -n tenant-api --watch | Live view of steps, weights and analysis |
kubectl get analysisrun -n tenant-api | Analysis results (Successful, Failed, Error) |
kubectl argo rollouts promote tenant-api -n tenant-api | Skip the current pause |
kubectl argo rollouts abort tenant-api -n tenant-api | Abort by hand: back to stable |
kubectl argo rollouts dashboard | Local web UI |
Edge building blocks
Anycast CDN / edge network | One IP announced worldwide; users reach the nearest point of presence |
WAF and bot protection | OWASP rules, rate rules, managed signatures at the edge |
Origin protection | Cells accept traffic only from the edge (private link, mTLS or signed headers) |
Cell gateway | Gateway API implementation per cell: JWT checks, per-tenant limits, routing |
Global rate-limit service | Shared counters (e.g. Envoy rate limit service with Redis) across replicas |
Cluster labels that drive placement
fleet.example.io/tenancy: shared | dedicated | Shared cell or one customer's cell |
fleet.example.io/compliance: standard | regulated | Which policies and add-ons apply |
fleet.example.io/region: eu-west | us-gov-west | Where data may live |
fleet.example.io/ring: 0 | 1 | 2 | 3 | Rollout order (regulated usually last) |
Labels every signal should carry
cell | Which cell (cluster label copied into metrics, logs and traces) |
ring | Rollout ring of that cell |
tenant | Only where cardinality allows (logs, traces, aggregated metrics) |
service, version | What is running, to compare canary and stable |
OpenCost allocation API
kubectl -n opencost port-forward svc/opencost 9003:9003 | Reach the API locally |
curl -s 'localhost:9003/allocation/compute?window=1d&aggregate=namespace&accumulate=true' | Cost per namespace for the last day |
curl -s 'localhost:9003/allocation/compute?window=7d&aggregate=label:tenant.example.io/id&accumulate=true' | Cost per tenant label for a week |
Make labels visible
metricLabelsAllowlist: [ pods=[*], namespaces=[tenant.example.io/id,team,cost-center] ] | kube-state-metrics values: export these labels |
The three models
Silo | Dedicated resources per tenant: strongest isolation, highest cost, N copies to run |
Pool | Shared resources, rows and requests carry a tenant ID: cheapest, isolation is logical |
Bridge | Pool for most layers or tenants, silo where it matters: the usual real answer |
Decide per layer
Edge / gateway | Almost always pooled, with per-tenant limits |
Compute | Pooled per cell; dedicated node pool or cell for heavy tenants |
Data | Shared tables + row-level security, schema per tenant, or database per tenant |
Encryption keys | Often per tenant even when data is pooled |
Whole stack | Dedicated cell for regulated or very large tenants |
PostgreSQL row-level security
ALTER TABLE t ENABLE ROW LEVEL SECURITY | Turn RLS on: without a policy, non-owners see nothing |
CREATE POLICY p ON t USING (...) WITH CHECK (...) | USING filters rows you can see/change; WITH CHECK validates rows you write |
current_setting('app.tenant_id', true) | Read the tenant set for this transaction; true = return NULL if unset |
SET LOCAL app.tenant_id = 'acme' | Set the tenant for this transaction only (safe with connection pools) |
ALTER TABLE t FORCE ROW LEVEL SECURITY | Apply policies to the table owner too |
rolsuper / rolbypassrls | These roles skip RLS: never let the application use them |
Isolation options for data
Shared tables + tenant_id + RLS | Cheapest, scales to many tenants; isolation enforced in the database |
Schema per tenant | Clear separation; migrations run per schema; fine up to thousands |
Database per tenant | Strongest short of a dedicated cell; per-tenant backup/restore; costly at scale |
Per-tenant key | Encrypt tenant data with its own key; delete the key to make data unreadable |
Verify a tenant
kubectl auth can-i create deployments -n team-a --as=jane@example.com --as-group=team-a-devs | Test what a group member may do (needs impersonation rights) |
kubectl auth can-i delete networkpolicies -n team-a --as=jane@example.com --as-group=team-a-devs | Must be no: the team can't remove its own isolation |
kubectl describe quota -n team-a | Used vs hard limits |
kubectl get events -n team-a --field-selector reason=FailedCreate | Pods blocked by quota or Pod Security |
kubectl get ns team-a --show-labels | Pod Security level and tenant labels |
kubectl label --dry-run=server --overwrite ns team-a pod-security.kubernetes.io/enforce=restricted | What would break before you enforce Pod Security |
The pieces
Namespace + pod-security.kubernetes.io/enforce=restricted | Boundary; no root, no privileged pods, no host access |
RoleBinding: Group → ClusterRole tenant-developer / view | Who can do what, managed in the identity provider; not the built-in edit role |
ResourceQuota | Total CPU, memory, pods, storage, LoadBalancers for the namespace |
LimitRange | Default requests/limits and a per-container maximum |
NetworkPolicy default deny + allow DNS | Other namespaces can't reach the team's pods |
Dedicated nodes (hard isolation)
kubectl taint node N1 N2 platform.example.com/tenant=team-a:NoExecute | Repel and evict every pod without the toleration |
kubectl label node N1 N2 platform.example.com/tenant=team-a | Let the team's pods select these nodes |
MutatingAdmissionPolicy (GA in 1.36) | Writes nodeSelector and toleration into the team's pods |
ValidatingAdmissionPolicy (GA in 1.30) | Rejects other tenants' tolerations, wildcard tolerations and spec.nodeName |
kubectl tenants describe team-a | Access, quota left and blocked workloads for one tenant (tenant-insights) |
Levels of automation
1. Tenant chart | One platform-owned Helm chart; a tenant = small values file; quotas from tiers |
2. GitOps | ApplicationSet: one Argo CD Application per tenant file; delete the file to offboard |
3. Self-service | Portal form or PR → CI validation → auto-merge for small tiers, approval for large |
4. Guardrails | Policy engine generates and protects defaults in every tenant namespace |
Commands
helm lint charts/tenant -f tenants/team-b.yaml | Check the chart with one tenant's values |
helm template team-b charts/tenant -f tenants/team-b.yaml | Render what Argo CD would apply |
kubectl get applications -n argocd -l platform.example.com/kind=tenant | Tenant applications and their sync status |
Onboarding steps
1. Record | Tenant ID, plan, home region, status provisioning |
2. Placement | A cell in the home region with capacity, or a new dedicated cell |
3. Data and keys | Rows or schema in the cell's database; per-tenant key |
4. Identity | Organization in the platform IdP; SSO with the customer's IdP; first admin; optional SCIM |
5. Limits | Plan limits loaded: API rate, users, storage, jobs |
6. Routing | Tenant → cell entry; per-tenant hostname if used |
7. Metering | Usage events and billing start |
8. Verify | Smoke test as the tenant, then status active |
Workflow rules
Idempotent steps | Create-if-missing; safe to run twice |
Compensation | Undo finished steps in reverse order if the workflow can't complete |
Visible status | provisioning → active / failed (with reason) → suspended → offboarded |
Design outline
1 Today | Shared platform, incidents, limits hit, compliance needs |
2 Cell model | Contents of a cell, global layer, rules |
3 Sizing | First limit, headroom, blast-radius cap, cell count |
4 Routing and moves | Directory, cached map, move workflow |
5 Releases | Rings, gates, canary analysis |
6 Special tenants | Dedicated and regulated cells |
7 Migration | From one platform to cells, in phases |
8 Metrics | Blast radius, incidents, release safety, cost per tenant |