Recent Comments
Link
Recent Posts
Today
Total
«   2025/03   »
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31
관리 메뉴

Study Memory Work

[K8S/CKA 자격증] Worloads & Scheduling - pod scheduling 본문

Infra/Kubernetes

[K8S/CKA 자격증] Worloads & Scheduling - pod scheduling

Hera Choi 2023. 1. 22. 17:28

pod scheduling

  • 특정 pod를 특정 node에서 실행시키고자 할 때 사용한다.
  • node label 과 node select를 통해서 운영된다.
  • node에 node lable을 설정해두고, deyployment를 이용하여 pod를 생성할 때 nodeSelector에 node label과 같은 value값을 설정해 놓으면, 해당 pod는 해당 lable이 설정되어있는 node에서만 실행된다.

node2, 3에 'gpu:true'라는 node label을 설정해 놓고, pod 생성 시, nodeSelector에 gpu:"true"옵션을 주면, 해당 Podsms node2,3에서만 생성된다.

  • node lable 관련 명령어
# node의 label 정보 보기
$ kubectl get nodes --show-labels

# node에 label 추가하기
$ kubectl labal {node Name} gpu=true

# label기준으로 node 조회하기
$ kubel get node -L gpu

# label value값 변경하기
$ kubectl labal {node Name} gpu=false --overwrite

# label 삭제하기
$ kubectl labal {node Name} gpu-
  • node selector 추가하기
apiVersion: v1
kind: Pod
metadata:
  name: nginx
  labels:
    env: test
spec:
  containers:
  - name: nginx
    image: nginx
    imagePullPolicy: IfNotPresent
  nodeSelector:			# node label과 같은 kwy,value 넣어주기
    gpu: true

[문제10] Pod Scheduling

작업 클러스터 : k8s
다음의 조건으로 pod를 생성하세요.

  • Name: eshop-store
  • Image: nginx
  • Node selector: disktype=ssd
  •  
# 1. label 존재여부 체크
$ kubectl get nodes -L disktype


# 2. pod 생성
$ kubectl run eshop-store --image-nginx --dry-run=client -o yaml > eshop.yaml
$ vi eshop.yaml

####
...
spec:
  containers:
  - name: eshop-store
    image: nginx
  nodeSelector:
    disktype: ssd
...
####

$ kubectl apply -f eshop.yaml


# 3. 확인
$ kubectl get pods -o wide