I want one of my node only accepts some kind of pods. So I wonder, is there a way to make one node only accept those pods with some specific labels?
You have two options:
Using Node Affinity
You need to label your nodes: kubectl label nodes node1 mylabel=specialpods
Then when you launch Pods specify the affinity
:
apiVersion: v1 kind: Pod metadata: name: mypod spec: affinity: nodeAffinity: requiredDuringSchedulingIgnoredDuringExecution: nodeSelectorTerms: - matchExpressions: - key: mylabel operator: In values: - specialpods containers:
Using Taint & Toleration
Taint & Toleration work together: you taint a node, and then specify the toleration for pod, only those Pods will be scheduled on node whose toleration "matches" taint:
Taint: kubectl taint nodes node1 mytaint=specialpods:NoSchedule
Add toleration in Pod Spec:
apiVersion: v1 kind: Pod metadata: name: mypod spec: tolerations: