Introduction to Karpenter
Tags: beginners, productivity, devops, kubernetes
Published: 2022-10-27 14:55:49

With Kubernetes, the ability to dynamically scale infrastructure based on demand is a major benefit. It provides multiple layers of autoscaling functionality: a horizontal pod autoscaler (HPA) and a vertical pod autoscaler (VPA) as a pod and a cluster autoscaler as a node.

However, _setting up cluster autoscaling with existing Kubernetes solutions can be difficult and restrictive_. For example, in an AWS EKS cluster, you cannot manage nodes directly. Instead, we need to use additional orchestration mechanisms such as `node groups`. Suppose we have defined **t3.large** as instance type of nodegroup. When a new node needs to be provisioned for the cluster, Kubernetes Cluster Autoscaler creates a new instance of type t3.large, regardless of resource requirements. Although we can use mixed instances in node groups, it is not always possible to meet resource demands and be cost effective.

# Kubernetes Autoscaling

K8S Autoscaling helps us to scale horizontally or in our applications. Pod-based or HPA-based scaling is a great first step. However, the problem is when we need multiple K8S nodes to hold our PODs.

## Karpenter

**Karpenter** is a node-based scaling solution created for K8S and aims to improve efficiency and costs. It's a great solution because we don't have to configure instance types or create node pools, which drastically simplifies configuration. On the other hand, integration with Spot instances is painless and allows us to reduce our costs (up to 90% less than On-Demand instances)

> Karpenter is an open source node deployment project designed for Kubernetes. Adding Karpenter to a Kubernetes cluster can significantly improve the efficiency and cost of running workloads on that cluster.

## Features of Karpenter

- Beware of pods that the Kubernetes scheduler has marked as unschedulable.
- Evaluate scheduling constraints (resource requirements, node selectors, affinities, tolerances, and topology distribution constraints).
- Demanded by pods deployment nodes that meet pod needs.
- Schedule pods to run on new nodes.
- Delete nodes when nodes are no longer needed.

## Control Loops of Karpenter

Karpenter has two control loops that maximize the availability and efficiency of your cluster.

### Allocator

Fast-acting controller that ensures pods are scheduled as quickly as possible

### Reallocator

Slow-acting controller replaces nodes as pod capacity changes over time.




Gratitude for perusing my article till the end. I hope you realized something unique today. If you enjoyed this article then please share it with your buddies and if you have suggestions or thoughts to share with me then please write in the comment box.

Follow me and share your thoughts,
[GitHub](https://github.com/MakendranG)
[LinkedIn](https://www.linkedin.com/in/makendran/)
[Twitter](https://twitter.com/MakendranG)


The above blog is submitted under 'Devtron Hacktoberfest 2022' conducted by [Devtron](https://devtron.ai/). Check out their Github repo and give it a star ⭐️ if you like it. Follow Devtron on [LinkedIn](https://www.linkedin.com/company/devtron-labs/), [Twitter](https://twitter.com/DevtronL)