Setup AWS Karpenter for EKS
Kubernetes’ ability to dynamically scale infrastructure based on demand is a major benefit. Kubernetes provides multiple layers of autoscaling functionality: the Horizontal Pod Autoscaler (HPA), the Vertical Pod Autoscaler, and the Cluster Autoscaler. Together, these allow you to ensure that each pod and cluster is just the right size to meet your current needs.
Karpenter:
Karpenter is an open-source, high-performance Kubernetes cluster auto scaler that takes advantage of the AWS API to launch instances according to what your Kubernetes cluster needs. If you are familiar with GKE Autopilot, Karpenter observes the pod specifications of unschedulable pods, calculates the aggregate resource requests, and sends a request to the compute service like Amazon EC2 with the capacity required to run all the new pods.
Conversely, Karpenter can also deprovision nodes when they are no longer needed. This can be determined by node expiry config (ttlSecondsUntilExpired) or when the last workload running on Karpenter provisioned node is terminated.
Cluster Autoscaling
Cluster auto-scaler is an industry-adopted, open-source, and vendor-neutral tool, and it is part of the Kubernetes project, with implementations by most major Kubernetes cloud providers. Cluster Autoscaling will increase or decrease the size of a Kubernetes cluster (by adding or removing worker nodes) based on the presence of pending pods and multiple metrics.
Karpenter vs. Cluster Autoscaler
Cluster Autoscaler will only scale up or down your managed node groups through Amazon EC2 Auto Scaling Groups. It requires the ability to examine and modify EC2 auto-scaling groups. So, it watches the node groups. Whenever we add a new node group, we must tell Cluster Autoscaler about it because of the mapping that Cluster Autoscaler is Kubernetes native, and the node group is AWS native.
Karpenter manages each instance directly, without additional orchestration mechanisms like node groups. Karpenter looks at the workload (i.e., pods) and launches the right instances for the situation. Instance selection decisions are intent-based and driven by the specifications of incoming pods, including resource requests and scheduling constraints.
How does Karpenter work?
- Karpenter observes the pod resource requests of unscheduled pods.
- Direct provision of Just-in-time capacity of the node. (Groupless Node Autoscaling)
- Karpenter will terminate nodes if they are outdated.
- Karpenter can relocate the pods in nodes for better resource utilization.
- Karpenter will decide which instance type is best for the scheduled pod, thus driving the cost down regularly.
Karpenter allows you to use all the flexibility of the cloud. That means you use all of the EC2 instance types AWS offers. Also, you can choose the purchase options like On-Demand and Spot Availability Zone options.
Karpenter does not require Node Groups to manage each instance directly without additional orchestration mechanisms.
In Cluster Autoscaler, you must configure Node Groups for each instance type, purchasing options. That brings operational overhead.
With Karpenter, you don’t need to rely on the kube-scheduler. When Cluster Autoscaler launches a node, it doesn’t bind the pods to those nodes. Kube-scheduler makes that decision.
Conclusion
Karpenter is designed to work alongside existing AWS Capacity providers such as EKS Managed node groups and ECS Auto scaling groups. Customers can use a mixed model of cluster capacity management. Over the long term, it is expected that Karpenter will be leveraged increasingly as the premier dynamic cluster node manager. Post navigation