Configuring pod affinity
Pod affinity controls where pods are deployed based on node configuration and placement of other pods.
To learn more about Pod Affinity, read Assigning Pods to Nodes in the Kubernetes documentation.
You can configure the affinity settings of the NiFi pod in the NiFi Custom Resource under
spec.statefulset
. The following example represents the default
configuration which will be added to the Custom Resource in the defaulting webhook.
spec:
statefulset:
affinity:
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- podAffinityTerm:
labelSelector:
matchExpressions:
- key: app.kubernetes.io/instance
operator: In
values:
- mynifi
topologyKey: kubernetes.io/hostname
weight: 1
This default configuration attempts to spread NiFi cluster pods to different nodes of the Kubernetes cluster. If there are more NiFi pods than available Kubernetes nodes, then some pods will coexist on the same node.