CKA Recap Pod Schedule

This is a quick recap for the points of pod schedual, details can click each title link or the final reference.

1. Affinity

  • nodeAffinity and nodeAntiAffinity

    • node labels
  • podAffinity and podAntiAffinity

    • pod labels
  • requiredDuringSchedulingIgnoredDuringExecution and preferredDuringSchedulingIgnoredDuringExecution

  • topologyKey

2. nodeName/nodeSelector

spec:
  containers:
  - name: nginx
    image: nginx
    imagePullPolicy: IfNotPresent
  nodeSelector:
    disktype: ssd
---
spec:
  nodeName: foo-node # schedule pod to specific node
  containers:
  - name: nginx
    image: nginx
    imagePullPolicy: IfNotPresent

3. Taint/Tolerations

CMD

k taint node NAME key[:value]:[EFFECT]
k describe node NAME | grep -i taint

yaml

tolerations:
- key: "example-key"
  operator: "Exists"
  effect: "NoSchedule"
- key: "key1"
  operator: "Equal"
  value: "value1"
  effect: "NoExecute"

4. Priority

The larger the higher

priorityclass

k get priorityclass

yaml

spec:
  containers:
  - name: nginx
    image: nginx
    imagePullPolicy: IfNotPresent
  priorityClassName: high-priority

Reference

Different way to assign Pods to Nodes Assign Pods to Nodes Pod Priority and Preemption