Kubernetes Patterns

Foundational, Behavioral, and Structural Patterns

Infrastructure | Technical Operations Excellence

4
Pattern Categories
25+
Design Patterns
2014
K8s Released
92%
Enterprise Adoption

Foundational Patterns

PatternPurpose
Health ProbeLiveness, readiness, startup checks
Predictable DemandsResource requests/limits
Automated PlacementNode selectors, affinity rules
Declarative DeploymentDesired state via manifests

Behavioral Patterns

PatternUse Case
Batch JobRun-to-completion workloads
Periodic JobCronJobs for scheduled tasks
Daemon ServicePer-node agents (logging, monitoring)
Singleton ServiceLeader election, exactly one instance
Stateful ServiceOrdered, sticky identity (StatefulSet)

Structural Patterns

PatternDescription
Init ContainerSetup tasks before main container
SidecarExtend without modifying main app
AmbassadorProxy for external communication
AdapterNormalize heterogeneous output

Configuration Patterns

PatternUse For
EnvVar ConfigSimple key-value settings
ConfigMapNon-sensitive config files
SecretSensitive data (encrypted)
Immutable ConfigVersion-pinned configurations

Operator Pattern

Operators encode operational knowledge as software, automating day-2 operations.

  • Custom Resource: Domain-specific API
  • Controller: Reconciliation logic
  • Levels: Basic install → Full lifecycle

Resilience Patterns

PatternK8s Implementation
Self-HealingRestart policy, pod disruption budget
ScalingHPA, VPA, cluster autoscaler
Rolling UpdatesDeployment strategy
Blue-GreenService selector switch
CanaryWeighted traffic split

Security Patterns

PatternImplementation
Least PrivilegeRBAC, SecurityContext
Network IsolationNetworkPolicy
Secret ManagementExternal Secrets Operator
Pod SecurityPSS/PSA, read-only root

Observability Patterns

  • Sidecar logging: Fluentbit, Fluent-bit
  • Service mesh: Istio, Linkerd for tracing
  • Metrics: Prometheus ServiceMonitor
  • Events: K8s event exporter

Declarative Operations

Define desired state; let Kubernetes reconcile.