我希望我的一个节点只接受某种pod。 所以我想知道,有没有办法让一个节点只接受那些带有特定标签的pod?
答案 0 :(得分:2)
您有两种选择:
使用节点亲和力
您需要标记节点:
kubectl label nodes node1 mylabel=specialpods
然后,当您启动Pod时,请指定affinity
:
apiVersion: v1 kind: Pod metadata: name: mypod spec: affinity: nodeAffinity: requiredDuringSchedulingIgnoredDuringExecution: nodeSelectorTerms: - matchExpressions: - key: mylabel operator: In values: - specialpods containers: - name: nginx-container image: nginx
使用污点&宽容
污点&容忍一起工作:你污染一个节点,然后指定pod的容忍度,只有那些Pod将被安排在容忍"匹配"的节点上。污点:
污点:kubectl taint nodes node1 mytaint=specialpods:NoSchedule
在Pod规范中添加容忍度:
apiVersion: v1 kind: Pod metadata: name: mypod spec: tolerations: - key: "mytaint" operator: "Equal" value: "specialpods" effect: "NoSchedule" containers: - name: nginx-container image: nginx