3.2 Pod Affinity (or Anti-affinity) Rules
The ocnaddkafka and Zookeeper services use the POD anti-affinity rules. The rules are intended to support even distribution of Kafka and Zookeeper pods across the available nodes.
Zookeeper Service Anti-affinity Rules
Zookeeper service anti-affinity rules are listed below:
spec:
affinity:
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100
podAffinityTerm:
labelSelector:
matchExpressions:
- key: app
operator: In
values:
- zookeeper
topologyKey: topology.kubernetes.io/zoneocnaddkafka Service Anti-affinity Rules
ocnaddkafka service anti-affinity rules are listed below:
spec:
topologySpreadConstraints:
- maxSkew: 1
topologyKey: kubernetes.io/hostname
whenUnsatisfiable: ScheduleAnyway
labelSelector:
matchLabels:
app1 : nodeselectionThe configuration ensures the scheduler keeps equal number of pods matching the constraint on every node. However, the parameter whenUnsatisfiable set to ScheduleAnyway, helps to schedule the pod, but the scheduler prioritizes honoring the skew to not make the cluster more imbalanced.