Karpenter custom Nodepool as default
Configure custom nodepool as your primary
EKS Auto mode comes with pre-installed Karpenter Autoscaler, default NodeClass and a default Nodepool. Default Nodepool is configured to provision
AMD
architecture, on-demand
servers. While this makes it easy to get started, many organizations have complex requirements like deploying specific CPU or GPU instances, or making use of SPOT
or Reserved
instances to save cost.
Custom NodePool as default
The default NodePool provided by AWS cannot be modified, however Karpenter allows you to order your NodePools using the spec.weight field so that the Karpenter scheduler will attempt to schedule one NodePool before another. This field can be used to define custom NodePool
that will have higher priority than default NodePool.
Nodepool with Spot and on-demanad instances
In this example, I am creating a custom Nodepool that has priority over default NodePool. This NodePool will provision SPOT
and On-Demanad
instances. Karpenter aims to provision most cost effective instances, which are often Spot
instances. You can achieve split of On-Demanad
vsSpot
instances using On-Demand/Spot Ratio Split or by provisioning 2 nodepools with same weight.
primary-nodepool.yaml
apiVersion: karpenter.sh/v1
kind: NodePool
metadata:
name: primary-nodepool
spec:
weight: 50
template:
spec:
expireAfter: 336h
nodeClassRef:
group: eks.amazonaws.com
kind: NodeClass
name: default
requirements:
- key: karpenter.sh/capacity-type
operator: In
values: ["spot","on-demand"]
- key: eks.amazonaws.com/instance-category
operator: In
values: ["c","m","r"]
- key: eks.amazonaws.com/instance-generation
operator: Gt
values: ["5"]
- key: kubernetes.io/arch
operator: In
values:
- amd64
- key: kubernetes.io/os
operator: In
values:
- linux
terminationGracePeriod: 24h0m0s
If you have purchased a Savings
Plan or Reserved
Instances, this methodcan be used to make Karpenter to prioritize this reserved capacity ahead of other instance types.