![]() |
VOOZH | about |
Advanced pod scheduling in Kubernetes enables the deployment of numerous interesting use cases and best practices for building complex applications and microservices on Kubernetes. Pod affinity enables pod colocation and data proximity in tightly connected application stacks and microservices.
Advanced Kubernetes Scheduling experienced a significant increase in v2.4, particularly in serverless deployments. The latest Kubernetes version, v1.30, is described as a substantial improvement in its ability to manage and scale containerized workloads—the best reason to get started with the platform to execute your production-worthy containerized workloads. This release includes various new capabilities aimed at improving the scalability, flexibility, and administration of Kubernetes settings, particularly in reacting to frameworks that handle serverless computing efficiently.
Kube scheduler is Kubernetes' default scheduler, which operates as part of the control plane. Kube scheduler is designed so that you can develop your scheduling component and use it instead. The Kube scheduler finds an ideal node for each freshly formed pod or other unplanned pods. However, every container in pods has varied resource requirements, as does each pod. As a result, existing nodes have to be constantly filtered to meet specific scheduling criteria. The scheduler locates possible Nodes for a Pod and then executes a series of functions to score the feasible Nodes before selecting the Node with the highest score among the feasible ones to run the Pod. The scheduler then tells the API server of its decision through a procedure known as binding.
Below are some advanced Kubernetes Scheduling Techniques
Node affinity/anti-affinity lets you specify which nodes a pod can operate on based on their labels. But what if you wish to set rules for how pods should be arranged about one another, such as spreading or packing pods inside a service or relative to pods in other services? You can use pod affinity/anti-affinity, also beta in Kubernetes 1.6.
Example:
affinity:
podAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: service
operator: In
values: [“S1”]
topologyKey: failure-domain.beta.kubernetes.io/zone
If the Kubernetes scheduler's different features do not provide sufficient control over workload scheduling, you can delegate responsibility for scheduling arbitrary subsets of pods to your custom scheduler(s), which run alongside or instead of the default Kubernetes scheduler. Kubernetes 1.6 includes beta support for multiple schedulers.
The default scheduler normally schedules each new pod. However, if you specify the name of your custom scheduler, the default scheduler will ignore the Pod and enable your scheduler to schedule it to a node.
Example:
apiVersion: v1
kind: Pod
metadata:
name: nginx
labels:
app: nginx
spec:
schedulerName: my-scheduler
containers:
- name: nginx
image: nginx:1.10
Taints and tolerations work together to guarantee that pods are scheduled on the correct nodes. A taint on a node repels pods that cannot withstand the taint. This technique is required for allocating nodes to specific workloads, isolating workloads, and managing nodes using specialized hardware.
apiVersion: v1
kind: Pod
metadata:
name: my-special-workload
spec:
containers:
- name: special-workload
image: special-workload:latest
tolerations:
- key: "key"
operator: "Equal"
value: "value"
effect: "NoSchedule"
Inter-pod affinity is a Kubernetes feature that allows you to schedule pods depending on their relationship to other pods. This functionality allows for a variety of interesting use scenarios, including the colocation of pods that are part of the codependent service(s) and the implementation of data locality, in which data pods run on the same system as the main service pod.
Example:
apiVersion: v1
kind: Pod
metadata:
name: example-pod-affinity
spec:
affinity:
podAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
– labelSelector:
matchExpressions:
– key: security
operator: In
values:
– S1
topologyKey: failure-domain.beta.kubernetes.io/zone
containers:
– name: pod-affinity
image: your-container
Advanced Kubernetes Scheduling Techniques separates application orchestration from infrastructure resources. Enterprises can now only be concerned with Kubernetes APIs for managing an application at scale and highly available, rather than underlying infrastructure resources.