KubernetesCXXX · Production Anti-PatternsProduction anti-patterns
Availability anti-patterns — the workload's resilience
What you'll learn
- Identify the availability anti-patterns
- Diagnose the impact of each anti-pattern
- Distinguish the high-impact from the low-impact anti-patterns
- Apply the discipline of availability anti-pattern fix
Prerequisites
Verified against Kubernetes 1.34.x · kubeadm 1.34.x · kubectl 1.34.x · etcd 3.6.x · CoreDNS 1.11.x · containerd 1.7.x / 2.x · 2026-08-16
The availability anti-patterns are the workload’s resilience. The diagnostic is the anti-patterns, the impact, and the systematic approach to fixing them. The discipline is the same scale-free: every anti-pattern gets a fix.
The availability anti-patterns
The availability anti-patterns are:
- No PDB. The workload has no PodDisruptionBudget; the workload can be evicted.
- All replicas on one node. The workload’s replicas are on one node; the node failure takes the workload down.
- No anti-affinity. The workload has no podAntiAffinity; the replicas are on the same node.
- No topology spread. The workload has no topology spread; the replicas are in the same zone.
flowchart TD
A[Availability anti-patterns] --> B[No PDB]
A --> C[All replicas on one node]
A --> D[No anti-affinity]
A --> E[No topology spread]
The availability anti-patterns are the workload’s resilience.
The diagnostic
The canonical diagnostic:
# Substitute your own value before running:
NS=production
# Use Polaris to detect anti-patterns
polaris audit --format yaml
# Check the workload's PDB
kubectl get pdb -n "$NS"
# Check the workload's replicas
kubectl get pods -n "$NS" -o wide
# Check the workload's topology
kubectl get pods -n "$NS" -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.spec.nodeName}{"\n"}{end}'
The diagnostic is the Polaris audit, the workload’s PDB, the workload’s replicas, and the workload’s topology.
The remediation
The remediation depends on the anti-pattern:
# Substitute your own values before running. APP is the value of the `app`
# label the Deployment puts on its pods, which the selectors below match:
DEPLOY=checkout-api
NS=production
APP=checkout-api
# Option 1: Set the PDB
kubectl apply -f pdb.yaml
# Option 2: Set the anti-affinity
kubectl patch deployment "$DEPLOY" -n "$NS" -p '{"spec":{"template":{"spec":{"affinity":{"podAntiAffinity":{"requiredDuringSchedulingIgnoredDuringExecution":[{"labelSelector":{"matchLabels":{"app":"'"$APP"'"}},"topologyKey":"kubernetes.io/hostname"}}]}}}}}}'
# Option 3: Set the topology spread
kubectl patch deployment "$DEPLOY" -n "$NS" -p '{"spec":{"template":{"spec":{"topologySpreadConstraints":[{"maxSkew":1,"topologyKey":"topology.kubernetes.io/zone","whenUnsatisfiable":"DoNotSchedule","labelSelector":{"matchLabels":{"app":"'"$APP"'"}}}]}}}}'
The remediation is the anti-pattern fix.
Production discipline
The availability anti-patterns are the cluster’s hypothesis. The discipline is to walk the 11-step methodology applied to the anti-patterns, identify the cause, apply the remediation. The cluster’s discipline is the same scale-free: every anti-pattern gets a fix.
- Run the detection in CI. The CI is the cluster’s prevention.
Quiz
Knowledge check · 4 questions
Q1. What is the most dangerous availability anti-pattern?
Q2. A PodDisruptionBudget of minAvailable: 2 keeps two replicas serving when a node crashes.
Q3. An operator reports that the workload's replicas are all on one node. The node failure will take the workload down. What is the diagnostic and remediation?
The cluster is a 1.34.x kubeadm install. The workload is `billing`. The workload has 6 replicas. All 6 replicas are on `node-01`. The workload has no podAntiAffinity.
Q4. Name three availability anti-patterns and the remediation for each.
Passing score: 75%. Answers are checked in this browser.