Cheat Sheets / Kubernetes & Platform

Multi-tenant SaaS Platforms cheat sheet

110 commands from every lesson of Multi-tenant SaaS Platforms — Cells, Rings & Progressive Delivery, on one page.

01 · Why cells

Cell design rules

No cross-cell calls on the request pathA cell serves its tenants with only its own components
Thin global layerRouting, identity, tenant directory: small, simple, highly available
Static stabilityCells keep serving if the global control plane is down
Same code everywhereCells differ by parameters, never by forks
Cells are cattleBuilt from code, replaceable, added when needed

02 · Sizing a cell

Limits to measure per cell

DatabaseWrite IOPS, storage, max connections, replication lag under load
MessagingPartitions per broker, throughput, consumer lag
KubernetesNodes, pods, API server latency, etcd size, pod IPs per subnet
Cloud accountLoad balancers, ENIs/IPs, instance and KMS request quotas
Edge and servicesRequests per second, connection pools, cache memory
Blast radiusMax tenants, max revenue or max top-tier customers per cell

03 · Routing tenants to cells

Ways to identify the tenant

Subdomain: acme.app.example.comEasy to route on at the edge; visible to users
Token claim: tenant=acmeWorks for APIs; needs token parsing at the router
Path prefix: /t/acme/…Simple, but leaks into every URL
Dedicated hostname per cellClients told which cell to use (after a lookup)

04 · Moving a tenant between cells

Move checklist

1 provisionTenant config, schema and storage ready in the target cell
2 copyBulk copy of the tenant's data (database rows, objects, search index)
3 streamChange data capture from source to target until lag ≈ 0
4 pauseShort write pause for this tenant only; drain in-flight writes
5 flipUpdate the tenant → cell map; routers refresh
6 verifyRow counts, checksums, smoke tests as the tenant
7 keepSource read-only for N days as the rollback point, then clean up

05 · Ring-based rollouts

A typical ring plan

Ring 0Internal and test tenants (dogfooding)
Ring 1Canary cells: low-risk or opted-in tenants, a few percent of traffic
Ring 2Broad shared cells, in waves (for example 25%, 50%, 100%)
Ring 3Regulated 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

06 · Canary analysis with Argo Rollouts

kubectl argo rollouts

kubectl argo rollouts get rollout tenant-api -n tenant-api --watchLive view of steps, weights and analysis
kubectl get analysisrun -n tenant-apiAnalysis results (Successful, Failed, Error)
kubectl argo rollouts promote tenant-api -n tenant-apiSkip the current pause
kubectl argo rollouts abort tenant-api -n tenant-apiAbort by hand: back to stable
kubectl argo rollouts dashboardLocal web UI

07 · The global edge

Edge building blocks

Anycast CDN / edge networkOne IP announced worldwide; users reach the nearest point of presence
WAF and bot protectionOWASP rules, rate rules, managed signatures at the edge
Origin protectionCells accept traffic only from the edge (private link, mTLS or signed headers)
Cell gatewayGateway API implementation per cell: JWT checks, per-tenant limits, routing
Global rate-limit serviceShared counters (e.g. Envoy rate limit service with Redis) across replicas

08 · Dedicated and regulated cells

Cluster labels that drive placement

fleet.example.io/tenancy: shared | dedicatedShared cell or one customer's cell
fleet.example.io/compliance: standard | regulatedWhich policies and add-ons apply
fleet.example.io/region: eu-west | us-gov-westWhere data may live
fleet.example.io/ring: 0 | 1 | 2 | 3Rollout order (regulated usually last)

09 · Operating a fleet of cells

Labels every signal should carry

cellWhich cell (cluster label copied into metrics, logs and traces)
ringRollout ring of that cell
tenantOnly where cardinality allows (logs, traces, aggregated metrics)
service, versionWhat is running, to compare canary and stable

10 · Cost per tenant

OpenCost allocation API

kubectl -n opencost port-forward svc/opencost 9003:9003Reach 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

11 · Tenancy models: silo, pool and bridge

The three models

SiloDedicated resources per tenant: strongest isolation, highest cost, N copies to run
PoolShared resources, rows and requests carry a tenant ID: cheapest, isolation is logical
BridgePool for most layers or tenants, silo where it matters: the usual real answer

Decide per layer

