Pod Priority는 다른 Pod에 비해 Pod의 중요도를 적용하는데 사용된다. 이 섹션에서는 두 개를 만들고 PriorityClass Pod의 상호 작용을 확인 한다.
ㅁ PriorityClass 만들기
cat <<EoF > ~/environment/resource-management/high-priority-class.yml
apiVersion: scheduling.k8s.io/v1
kind: PriorityClass
metadata:
name: high-priority
value: 100
globalDefault: false
description: "High-priority Pods"
EoF
kubectl apply -f ~/environment/resource-management/high-priority-class.yml
cat <<EoF > ~/environment/resource-management/low-priority-class.yml
apiVersion: scheduling.k8s.io/v1
kind: PriorityClass
metadata:
name: low-priority
value: 50
globalDefault: false
description: "Low-priority Pods"
EoF
kubectl apply -f ~/environment/resource-management/low-priority-class.yml
PriorityClass가 없이 생성된 Pods는 0이다. Global PriorityClass가 할당될 수 있다 추가적인 정보를 보려면 여기를 클릭한다.
ㅁ Deploy low-priority Pods
cat <<EoF > ~/environment/resource-management/low-priority-deployment.yml
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: nginx-deployment
name: nginx-deployment
spec:
replicas: 50
selector:
matchLabels:
app: nginx-deployment
template:
metadata:
labels:
app: nginx-deployment
spec:
priorityClassName: "low-priority"
containers:
- image: nginx
name: nginx-deployment
resources:
limits:
memory: 1G
EoF
kubectl apply -f ~/environment/resource-management/low-priority-deployment.yml
사용 가능한 Pod가 Deployment 수를 중심으로 안정화 될때까지에서 사용 가능한 Pod 수를 확인한다. 노드가 포드로 완전히 채워졌는지 확인하고 안정화 되는데 최대 2분이 소요될 수 있다.
kubectl get deployment nginx-deployment --watch
ㅁ Deploy High Priority Pod
cat <<EoF > ~/environment/resource-management/high-priority-deployment.yml
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: high-nginx-deployment
name: high-nginx-deployment
spec:
replicas: 5
selector:
matchLabels:
app: high-nginx-deployment
template:
metadata:
labels:
app: high-nginx-deployment
spec:
priorityClassName: "high-priority"
containers:
- image: nginx
name: high-nginx-deployment
resources:
limits:
memory: 1G
EoF
kubectl apply -f ~/environment/resource-management/high-priority-deployment.yml
수행해 보면 high-priority-deployment가 수행되면서 기존 low-priority로 만들어진 pod가 삭제됨을 볼 수 있다.
'AWS EKS 실습 > EKS Intermediate' 카테고리의 다른 글
Deploying Jenkins for Kubernetes (0) | 2021.03.19 |
---|---|
Advanced POD CPU and Memory management (0) | 2021.03.18 |
Resource Quotas (0) | 2021.03.18 |
Resource management 기본 (0) | 2021.03.18 |
OPA Policy - Example 1: 승인된 Container Registry 만 사용하도록 정책 정의 (0) | 2021.03.18 |