Karpenter NodePools: 노드 프로비저닝의 기준 정하기
Karpenter를 NodePool로 구성하는 방법을 설명하는 문서예요. NodePool이 노드 생성에 걸어 두는 제약(taints, requirements, 만료)부터 정적 용량(replicas), 리소스 한도, 가중치, 상태 조건과 실전 예제까지 정리했어요.
출처: Karpenter 문서
본문
Karpenter를 처음 설치하면 기본 NodePool을 하나 만들게 돼요. NodePool은 Karpenter가 만들 수 있는 노드와 그 노드 위에서 실행될 수 있는 파드에 제약을 겁니다. NodePool에는 이런 일을 시킬 수 있어요.
- Karpenter가 만드는 노드에서 실행될 수 있는 파드를 제한하는 taint를 정의해요.
- 노드에 처음에 테인트를 붙이되 그 테인트가 임시라는 걸 Karpenter에게 알려 주는 startup taint를 정의합니다.
- 노드 생성을 특정 존, 인스턴스 타입, 컴퓨팅 아키텍처로 제한해요.
- 노드 만료의 기본값을 설정합니다.
NodePool을 변경하거나 NodePool을 더 추가할 수도 있어요. NodePool을 다룰 때 알아둘 점은 이렇습니다.
- NodePool이 하나도 구성돼 있지 않으면 Karpenter는 아무 것도 하지 않아요.
- 구성된 각 NodePool은 Karpenter가 순회하며 살펴봅니다.
- NodePool에 파드가 허용(tolerate)하지 않는 taint가 있으면 Karpenter는 그 NodePool로 그 파드를 프로비저닝하지 않아요.
- NodePool에 startup taint가 있으면 프로비저닝되는 노드에 적용되지만, 파드가 그 테인트를 허용할 필요는 없어요. Karpenter는 테인트가 임시이고 다른 시스템이 제거할 거라고 가정합니다.
- NodePool은 서로 배타적으로 만드는 걸 권장해요. 파드가 여러 NodePool에 매칭되지 않게 하는 거죠. 여러 NodePool이 매칭되면 Karpenter는 weight가 가장 높은 NodePool을 사용합니다.
참고
Kubelet 기능을 설정하는 객체들은 다른 Karpenter 프로바이더가 그 기능들을 지원할 필요가 없도록, NodePool spec에서 EC2NodeClasses spec으로 옮겨졌어요.
NodePool 구성 예시는 Karpenter GitHub 저장소의 예제를 보세요.
apiVersion: karpenter.sh/v1
kind: NodePool
metadata:
name: default
spec:
# Template section that describes how to template out NodeClaim resources that Karpenter will provision
# Karpenter will consider this template to be the minimum requirements needed to provision a Node using this NodePool
# It will overlay this NodePool with Pods that need to schedule to further constrain the NodeClaims
# Karpenter will provision to launch new Nodes for the cluster
template:
metadata:
# Labels are arbitrary key-values that are applied to all nodes
labels:
billing-team: my-team
# Annotations are arbitrary key-values that are applied to all nodes
annotations:
example.com/owner: "my-team"
spec:
# References the Cloud Provider's NodeClass resource, see your cloud provider specific documentation
nodeClassRef:
group: karpenter.k8s.aws # Updated since only a single version will be served
kind: EC2NodeClass
name: default
# Provisioned nodes will have these taints
# Taints may prevent pods from scheduling if they are not tolerated by the pod.
taints:
- key: example.com/special-taint
effect: NoSchedule
# Provisioned nodes will have these taints, but pods do not need to tolerate these taints to be provisioned by this
# NodePool. These taints are expected to be temporary and some other entity (e.g. a DaemonSet) is responsible for
# removing the taint after it has finished initializing the node.
startupTaints:
- key: example.com/another-taint
effect: NoSchedule
# The amount of time a Node can live on the cluster before being removed
# Avoiding long-running Nodes helps to reduce security vulnerabilities as well as to reduce the chance of issues that can plague Nodes with long uptimes such as file fragmentation or memory leaks from system processes
# You can choose to disable expiration entirely by setting the string value 'Never' here
# Note: changing this value in the nodepool will drift the nodeclaims.
expireAfter: 720h | Never
# The amount of time that a node can be draining before it's forcibly deleted. A node begins draining when a delete call is made against it, starting
# its finalization flow. Pods with TerminationGracePeriodSeconds will be deleted preemptively before this terminationGracePeriod ends to give as much time to cleanup as possible.
# If your pod's terminationGracePeriodSeconds is larger than this terminationGracePeriod, Karpenter may forcibly delete the pod
# before it has its full terminationGracePeriod to cleanup.
# Note: changing this value in the nodepool will drift the nodeclaims.
terminationGracePeriod: 48h
# Requirements that constrain the parameters of provisioned nodes.
# These requirements are combined with pod.spec.topologySpreadConstraints, pod.spec.affinity.nodeAffinity, pod.spec.affinity.podAffinity, and pod.spec.nodeSelector rules.
# Operators { In, NotIn, Exists, DoesNotExist, Gt, Lt, Gte, and Lte } are supported.
# https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#operators
requirements:
- key: "karpenter.k8s.aws/instance-category"
operator: In
values: ["c", "m", "r"]
# minValues here enforces the scheduler to consider at least that number of unique instance-category to schedule the pods.
# This field is ALPHA and can be dropped or replaced at any time
minValues: 2
- key: "karpenter.k8s.aws/instance-family"
operator: In
values: ["m5","m5d","c5","c5d","c4","r4"]
minValues: 5
- key: "karpenter.k8s.aws/instance-cpu"
operator: In
values: ["4", "8", "16", "32"]
- key: "karpenter.k8s.aws/instance-hypervisor"
operator: In
values: ["nitro"]
- key: "karpenter.k8s.aws/instance-generation"
operator: Gte
values: ["3"]
- key: "topology.kubernetes.io/zone"
operator: In
values: ["us-west-2a", "us-west-2b"]
- key: "kubernetes.io/arch"
operator: In
values: ["arm64", "amd64"]
- key: "karpenter.sh/capacity-type"
operator: In
values: ["spot", "on-demand", "reserved"]
# Disruption section which describes the ways in which Karpenter can disrupt and replace Nodes
# Configuration in this section constrains how aggressive Karpenter can be with performing operations
# like rolling Nodes due to them hitting their maximum lifetime (expiry) or scaling down nodes to reduce cluster cost
disruption:
# Describes which types of Nodes Karpenter should consider for consolidation
# If using 'WhenEmptyOrUnderutilized', Karpenter will consider all nodes for consolidation and attempt to remove or replace Nodes when it discovers that the Node is empty or underutilized and could be changed to reduce cost
# If using 'Balanced', Karpenter considers the same nodes as 'WhenEmptyOrUnderutilized' but only consolidates when the estimated savings are worth the disruption to running pods
# If using `WhenEmpty`, Karpenter will only consider nodes for consolidation that contain no workload pods
consolidationPolicy: WhenEmptyOrUnderutilized | Balanced | WhenEmpty
# The amount of time Karpenter should wait to consolidate a node after a pod has been added or removed from the node.
# You can choose to disable consolidation entirely by setting the string value 'Never' here
# Optional, defaults to '0s'
consolidateAfter: 1m | Never # Added to allow additional control over consolidation aggressiveness
# Budgets control the speed Karpenter can scale down nodes.
# Karpenter will respect the minimum of the currently active budgets, and will round up
# when considering percentages. Duration and Schedule must be set together.
budgets:
- nodes: 10%
# On Weekdays during business hours, don't do any deprovisioning.
- schedule: "0 9 * * mon-fri"
duration: 8h
nodes: "0"
# Optional: Number of nodes to maintain for static capacity
# When set, NodePool operates in static mode maintaining fixed node count
replicas: 5
# Resource limits constrain the total size of the pool.
# Limits prevent Karpenter from creating new instances once the limit is exceeded.
limits:
cpu: "1000"
memory: 1000Gi
# limits.nodes constrains maximum node count during scaling/drift
nodes: 10
# Priority given to the NodePool when the scheduler considers which NodePool
# to select. Higher weights indicate higher priority when comparing NodePools.
# Specifying no weight is equivalent to specifying a weight of 0.
# Note: weight cannot be set when replicas is specified
weight: 10
status:
conditions:
- type: Initialized
status: "False"
observedGeneration: 1
lastTransitionTime: "2024-02-02T19:54:34Z"
reason: NodeClaimNotLaunched
message: "NodeClaim hasn't succeeded launch"
# Current node count for the NodePool
nodes: 5
resources:
cpu: "20"
memory: "8192Mi"
ephemeral-storage: "100Gi"
metadata.name
NodePool의 이름이에요.
spec.template.metadata.labels
모든 노드에 적용할 임의의 키/값 쌍이에요.
spec.template.metadata.annotations
모든 노드에 적용할 임의의 키/값 쌍이에요.
spec.template.spec.nodeClassRef
이 필드는 클라우드 프로바이더의 NodeClass 리소스를 가리켜요. 자세한 내용은 EC2NodeClasses를 참고하세요.
spec.template.spec.taints
프로비저닝된 노드에 추가할 테인트예요. 이 테인트를 허용하지 않는 파드는 스케줄링이 막힐 수 있습니다. 자세한 내용은 Taints and Tolerations를 참고하세요.
spec.template.spec.startupTaints
에이전트 시작이나 네트워킹 설정 같은 특정 조건이 충족되어야 노드가 초기화될 수 있음을 나타내려고 노드에 붙이는 테인트예요. 이 테인트가 정리되기 전에는 노드에 파드를 배포할 수 없습니다.
spec.template.spec.expireAfter
노드가 Karpenter에 의해 삭제되기 전까지 클러스터에 살아 있을 수 있는 시간이에요. 만료 시간이 지나면 노드가 드레인을 시작합니다.
spec.template.spec.terminationGracePeriod
Karpenter가 노드를 강제로 정리하기 전에 노드가 드레인될 수 있는 시간이에요. PDB와 do-not-disrupt처럼 축출을 막는 파드는 terminationGracePeriod에 도달할 때까지 드레인 중에 존중되고, 그 시점에 강제로 삭제됩니다.
spec.template.spec.requirements
쿠버네티스는 Well-Known Labels를 정의하고, 클라우드 프로바이더(예: AWS)가 그걸 구현해요. 이 라벨들은 NodePool API의 "spec.requirements" 섹션에서 정의합니다.
쿠버네티스의 well-known 라벨 외에도 Karpenter는 더 정교한 스케줄링을 위한 AWS 전용 라벨을 지원해요. 전체 목록은 여기를 보세요.
이 well-known 라벨들은 NodePool 수준에서 지정하거나 워크로드 정의(예: pod.spec의 nodeSelector)에서 지정할 수 있어요. 노드는 NodePool과 파드의 requirements를 모두 사용해서 고릅니다. 겹치는 부분이 없으면 노드가 띄워지지 않아요. 다시 말해 파드의 requirements가 NodePool의 requirements 안에 들어와야 합니다. well-known 라벨에 대한 requirement가 정의돼 있지 않으면 클라우드 프로바이더가 제공하는 어떤 값이든 선택될 수 있어요.
예를 들어 파드 spec의 nodeSelector로 인스턴스 타입을 지정할 수 있죠. 요청한 인스턴스 타입이 NodePool 목록에 없고 NodePool에 인스턴스 타입 requirements가 있으면 Karpenter는 노드를 만들지 않고 파드를 스케줄링하지도 않습니다.
정적 NodePool (Static NodePool)
정적 NodePool의 requirements는 동적 풀과 동일하게 동작해요. 그 NodePool 아래에서 띄워지는 모든 NodeClaim의 제약을 정의합니다.
NodeClaim의 requirements는 NodePool의 NodeClaimTemplate에서 직접 도출돼요. 이 값은 NodeClaim 생성 시 한 번 평가되므로, 선택은 템플릿이 허용하는 것만으로 결정됩니다. 그래서 같은 정적 NodePool에 만들어진 NodeClaim이라도, 인스턴스 가용성에 따라 NodePool requirements와 호환되는 한 서로 다른 인스턴스 타입이 띄워질 수 있어요.
Well-Known Labels
인스턴스 타입 (Instance Types)
- key:
node.kubernetes.io/instance-type - key:
karpenter.k8s.aws/instance-family - key:
karpenter.k8s.aws/instance-category - key:
karpenter.k8s.aws/instance-generation - key:
karpenter.k8s.aws/instance-capability-flex
일반적으로 인스턴스 타입은 단일 값이 아니라 목록으로 지정해야 해요. 이 requirements를 정의하지 않은 채 두는 것을 권장합니다. 파드를 효율적으로 배치할 선택지를 최대로 넓히거든요.
AWS 인스턴스 타입을 검토해 보세요. 대부분의 인스턴스 타입이 지원되고 non-HVM만 제외예요.
가용 영역 (Availability Zones)
- key:
topology.kubernetes.io/zone - value 예시:
us-east-1c - value 목록:
aws ec2 describe-availability-zones --region <region-name>
Karpenter를 구성해서 특정 존에 노드를 만들 수 있어요. 참고로 여러분의 AWS 계정에서의 가용 영역 us-east-1a는 다른 AWS 계정의 us-east-1a와 같은 위치가 아닐 수 있습니다.
아키텍처 (Architecture)
- key:
kubernetes.io/arch - values
amd64arm64
Karpenter는 amd64 노드와 arm64 노드를 지원해요.
운영체제 (Operating System)
- key:
kubernetes.io/os - values
linuxwindows
Karpenter는 linux와 windows 운영체제를 지원합니다.
용량 타입 (Capacity Type)
- key:
karpenter.sh/capacity-type - values
spoton-demandreserved
Karpenter는 용량 타입 지정을 지원하며, EC2 구매 옵션에 해당하는 개념이에요. reserved 용량 타입은 예약 인스턴스(RIs)가 아니라 용량 예약(on-demand capacity reservations와 capacity blocks)을 가리킨다는 점에 주의하세요.
NodePool이 여러 용량 타입과 호환되면 Karpenter는 reserved를 먼저, 다음으로 spot, 마지막으로 on-demand 순서로 우선시해요. 프로바이더 API(예: EC2 Fleet API)가 용량을 사용할 수 없다고 알려주면, Karpenter는 그 인스턴스 타입과 존 조합에 대한 EC2 용량 프로비저닝 시도 전체에 걸쳐 그 결과를 3분간 캐시합니다. 더 높은 우선순위 용량 타입에 다른 선택지가 없으면, Karpenter는 일반적으로 밀리초 단위로 낮은 우선순위 용량 타입으로 폴백을 시도해요.
Karpenter는 karpenter.sh/capacity-type을 토폴로지 스프레드를 강제하는 토폴로지 키로도 사용할 수 있습니다.
테넌시 (Tenancy)
- key:
karpenter.k8s.aws/instance-tenancy - values
defaultdedicated
Karpenter는 테넌시 타입 지정을 지원해요.
NodeClaim이 dedicated 테넌시를 요구하면 Dedicated Instance에 띄워집니다. NodeClaim이 이 라벨을 지정하지 않았거나 두 타입이 모두 허용되면 default 테넌시로 띄워요.
참고
현재 NodePool과 NodeClaim 양쪽의 requirements 총수에는 100개 제한이 있어요.
spec.template.metadata.labels도 NodeClaim이 생성될 때 requirements로 전파되므로, NodePool에 requirements와 라벨을 합쳐 100개를 넘게 설정할 수 없다는 점에 주의하세요.
Min Values
requirements의 [key, operator, values] 조합에 더해, Karpenter는 NodePool requirements 블록에서 minValues도 지원해요. 파드를 클러스터에 스케줄링하면서 사용자가 지정한 유연성 최소치를 스케줄러가 알 수 있게 하는 거죠. --min-values-policy 플래그나 MIN_VALUES_POLICY 환경 변수로 구성한 정책에 따라, Karpenter가 파드 스케줄링 시 각 key에 대해 이 최소 유연성을 충족하지 못하면 두 가지 중 하나로 동작합니다. 정책이 Strict면 그 NodePool의 스케줄링 루프를 실패시켜요. 파드 요구를 충족하는 다른 NodePool로 폴백하거나 파드 스케줄링 자체를 실패시킵니다. 정책이 BestEffort면 minValues를 충족될 때까지 완화해요.
Spot 인스턴스를 쓰려면 requirements에 karpenter.sh/capacity-type: spot을 지정하세요. 예를 들어 아래 spec은 정의된 각 key에 minValues를 강제합니다. 파드를 스케줄링하려면 [c,m,r]에서 유니크한 인스턴스 카테고리 2개 이상, 유니크한 인스턴스 패밀리 5개 이상(예: "m5","m5d","r4","c5","c5d","c4" 등), 유니크한 인스턴스 타입 10개 이상(예: "c5.2xlarge","c4.xlarge" 등)이 필요해요.
spec:
template:
spec:
requirements:
- key: kubernetes.io/arch
operator: In
values: ["amd64"]
- key: kubernetes.io/os
operator: In
values: ["linux"]
- key: karpenter.sh/capacity-type
operator: In
values: ["spot"]
- key: karpenter.k8s.aws/instance-category
operator: In
values: ["c", "m", "r"]
minValues: 2
- key: karpenter.k8s.aws/instance-family
operator: Exists
minValues: 5
- key: node.kubernetes.io/instance-type
operator: Exists
minValues: 10
- key: karpenter.k8s.aws/instance-generation
operator: Gte
values: ["3"]
minValues는 여러 연산자와 여러 requirements와 함께 쓸 수 있어요. 그리고 같은 requirement key에 여러 연산자로 minValues가 정의되면, 스케줄러는 그 requirement의 모든 minValues 중 최댓값을 고려합니다. 예를 들어 아래 spec은 파드를 스케줄링하려면 최소 5개의 인스턴스 패밀리를 고려하라고 스케줄러에 요구해요.
spec:
template:
spec:
requirements:
- key: kubernetes.io/arch
operator: In
values: ["amd64"]
- key: kubernetes.io/os
operator: In
values: ["linux"]
- key: karpenter.k8s.aws/instance-category
operator: In
values: ["c", "m", "r"]
minValues: 2
- key: karpenter.k8s.aws/instance-family
operator: Exists
minValues: 5
- key: karpenter.k8s.aws/instance-family
operator: In
values: ["m5","m5d","c5","c5d","c4","r4"]
minValues: 3
- key: node.kubernetes.io/instance-type
operator: Exists
minValues: 10
- key: karpenter.k8s.aws/instance-generation
operator: Gte
values: ["3"]
권장
Karpenter는 클러스터에 꼭 필요한 방식으로만 인스턴스 타입을 제한하면 NodePool을 매우 유연하게 쓸 수 있게 해 줘요. 기본값에서 Karpenter는
spec.template.spec.requirements필드의 지정을 강제하지만, 그 필드 안에 어떤 requirement도 넣으라고 강제하진 않습니다.requirements: []로 지정하면 클라우드 프로바이더가 지원하는 모든 인스턴스 타입에 완전히 유연해지는 뜻이에요. 이 기본값을 강제하진 않지만, 대부분의 사용 사례에서는 이상한 동작이나 생소한 인스턴스 타입을 피하려고 어떤 requirements라도 지정하는 걸 권장합니다. 아래는 일반 워크로드의 대부분 사용 사례에 맞을 requirements에 대한 요약 권장안이에요.
spec:
template:
spec:
requirements:
- key: kubernetes.io/arch
operator: In
values: ["amd64"]
- key: kubernetes.io/os
operator: In
values: ["linux"]
- key: karpenter.sh/capacity-type
operator: In
values: ["on-demand"]
- key: karpenter.k8s.aws/instance-category
operator: In
values: ["c", "m", "r"]
- key: karpenter.k8s.aws/instance-generation
operator: Gte
values: ["3"]
spec.disruption
NodePool을 통해 Karpenter가 노드를 중단하도록 여러 방식으로 구성할 수 있어요. spec.disruption.consolidationPolicy, spec.disruption.consolidateAfter, spec.template.spec.expireAfter를 사용할 수 있습니다. NodePool의 spec.disruption.budgets로 Karpenter의 디스럽션 속도를 제한할 수도 있어요. 자세한 내용은 Disruption을 읽어 보세요.
spec.replicas
정적 용량 모드를 켜는 선택 필드예요. 지정하면 NodePool이 파드 수요와 무관하게 고정된 수의 노드를 유지합니다.
정적 NodePool 제약:
- 한 번 설정하면 제거할 수 없어요 (NodePool은 정적·동적 모드 사이를 전환할 수 없습니다).
- limits 섹션에서는
limits.nodes만 허용돼요. weight필드를 설정할 수 없습니다.- 노드가 컨솔리데이션 대상으로 고려되지 않아요.
- 스케일 동작은 노드 디스럽션 예산을 우회하지만 PodDisruptionBudget은 지킵니다.
스케일링: kubectl scale nodepool <name> --replicas=<count>로 복제본 수를 바꾸세요.
spec.limits
NodePool spec에는 NodePool이 소비할 수 있는 리소스의 최대량을 제한하는 limits 섹션(spec.limits)이 있어요.
NodePool.spec.limits 섹션이 지정되지 않으면 리소스 할당에 기본 제한이 없다는 뜻이에요. 이 경우 최대 리소스 소비는 클라우드 프로바이더가 설정한 할당량이 결정합니다. 한도를 초과하면 몇몇 노드가 종료될 때까지 노드 프로비저닝이 막혀요.
limits.nodes 필드는 스케일링 동작이나 드리프트 교체 동안 노드 수의 최대치를 제한합니다.
apiVersion: karpenter.sh/v1
kind: NodePool
metadata:
name: default
spec:
replicas: 10
template:
spec:
requirements:
- key: karpenter.sh/capacity-type
operator: In
values: ["spot"]
limits:
cpu: 1000
memory: 1000Gi
nvidia.com/gpu: 2
# For static NodePools, only nodes limit is allowed
nodes: 20
참고
Karpenter 프로비저닝은 매우 병렬적이에요. 그래서 한도 검사는 eventual consistency로 동작하고, 빠른 스케일 아웃 중에 한도를 넘을 수 있습니다.
CPU limits는 DecimalSI 값으로 표현해요. 쿠버네티스 API가 이 값을 문자열로 강제 변환하므로, GitOps 불일치를 피하려고 정수 사용은 권장하지 않습니다.
Memory limits는 BinarySI 값(예: 1000Gi)으로 표현돼요.
클러스터의 현재 cpu와 메모리 소비는 다음 명령으로 볼 수 있어요:
kubectl get nodepool -o=jsonpath='{.items[0].status}'
resources에 대한 자세한 정보는 쿠버네티스 core API (k8s.io/api/core/v1)를 참고하세요.
spec.weight
Karpenter는 파드·노드 어피니티에서 weight를 쓰는 방식과 비슷한 weight 메커니즘으로 NodePool 선호를 표현하게 해 줘요.
NodePool 가중치에 대한 자세한 내용은 스케줄링 문서의 Weighted NodePools 섹션을 참고하세요.
status.conditions
Conditions 객체는 Karpenter에 관측 가능성 기능을 더해요.
status.conditions.type객체는Initialized나Available같은 노드 상태를 반영합니다.- 조건의 상태인
status.conditions.status는 그 조건이True인지False인지를 나타내요. status.conditions.observedGeneration은 인스턴스가.metadata.generation의 현재 상태보다 오래됐는지를 나타냅니다.status.conditions.lastTransitionTime객체는 조건의 이전 전환 시각을 나타내는 식별자를 담고 있어요.status.conditions.reason객체는 조건의 이전 전환 이유를 나타냅니다.status.conditions.message객체는 조건의 이전 전환에 대한 사람이 읽을 수 있는 세부 정보를 제공해요.
NodePool에는 다음 상태 조건이 있습니다:
| 조건 타입 | 설명 |
|---|---|
| NodeClassReady | 기반이 되는 nodeClass가 준비됨 |
| ValidationSucceeded | NodePool CRD 검증 성공 |
| NodeRegistrationHealthy | 잘못된 구성 때문에 띄워진 노드가 성공적으로 등록하지 못해 수동 조사가 필요한지를 나타냄 |
| Ready | NodePool이 준비됐는지를 나타내는 최상위 조건. NodePool의 다른 모든 조건이 true가 될 때까지 이 조건은 true가 되지 않음 |
NodeRegistrationHealthy 조건은 정보 제공용이고 최상위 Ready 조건에 영향을 주지 않아요.
NodePool이 준비되지 않았으면 스케줄링 대상으로 고려되지 않습니다.
status.nodes
이 필드는 NodePool이 관리하는 현재 노드 수를 보여줘요.
status.resources
status.resources 아래의 객체들은 cpu, memory, ephemeral-storage 같은 리소스 상태에 대한 정보를 제공합니다.
예시 (Examples)
고가 하드웨어 격리하기
특정 프로세서 타입의 노드만 프로비저닝하도록 NodePool을 구성할 수 있어요. 다음 예제는 Nvidia GPU에 대한 toleration을 가진 파드만 스케줄링되도록 테인트를 설정합니다:
apiVersion: karpenter.sh/v1
kind: NodePool
metadata:
name: gpu
spec:
disruption:
consolidationPolicy: WhenEmptyOrUnderutilized
template:
spec:
requirements:
- key: node.kubernetes.io/instance-type
operator: In
values: ["p3.8xlarge", "p3.16xlarge"]
taints:
- key: nvidia.com/gpu
value: "true"
effect: NoSchedule
이 NodePool에 정의된 노드에서 파드가 실행되려면 파드 spec에서 nvidia.com/gpu를 tolerate해야 해요.
정적 NodePool
replicas 필드를 설정하면 정적 용량으로 NodePool을 구성할 수 있어요. 파드 수요와 무관하게 고정된 수의 노드를 유지합니다. 노드를 존들에 분산하고 싶은 사용자는 아래처럼 명시적으로 할 수 있어요:
- 각각 특정 AZ에 고정된 여러 정적 NodePool을 만듭니다.
다음 예제는 복제본 10개인 정적 NodePool을 만들어요:
apiVersion: karpenter.sh/v1
kind: NodePool
metadata:
name: static-capacity
spec:
replicas: 10
template:
spec:
requirements:
- key: node.kubernetes.io/instance-type
operator: In
values: ["m5.large", "m5.xlarge"]
- key: topology.kubernetes.io/zone
operator: In
values: ["us-west-2a"] # All replicas will come up in specified zone
limits:
nodes: 15 # Maximum nodes during scaling/drift
disruption:
budgets:
- nodes: 20% # Disruption budget for drift replacement
Karpenter는 정적 NodePool에서 drifted 노드의 교체를 미리 띄우므로, limits.nodes는 replicas보다 위에 여유를 둬야 해요. limits.nodes가 replicas와 같으면 TerminateFirstDrift 기능 게이트를 켜지 않는 한 drifted 노드를 교체할 수 없습니다. Terminate-First Disruption을 참고하세요. 이건 만료(expiration)에는 영향을 주지 않아요. Karpenter는 만료된 노드를 교체를 미리 띄우지 않고 종료한 다음 replicas까지 다시 프로비저닝합니다.
Cilium Startup Taint
Cilium 문서에 따르면, Cilium이 다른 파드가 시작되기 전에 네트워킹을 구성할 수 있도록 노드에 node.cilium.io/agent-not-ready=true:NoExecute 테인트를 두는 게 권장돼요. 이건 Karpenter의 startupTaints로 구현할 수 있습니다. 이 테인트는 노드에 붙지만, 프로비저닝 대상으로 고려되기 위해 파드가 이 테인트를 허용할 필요는 없어요.
정확한 startupTaints를 제공하지 않으면 Karpenter가 새 노드를 계속 프로비저닝할 수 있어요. 새 노드가 합류하고 Karpenter가 모르는 startup taint가 붙으면, Karpenter는 Pending 파드를 이 노드에 스케줄링 불가능하다고 보게 됩니다. 그러면 Karpenter는 Pending 파드를 스케줄링하려고 또 다른 새 노드를 프로비저닝하려고 해요.
apiVersion: karpenter.sh/v1
kind: NodePool
metadata:
name: cilium-startup
spec:
disruption:
consolidationPolicy: WhenEmptyOrUnderutilized
template:
spec:
startupTaints:
- key: node.cilium.io/agent-not-ready
value: "true"
effect: NoExecute