tadata
Back to home

Kubernetes Patterns: Deployment, Resource Management & Multi-Tenancy

#kubernetes#devops#cloud#architecture#containers

Kubernetes provides the building blocks; patterns provide the architecture. This post covers the deployment strategies, structural patterns, and tenancy models that separate production-grade clusters from demo setups.

Deployment Strategy Comparison

StrategyZero downtimeRollback speedResource costRiskComplexityBest for
Rolling updateYesSlow (re-roll)1x + surgeLow per-podLowStateless services, default choice
Blue-greenYesInstant (switch)2xAll-or-nothingMediumCritical services needing instant rollback
CanaryYesFast (route shift)1x + canary %Controlled blast radiusHighUser-facing services, gradual rollout
RecreateNo (downtime)Slow1xFull outage during deployLowStateful services, DB migrations
A/B testingYesFast1x + variant %Segment-specificHighFeature experimentation
Shadow / dark launchYesN/A (no user impact)2xNone (mirrored traffic)Very highPerformance validation

Sidecar / Ambassador / Adapter Patterns

┌─────────────────────────────────────────────────┐
│                     POD                          │
│                                                  │
│  ┌───────────┐  ┌───────────┐  ┌───────────┐   │
│  │    App    │  │  Sidecar  │  │  Sidecar  │   │
│  │ Container │  │  (proxy)  │  │  (logging)│   │
│  └─────┬─────┘  └─────┬─────┘  └─────┬─────┘   │
│        │              │              │           │
│        └──────── shared network ─────┘           │
│                 shared volumes                   │
└─────────────────────────────────────────────────┘
PatternRoleExampleWhen to use
SidecarExtend app with cross-cutting concernsEnvoy proxy, log forwarder, cert rotationService mesh, observability
AmbassadorProxy outbound connections from appOAuth token injection, rate limiterSimplify app-to-external communication
AdapterNormalize app output for external systemsPrometheus exporter, log format converterHeterogeneous monitoring
Init containerRun setup before app startsDB migration, config fetch, secret injectionOne-time initialization

Resource Management Taxonomy

Resource Management
├── Requests & Limits
│   ├── CPU requests (scheduling guarantee)
│   ├── CPU limits (throttling ceiling)
│   ├── Memory requests (scheduling guarantee)
│   └── Memory limits (OOM-kill boundary)
├── Quality of Service (QoS)
│   ├── Guaranteed (requests = limits)
│   ├── Burstable (requests < limits)
│   └── BestEffort (no requests/limits)
├── Cluster-Level Controls
│   ├── ResourceQuotas (per-namespace caps)
│   ├── LimitRanges (per-pod defaults & bounds)
│   └── PriorityClasses (eviction ordering)
└── Autoscaling
    ├── HPA — Horizontal Pod Autoscaler (replica count)
    ├── VPA — Vertical Pod Autoscaler (resource sizing)
    ├── KEDA — Event-driven scaling (queue depth, custom metrics)
    └── Cluster Autoscaler / Karpenter (node provisioning)

Namespace Strategy Matrix

StrategyStructureProsConsBest for
Per environmentdev / staging / prodSimple, clear separationPoor isolation within envSmall teams, <10 services
Per teamteam-a / team-b / platformTeam autonomy, RBAC mappingCross-team service discovery harderMedium orgs, domain teams
Per serviceapi-gateway / billing / ml-servingMaximum isolationNamespace sprawl, overheadStrict security requirements
Hybridprod-team-a / staging-team-aBest of both worldsNaming conventions criticalLarge organizations
Per tenanttenant-abc / tenant-xyzStrong data isolationCluster resource pressureMulti-tenant SaaS

Multi-Tenancy Comparison

DimensionNamespace isolationVirtual clusters (vCluster)Separate clusters
Isolation levelSoft (RBAC + NetworkPolicy)Medium (virtual control plane)Hard (physical separation)
Cost efficiencyHigh (shared infra)MediumLow (duplicated infra)
Blast radiusNamespaceVirtual clusterFull cluster
CRD isolationNone (shared)Per virtual clusterFull
ComplexityLowMediumHigh
ComplianceBasicGoodBest (air-gapped)
Best forInternal teams, dev/stagingISVs, platform engineeringRegulated industries, PCI/HIPAA

Pod Disruption Budget (PDB) Guidelines

Workload typeRecommended PDBRationale
Stateless API (3+ replicas)minAvailable: 2 or maxUnavailable: 1Maintain capacity during drain
Stateful (DB, cache)minAvailable: N-1 (quorum)Preserve quorum for consensus
Singleton (1 replica)maxUnavailable: 0Prevent eviction, accept drain block
Batch / CronJobNo PDBRestart is acceptable
DaemonSetmaxUnavailable: 1Rolling node drain

Resources

:::