Net Eng

[CKA] - Node Labels & nodeSelector 본문

Cloud/Kubernetes

[CKA] - Node Labels & nodeSelector

欲心 2024. 1. 21. 07:37

[선수 지식]

파드 스케줄링(Pod Scheduling)

* Node Labels/nodeSelector

* Affinity/Antiaffinity

- Node Affinity

- Pod Affinity

* Node Taints, Pod Tolerations

+

* drain

* cordon/uncordon

 


 

[선수 작업]

kubectl config set-context k8s --user=kubernetes-admin --cluster=kubernetes
kubectl label node node01 disktype=ssd

 


 

[문제]

Schedule a pod as follows:

name: eshop-store

image: nginx

node selector: disktype=ssd

작업 클러스터: k8s


 

[풀이]

kubectl config use-context k8s

* k8s 클러스터 사용

 

kubectl get nodes --show-labels
kubectl get nodes -L disktype

* node의 label 확인 (disktype)

 

kubectl run eshop-store --image=nginx --dry-run=client -o yaml > eshop-store.yaml

* dry-run 명령어로 eshop-store.yaml 파일 생성

 

apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: eshop-store
  name: eshop-store
spec:
  containers:
  - image: nginx
    name: eshop-store
    resources: {}
  nodeSelector:
    disktype: ssd
  dnsPolicy: ClusterFirst
  restartPolicy: Always
status: {}

* yaml 파일에 nodeSelector 항목 추가 (Containers와 같은 레벨)

 

kubectl apply -f eshop-store.yaml

* yaml 파일 실행

 

kubectl get pods -o wide

* Pod 실행 확인

 


 

[참고]

 

노드에 파드 할당하기

특정한 노드(들) 집합에서만 동작하거나 특정한 노드 집합에서 동작하는 것을 선호하도록 파드를 제한할 수 있다. 이를 수행하는 방법에는 여러 가지가 있으며 권장되는 접근 방식은 모두 레이

kubernetes.io

 

 

Assign Pods to Nodes

This page shows how to assign a Kubernetes Pod to a particular node in a Kubernetes cluster. Before you begin You need to have a Kubernetes cluster, and the kubectl command-line tool must be configured to communicate with your cluster. It is recommended to

kubernetes.io

 

 

Assign Pods to Nodes

This page shows how to assign a Kubernetes Pod to a particular node in a Kubernetes cluster. Before you begin You need to have a Kubernetes cluster, and the kubectl command-line tool must be configured to communicate with your cluster. It is recommended to

kubernetes.io

 

'Cloud > Kubernetes' 카테고리의 다른 글

[CKA] - Node 정보 수집  (0) 2024.01.21
[CKA] - Node 관리  (0) 2024.01.21
[CKA] - Rolling update & Roll Back  (0) 2024.01.19
[CKA] - Deployment & Pod Scale  (0) 2024.01.19
[CKA] - Side-car Container Pod 생성하기  (0) 2024.01.19