Updated:

CKA - scheduling

1. Manual Scheduling

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

2. Selector

$ kubectl get pods --selector {KEY}={VALUE}

3. Taints and Tolerations

  • 특정 POD만 스케줄링을 원할 때

  • Taints (Node)

$ kubectl taint nodes {node name} {key}={value}:{NoSchedule | PreferNoSchedule | NoExecute}
  • Toleration (Pod)
apiVersion: v1
kind: Pod
metadata:
  name: nginx
  labels:
    env: test
spec:
  containers:
  - name: nginx
    image: nginx
  tolerations:
  - key: "example-key"
    operator: "Exists"
    effect: "NoSchedule"

4. Node Selectors and Node Affinity

$ kubectl label nodes {node name} {key}={value}
  • Node Selector
apiVersion: v1
kind: Pod
metadata:
  name: nginx
  labels:
    env: test
spec:
  containers:
  - name: nginx
    image: nginx
  nodeSelector:
    {key}: {value}
  • Node Affinity
apiVersion: v1
kind: Pod
metadata:
  name: nginx
  labels:
    env: test
spec:
  containers:
  - name: nginx
    image: nginx
  affinity:
    nodeAffinity:
      requiredDuringSchedulingIgnoredDuringExecution:
        nodeSelectorTerms:
        - matchExpressions:
          - key : {key}
            operator: Exists

5. DaemonSet

  • 특정 노드 또는 모든 노드에 항상 실행되어야 할 특정 pod을 관리
  • use case : kube-proxy, networking
$ kubectl get ds

6. Static Pods

  • kube-api-server 없이 worker node 혼자서 pod을 띄울 경우
  • 오직 pod만 가능하며, deployment나 service 등은 안됨
  • use case : master node의 pod (apiserver, etcd, controller-manager)
$ vi /etc/kubernetes/manifests/{pod}.yaml

# path configuration
$ vi /var/lib/kubelet/config.yaml

7. Multiple Scheduler

  • 2개 이상의 scheduler가 있을 경우, pod마다 scheduler를 지정할 수 있음
# default scheduler
$ vi /etc/kubernetes/manifests/kube-scheduler.yaml
apiVersion: v1
kind: Pod
metadata:
  name: nginx
  labels:
    env: test
spec:
  containers:
  - name: nginx
    image: nginx
  schedulerName: {scheduler name}

Leave a comment