A topology key is the node-label key that defines where Kubernetes compares Pods for a Pod affinity or anti-affinity rule. The Pod label selector identifies existing Pods; the topology key sets the placement domain, such as a node or zone. section 3.2.7
Keep licensed Pods on one node
To avoid buying another per-node license, select existing Pods labeled license=widgets and set topologyKey to kubernetes.io/hostname. A required Pod affinity rule then places the new Pod on a node hosting a match. An anti-affinity rule can instead use a zone label to prefer separation. section 3.2.7
apiVersion: v1
kind: Pod
metadata:
name: widgets-license-example
spec:
affinity:
podAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: license
operator: In
values:
- widgets
topologyKey: kubernetes.io/hostname
containers:
- name: nginx-widgets
image: nginx-widgets
The Pod manifest shows the label selector and topologyKey together in a required affinity rule. section 3.2.7

