[8] NodeSelector

NodeSelector란?

특정 Application Pod를 특정 Node에 실행시켜달라는 것

❓Schedule a pod

Reference

docs에서 nodeselector 검색

Assigning Pods to Nodes

실습

# 클러스터 전환
[user@console ~]$ kubectl config use-context k8s

# node 정보 확인 (label 정보랑 같이)
[user@console ~]$ kubectl get nodes --show-labels
NAME          STATUS
k8s-master    READY
k8s-worker1   READY
k8s-worker2   READY

# node 정보 확인 (disktype label 정보랑 같이)
[user@console ~]$ kubectl get nodes -L disktype
NAME          STATUS   DISKTYPE
k8s-master    READY
k8s-worker1   READY    ssd
k8s-worker2   READY    std

# pod 생성하기
[user@console ~]$ kubectl run eshop-store --image=nginx --dry-run=client -o yaml

# yaml 템플릿으로 yaml 파일 생성
[user@console ~]$ kubectl run eshop-store --image=nginx --dry-run=client -o yaml > eshop-store.yaml

[user@console ~]$ vi eshop-store.yaml

spec:
	nodeSelector:
		disktype: ssd
추가하기

:wq

# 수정한 yaml파일로 pod 생성
[user@console ~]$ kubectl apply -f eshop-store.yaml

# 확인
[user@console ~]$ kubectl get pods -o wide eshop-store
NODE 부분 확인하면 k8s-worker1에 생성된 것 확인

기출문제 (36번)

Schedule a pod as follows: Name: nginx-kusc00101 Image: nginx Node selector: disk=ssd


Revision #1
Created 31 May 2023 00:02:50 by 와지
Updated 20 June 2023 13:20:12 by 와지