DevOps in K8s — PodTopologySpread
<h1>What is PodTopologySpread?</h1>
<p><code>PodTopologySpread</code> (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.</p>
<p>The purpose of <code>PodTopologySpread</code> is to ensure that the workload is not concentrated in a few nodes or zones but instead is evenly distributed.</p>
<p>An example of <code>PodTopologySpread</code> definition looks like:</p>
<pre>
apiVersion: v1
kind: Pod
metadata:
name: mypod
spec:
topologySpreadConstraints:
- maxSkew: 1
topologyKey: zone
whenUnsatisfiable: DoNotSchedule
labelSelector:
matchLabels:
app: myapp</pre>
<p>You can see that anew <code>topologySpreadConstraints</code> 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 (<code>Deployment</code>, <code>DaemonSet</code>, <code>StatefulSet</code>) can also make use of the <code>PodTopologySpread</code> feature.</p>
<p><a href="https://tonylixu.medium.com/devops-in-k8s-podtopologyspread-e5d583571837"><strong>Website</strong></a></p>