K8s by Example: Pod Affinity
| Pod affinity schedules Pods on nodes where specific Pods are already running. Use for: co-locating related services, reducing network latency, data locality. |
| pod-affinity.yaml | |
| Pod affinity is defined in | |
| pod-affinity-types.yaml | |
| First example: | |
| topology-keys.yaml | |
|
| |
| pod-affinity-expressions.yaml | |
| Use | |
| pod-affinity-namespace.yaml | |
|
| |
| pod-combined-affinity.yaml | |
| Combine affinity with anti-affinity for complex placement. Co-locate with dependencies but spread across nodes. Common pattern for stateful applications with their caches. | |
| terminal | |
| Debug pod affinity issues by checking scheduler events. Pending Pods show why no node was selected. Verify target Pods exist and have matching labels. | |