Edge / gatewayAlmost always pooled, with per-tenant limits
ComputePooled per cell; dedicated node pool or cell for heavy tenants
DataShared tables + row-level security, schema per tenant, or database per tenant
Encryption keysOften per tenant even when data is pooled
Whole stackDedicated cell for regulated or very large tenants

12 · Isolating tenant data

PostgreSQL row-level security

ALTER TABLE t ENABLE ROW LEVEL SECURITYTurn 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 SECURITYApply policies to the table owner too
rolsuper / rolbypassrlsThese roles skip RLS: never let the application use them

Isolation options for data

Shared tables + tenant_id + RLSCheapest, scales to many tenants; isolation enforced in the database
Schema per tenantClear separation; migrations run per schema; fine up to thousands
Database per tenantStrongest short of a dedicated cell; per-tenant backup/restore; costly at scale
Per-tenant keyEncrypt tenant data with its own key; delete the key to make data unreadable

13 · Teams on a shared Kubernetes cluster

Verify a tenant

kubectl auth can-i create deployments -n team-a --as=jane@example.com --as-group=team-a-devsTest 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-devsMust be no: the team can't remove its own isolation
kubectl describe quota -n team-aUsed vs hard limits
kubectl get events -n team-a --field-selector reason=FailedCreatePods blocked by quota or Pod Security
kubectl get ns team-a --show-labelsPod Security level and tenant labels
kubectl label --dry-run=server --overwrite ns team-a pod-security.kubernetes.io/enforce=restrictedWhat would break before you enforce Pod Security

The pieces

Namespace + pod-security.kubernetes.io/enforce=restrictedBoundary; no root, no privileged pods, no host access
RoleBinding: Group → ClusterRole tenant-developer / viewWho can do what, managed in the identity provider; not the built-in edit role
ResourceQuotaTotal CPU, memory, pods, storage, LoadBalancers for the namespace
LimitRangeDefault requests/limits and a per-container maximum
NetworkPolicy default deny + allow DNSOther namespaces can't reach the team's pods

Dedicated nodes (hard isolation)

kubectl taint node N1 N2 platform.example.com/tenant=team-a:NoExecuteRepel and evict every pod without the toleration
kubectl label node N1 N2 platform.example.com/tenant=team-aLet 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-aAccess, quota left and blocked workloads for one tenant (tenant-insights)

14 · Automating tenant onboarding

Levels of automation

1. Tenant chartOne platform-owned Helm chart; a tenant = small values file; quotas from tiers
2. GitOpsApplicationSet: one Argo CD Application per tenant file; delete the file to offboard
3. Self-servicePortal form or PR → CI validation → auto-merge for small tiers, approval for large
4. GuardrailsPolicy engine generates and protects defaults in every tenant namespace

Commands

helm lint charts/tenant -f tenants/team-b.yamlCheck the chart with one tenant's values
helm template team-b charts/tenant -f tenants/team-b.yamlRender what Argo CD would apply
kubectl get applications -n argocd -l platform.example.com/kind=tenantTenant applications and their sync status

15 · Customer tenant lifecycle

Onboarding steps

1. RecordTenant ID, plan, home region, status provisioning
2. PlacementA cell in the home region with capacity, or a new dedicated cell
3. Data and keysRows or schema in the cell's database; per-tenant key
4. IdentityOrganization in the platform IdP; SSO with the customer's IdP; first admin; optional SCIM
5. LimitsPlan limits loaded: API rate, users, storage, jobs
6. RoutingTenant → cell entry; per-tenant hostname if used
7. MeteringUsage events and billing start
8. VerifySmoke test as the tenant, then status active

Workflow rules

Idempotent stepsCreate-if-missing; safe to run twice
CompensationUndo finished steps in reverse order if the workflow can't complete
Visible statusprovisioning → active / failed (with reason) → suspended → offboarded

16 · Capstone: cells for 10,000 tenants

Design outline

1 TodayShared platform, incidents, limits hit, compliance needs
2 Cell modelContents of a cell, global layer, rules
3 SizingFirst limit, headroom, blast-radius cap, cell count
4 Routing and movesDirectory, cached map, move workflow
5 ReleasesRings, gates, canary analysis
6 Special tenantsDedicated and regulated cells
7 MigrationFrom one platform to cells, in phases
8 MetricsBlast radius, incidents, release safety, cost per tenant