DevOps/Kubernetes

Kubernetes::스케쥴링 (Scheduling)

yscho03 2023. 12. 19. 22:44
728x90
반응형

수동 스케쥴링 (Manual Scheduling)

클러스터에 스케줄러가 없을 때 수동으로 처리하는 방법이다.
POD에는 기본적으로 설정되지 않은 NodeName이라는 필드가 있는데 이 필드를 설정하여 수동으로 스케쥴링 하는 방법이다.

apiVersion: v1
kind: Pod
metadata:
 name: nginx
 labels:
  name: nginx
spec:
 containers:
 - name: nginx
   image: nginx
   ports:
   - containerPort: 8080
 nodeName: node02

또 다른 방법

apiVersion: v1
kind: Binding
metadata:
  name: nginx
target:
  apiVersion: v1
  kind: Node
  name: node02
apiVersion: v1
kind: Pod
metadata:
 name: nginx
 labels:
  name: nginx
spec:
 containers:
 - name: nginx
   image: nginx
   ports:
   - containerPort: 8080

 

레이블 및 선택자 (Labels and Selectors)

Labels and Selectors

  • 레이블과 선택자는 항목을 그룹화하는 표준 방법이다.
  • 레이블은 각 항목에 첨부된 속성이다.
 apiVersion: v1
 kind: Pod
 metadata:
  name: simple-webapp
  labels:
    app: App1
    function: Front-end
 spec:
  containers:
  - name: simple-webapp
    image: simple-webapp
    ports:
    - containerPort: 8080
 apiVersion: apps/v1
 kind: ReplicaSet
 metadata:
   name: simple-webapp
   labels:
     app: App1
     function: Front-end
 spec:
  replicas: 3
  selector:
    matchLabels:
     app: App1
 template:
   metadata:
     labels:
       app: App1
       function: Front-end
   spec:
     containers:
     - name: simple-webapp
       image: simple-webapp   
  apiVersion: v1
  kind: Service
  metadata:
   name: my-service
  spec:
   selector:
     app: App1
   ports:
   - protocol: TCP
     port: 80
     targetPort: 9376 

Annotations

레이블과 선택기는 개체를 그룹화하는 데 사용되지만 주석은 정보 제공 목적으로 기타 세부 정보를 기록하는 데 사용된다.

apiVersion: apps/v1
kind: ReplicaSet
metadata:
  name: simple-webapp
  labels:
    app: App1
    function: Front-end
  annotations:
     buildversion: 1.34
spec:
 replicas: 3
 selector:
   matchLabels:
    app: App1
template:
  metadata:
    labels:
      app: App1
      function: Front-end
  spec:
    containers:
    - name: simple-webapp
      image: simple-webapp   

 

Taints and Tolerations

Taints 및 Tolerations는 노드에서 예약할 수 있는 파드에 대한 제한을 설정하는 데 사용된다.
노드의 특정 taint에 허용되는 파드에만 해당 노드에서 예약된다.

Taints

3가지 효과를 줄 수 있다.

  • NoSchedule : 해당 노드에 POD를 예약하지 않는다.
  • PreferNoSchedule : POD를 노드에 예약하지 않으려고 시도한다.
  • NoExecute : 노드에서 제거되고(노드에서 이미 실행 중인 경우) 노드에서 예약되지 않는다.
$ kubectl taint nodes node1.example.com app=blue:NoSchedule

Tolerations

POD 정의에 tolerations 섹션을 추가하여 설정합니다.

apiVersion: v1
kind: Pod
metadata:
 name: myapp-pod
spec:
 containers:
 - name: nginx-container
   image: nginx
 tolerations:
 - key: "app"
   operator: "Equal"
   value: "blue"
   effect: "NoSchedule"
728x90
반응형