Member-only story
DevOps in K8s — PodTopologySpread
Note, full “DevOps in K8s” mind map is available at: “DevOps in K8s Mind Map”
What is PodTopologySpread?
PodTopologySpread
(formerly known as "EvenPodsSpread") is a scheduling feature in K8s that aims to achieve a balanced distribution of pods across different topologies. Common examples are nodes, racks, zones, or even custom-defined domains that can be labeled within a cluster.
The purpose of PodTopologySpread
is to ensure that the workload is not concentrated in a few nodes or zones but instead is evenly distributed.
An example of PodTopologySpread
definition looks like:
apiVersion: v1
kind: Pod
metadata:
name: mypod
spec:
topologySpreadConstraints:
- maxSkew: 1
topologyKey: zone
whenUnsatisfiable: DoNotSchedule
labelSelector:
matchLabels:
app: myapp
You can see that anew topologySpreadConstraints
field has been added to the Pod's Spec specification for configuring topology distribution constraints. Since this new field is added at the Pod spec level, higher-level controllers (Deployment
, DaemonSet
, StatefulSet
) can also make use of the PodTopologySpread
feature.