K8s Objects Based on Topology
Posted May 24, 2023 by Rohith ‐ 2 min read
Topology based features provide flexibility and control over the placement of resources within a Kubernetes cluster based on the underlying topology. By leveraging topology-aware scheduling and placement, you can optimize resource utilization, improve availability, and enhance the performance of your applications.
In Kubernetes, the following resources or objects can be chosen based on topology:
Pod: The scheduling of Pods can be influenced by topology. The Pod can be scheduled to nodes based on topology constraints to ensure that the Pod is deployed in a specific zone, region, or failure domain. This can be achieved using the topologySpreadConstraints field in the Pod’s specification.
Persistent Volume (PV): When provisioning Persistent Volumes dynamically, topology constraints can be applied to ensure that the PV is allocated on nodes within the same topology domain. This helps in distributing the storage across failure zones and improving availability. StorageClasses, such as the “topology-aware-pd-standard” can be used to enable topology-aware provisioning of PVs.
Node Affinity: Node affinity is a feature in Kubernetes that allows you to schedule Pods onto specific nodes based on labels and node selectors. By specifying node affinity rules with topology constraints, you can ensure that Pods are scheduled on nodes within the desired topology domain. This helps in achieving high availability and fault tolerance.
Pod Affinity and Pod Anti-Affinity: Pod affinity and anti-affinity are mechanisms to influence the scheduling of Pods based on the presence or absence of other Pods. With topology constraints, you can define affinity or anti-affinity rules that ensure Pods are scheduled on nodes within the same topology domain or avoid scheduling them on nodes in certain domains.