默認調度是:最大空閒資源調度
調度器
預算策略
CheckNodeCondition:檢查節點網絡磁盤等是否正常
GeneralPredicates:通用預選策略
HostName:檢查pod對象是否定義了pod.spec.hostname
podFitsHostPorts: pods.spec.containers.ports.hostPort
MatchNNodeSelector:pods.spec.nodeSelector
PodFitsResources:檢查Pod資源需求能否被節點滿足
NoDiskConflict:檢查pod依賴的存儲卷能否滿足,默認不啓用
PodToleratesNodeTaints:檢查Pod上的spec.tolerations客容忍五點是否包含節點污點
PodToleratesNodeBoExecteTaints:默認不啓用
CheckNodeLabelPresence:檢查節點標籤存在,默認不啓用
CheckServiceAffinity:根據當前pod所屬pod所屬對象services放在同一個node
污點調度
-
查看節點污點
kubectl describe node node-name
官方文檔:https://kubernetes.io/zh/docs/concepts/configuration/taint-and-toleration/
-
節點添加污點
kubectl taint nodes node1 key=value:NoSchedule
kubectl taint nodes node1 key=value:NoExecute
kubectl taint nodes node1 key=value:PreferNoSchedule
-
NoSchedule:K8Snode添加這個effecf類型污點,新的不能容忍的pod不能再調度過來,但是老的運行在node上不受影響
-
-
NoExecute:K8Snode添加這個effecf類型污點,新的不能容忍的pod不能調度過來,老的pod也會被驅逐
-
-
PreferNoSchedule:pod會嘗試將pod分配到該節點
-
-
節點刪除污點:
kubectl taint nodes kube11 key:NoSchedule-
-
pod設置容忍一個污點
apiVersion: apps/v1Beta1
kind: Deployment
metadata:
name: nginx-deploy
spec:
replicas: 1
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
images: nginx:laste
ports:
- containerPort: 80
tolerations: #containers同級
- key: "key1" #能容忍的污點key
operator: "Equal" #Equal等於表示key=value , Exists不等於,表示當值不等於下面value正常
value: "value1" #值
effect: "NoExecute" #effect策略,見上面
tolerationSeconds: 3600 #原始的pod多久驅逐,注意只有effect: "NoExecute"才能設置,不然報錯