DevOps in K8s — PodTopologySpread

<h1>What is PodTopologySpread?</h1> <p><code>PodTopologySpread</code>&nbsp;(formerly known as &quot;EvenPodsSpread&quot;) 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&nbsp;<code>PodTopologySpread</code>&nbsp;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&nbsp;<code>PodTopologySpread</code>&nbsp;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&nbsp;<code>topologySpreadConstraints</code>&nbsp;field has been added to the Pod&#39;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>,&nbsp;<code>DaemonSet</code>,&nbsp;<code>StatefulSet</code>) can also make use of the&nbsp;<code>PodTopologySpread</code>&nbsp;feature.</p> <p><a href="https://tonylixu.medium.com/devops-in-k8s-podtopologyspread-e5d583571837"><strong>Website</strong></a></p>
Tags: DevOps K8s