How to manage pod scheduling in aws EKS?
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Introduction
Amazon Elastic Kubernetes Service (EKS) is a managed Kubernetes service that simplifies the process of running Kubernetes on AWS, eliminating the need to manually manage the infrastructure and control plane. One of the critical aspects of utilizing Kubernetes effectively is managing pod scheduling. Proper pod scheduling ensures that applications are highly available, performant, and optimized from a cost perspective. In this article, we'll delve into the strategies and techniques for managing pod scheduling in AWS EKS.
Overview of Pod Scheduling
Pod scheduling is the process of assigning pods to nodes within a Kubernetes cluster based on constraints and available resources. Kubernetes uses a scheduler to automate this process, making decisions based on factors like resource requests, limits, and taints. Efficient pod scheduling is paramount in balancing workloads, minimizing costs, and achieving high availability and fault tolerance.
Pod Scheduling Components in EKS
- Node Affinity and Anti-Affinity:
- Node Affinity allows you to constrain which nodes a pod can be scheduled on based on labels on the nodes.
- Node Anti-Affinity works the opposite way, discouraging pods from being placed on certain nodes.
- Example configuration:
- matchExpressions:
- key: "disktype"
- "ssd"
- Taints are placed on nodes and tolerations are added to pods to ensure that pods are not scheduled on inappropriate nodes.
- Example taint command:
- Adding tolerations to a pod:
- key: "key"
- Pod Affinity enables a pod to be scheduled on a particular node if certain conditions about other pods (already running on that node) are satisfied.
- Pod Anti-Affinity serves as a constraint that avoids placing certain pods on nodes under particular conditions.
- Define the minimum and maximum compute resources required for each pod. This helps the scheduler allocate the pod to a suitable node.
- Example configuration:
- name: my-container
- Use custom scheduling policies to tailor pod scheduling priorities.
- Incorporate preemption to ensure critical workloads have precedence over less important tasks.
- Enable the Cluster Autoscaler for automatic adjustment of the number of nodes in a cluster based on the pod's needs.
- More information on setting up the Cluster Autoscaler can be found here.
- Optimize for Cost and Performance:
- Leverage AWS spot instances for less critical workloads.
- Use Fargate for serverless compute options when applicable.
- High Availability:
- Distribute pods across multiple availability zones to ensure high availability and fault tolerance.
- Scaling Strategies:
- Implement Horizontal Pod Autoscaler (HPA) to scale pod replicas based on metrics like CPU utilization.
- Example HPA configuration:
Related reading
- How to merge kubectl config file with /.kube/config?
- How to mimic '--volumes-from' in Kubernetes
- How to mock the Kubernetes cluster/server?
- How to monitor disk usage of kubernetes persistent volumes?
- How to mock AWS DynamoDB service?
- How to modify expiry time of the access and identity tokens for AWS Cognito User Pools
- How to mount a Host folder in minikube VM
- How to mount a postgresql volume using Aws EBS in Kubernete

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.