이번엔 PriorityClass 에 대해 정리하고자 한다.
1. 정의
- Pod 가 얼마나 중요한지(우선순위)를 정의하는 리소스
2. 특징
- 스케줄링 우선순위 결정
- Preemption(선점) 동작
> 자원이 부족할 때 높은 우선순위 Pod 는 낮은 우선순위 Pod 를 제거(evict) 하여 자리를 차지할 수 있음
- 시스템 핵심 서비스 보호
> kube-system 리소스처럼 중요한 Pod 는 높은 priority 로 설정해 노드 리소스 부족 시 제거되지 않도록 보호
3. 관련 문제 (KodeKloud 에서 제공하는 샘플 문제를 정리)
- Which of the following PriorityClasses are part of a default Kubernetes setup?
kubectl get priorityclass
- Create a PriorityClass named high-priority, a value of 100000, and a preemption policy of PreemptLowerPriority. Do not set this class as a global default.
vi high-priority.yaml
apiVersion: scheduling.k8s.io/v1
kind: PriorityClass
metadata:
name: high-priority
value: 100000
globalDefault: false
preemptionPolicy: PreemptLowerPriority
kubectl apply -f high-priority.yaml
kubectl get priorityclass
- In the default namespace, create a pod named low-prio-pod that runs an nginx image and uses the low-priority PriorityClass.
vi low-prio-pod.yaml
apiVersion: v1
kind: Pod
metadata:
name: low-prio-pod
spec:
containers:
- name: nginx
image: nginx
priorityClassName: low-priority
kubectl apply -f low-prio-pod.yaml
- To resolve this situation and get the critical-app to a running state, you should:
> Assign the high-priority class to the critical-app. Delete and recreate the pod with the new priority. Make sure the pod is in running state after applying the actions.
kubectl get pod critical-app -o yaml > critical-app.yaml
-- add priorityClassName: high-priority under the spec field.
-- remove the line priority: 0 if it exists in the spec to avoid conflicting priority settings.
kubectl delete pod critical-app
kubectl apply -f critical-app.yaml
kubectl get pod critical-app
4. 출처
'IT > Kubernetes' 카테고리의 다른 글
| [CKA] PV(PersistentVolume) 란? (0) | 2025.11.22 |
|---|---|
| [CKA] StorageClass 란? (0) | 2025.11.21 |
| [CKA] Deployment 란? (0) | 2025.11.21 |
| [CKA] ReplicaSet 이란? (0) | 2025.11.21 |
| [CKA] Pod 란? (0) | 2025.11.20 |