From 110ae040562955be9f6a815d35577de76cb3a1f3 Mon Sep 17 00:00:00 2001 From: Michele Cereda Date: Sun, 8 Jun 2025 18:09:42 +0200 Subject: [PATCH] chore(kb/k8s/karpenter): mostly just add sources --- knowledge base/kubernetes/karpenter.md | 53 ++++++++++++++++++++++---- 1 file changed, 45 insertions(+), 8 deletions(-) diff --git a/knowledge base/kubernetes/karpenter.md b/knowledge base/kubernetes/karpenter.md index 71f21f0..f75709a 100644 --- a/knowledge base/kubernetes/karpenter.md +++ b/knowledge base/kubernetes/karpenter.md @@ -4,25 +4,29 @@ Open-source, just-in-time cloud node provisioner for Kubernetes. 1. [TL;DR](#tldr) 1. [Setup](#setup) + 1. [AWS](#aws) 1. [Further readings](#further-readings) 1. [Sources](#sources) ## TL;DR -Karpenter works by: +Runs as workload on the cluster. + +Works by: 1. Watching for unschedulable pods. 1. Evaluating unschedulable pods' scheduling constraints (resource requests, node selectors, affinities, tolerations, and topology spread constraints). -1. Provisioning **cloud-based** nodes meeting the requirements of unschedulable pods. +1. Provisioning **cloud-based** nodes meeting the resource requirements and scheduling constraints of unschedulable + pods. 1. Deleting nodes when no longer needed. -Karpenter runs as workload on the cluster. +Under the hood, Karpenter adds a finalizer to the Kubernetes node object it provisions.
+The finalizer blocks node deletion until all pods on it are drained and the instance is terminated.
+This **only** works for nodes provisioned by Karpenter. -Should one manually delete a Karpenter-provisioned node, Karpenter will gracefully cordon, drain, and shutdown the -corresponding instance.
-Under the hood, Karpenter adds a finalizer to the node object it provisions. This blocks deletion until all pods are -drained and the instance is terminated. This **only** works for nodes provisioned by Karpenter. +Should one manually delete a Karpenter-provisioned Kubernetes node object, Karpenter will gracefully cordon, drain, and +shutdown the corresponding cloud instance.
Setup @@ -71,10 +75,33 @@ helm … \ Karpenter's controller and webhook deployment are designed to run as a workload on the cluster. -As of 2024-12-24, it only supports AWS and Azure nodes.
+As of 2025-06-08, it only supports AWS and Azure nodes.
As part of the installation process, one **will** need credentials from the underlying cloud provider to allow Karpenter-managed nodes to be started up and added to the cluster as needed. +Karpenter configuration comes in the form of: + +- A _NodePool_ Custom Resource Definition. +- A _NodeClass_ Custom Resource Definition.
+ Its specifics are defined by the cloud provider's implementation. + +A single Karpenter NodePool is capable of handling many different pod shapes.
+A cluster may have more than one NodePool. + +### AWS + +Leverages the [Karpenter provider for AWS]. + +Requirements: + +- An IAM Role for Karpenter.
+ Required to allow Karpenter to call AWS APIs. +- An IAM Role and an instance profile for the EC2 instances Karpenter creates. +- An EKS cluster access entry for the nodes' IAM role.
+ Required by the nodes to be able to join the EKS cluster. +- An SQS queue for Karpenter.
+ Required to receive Spot interruption, instance re-balance and other events. + ## Further readings - [Website] @@ -83,6 +110,11 @@ Karpenter-managed nodes to be started up and added to the cluster as needed. ### Sources +- [Karpenter EKS workshop] +- [Karpenter: Amazon EKS Best Practice and Cloud Cost Optimization] +- [Run Kubernetes Clusters for Less with Amazon EC2 Spot and Karpenter] +- [Karpenter best practices] + +[Karpenter best practices]: https://docs.aws.amazon.com/eks/latest/best-practices/karpenter.html +[Karpenter EKS workshop]: https://www.eksworkshop.com/docs/autoscaling/compute/karpenter/ +[Karpenter provider for AWS]: https://github.com/aws/karpenter-provider-aws +[Karpenter: Amazon EKS Best Practice and Cloud Cost Optimization]: https://catalog.us-east-1.prod.workshops.aws/workshops/f6b4587e-b8a5-4a43-be87-26bd85a70aba/en-US +[Run Kubernetes Clusters for Less with Amazon EC2 Spot and Karpenter]: https://community.aws/content/2dhlDEUfwElQ9mhtOP6D8YJbULA/run-kubernetes-clusters-for-less-with-amazon-ec2-spot-and-karpenter