DaemonSet 是如何調(diào)度的
v1.12以后默認禁用
通常,Kubernetes Scheduler(調(diào)度器)決定了 Pod 在哪個節(jié)點上運行。然而 DaemonSet Controller 創(chuàng)建的 Pod 已經(jīng)指定了 .spec.nodeName
字段,因此:
- Node 節(jié)點的 unschedulable (opens new window)字段將被 DaemonSet Controller 忽略
- DaemonSet Controller 可以在 kubernetes scheduler 啟動之前創(chuàng)建 Pod,這個特性在引導集群啟動的時候非常有用(集群使用者無需關心)
由默認調(diào)度器調(diào)度
v1.12以后默認啟用
DaemonSet 確保所以符合條件的節(jié)點運行了一個指定的 Pod。通常,Kubernetes Scheduler 決定 Pod 在哪個節(jié)點上運行。然而如果 DaemonSet 的 Pod 由 DaemonSet Controller 創(chuàng)建和調(diào)度,會引發(fā)如下問題:
- Pod 的行為不一致:普通的 Pod 在創(chuàng)建后處于 Pending 狀態(tài),并等待被調(diào)度,但是 DaemonSet Pod 創(chuàng)建后,初始狀態(tài)不是 Pending。這會使用戶感到困惑
- Pod 的優(yōu)先權(preemption) (opens new window)由 kubernetes 調(diào)度器處理。如果 Pod 優(yōu)先權被啟用,DaemonSet Controller 在創(chuàng)建和調(diào)度 Pod 時,不會考慮 Pod 的優(yōu)先權
Kubernetes v1.12 版本以后,默認通過 kubernetes 調(diào)度器來調(diào)度 DaemonSet 的 Pod。DaemonSet Controller 將會向 DaemonSet 的 Pod 添加 .spec.nodeAffinity
字段,而不是 .spec.nodeName
字段,并進一步由 kubernetes 調(diào)度器將 Pod 綁定到目標節(jié)點。如果 DaemonSet 的 Pod 已經(jīng)存在了 nodeAffinity
字段,該字段的值將被替換。
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchFields:
- key: metadata.name
operator: In
values:
- target-host-name
此外, node.kubernetes.io/unschedulable:NoSchedule
容忍(toleration)將被自動添加到 DaemonSet 的 Pod 中。由此,默認調(diào)度器在調(diào)度 DaemonSet 的 Pod 時可以忽略節(jié)點的 unschedulable 屬性文章來源:http://www.zghlxwxcb.cn/news/detail-495878.html
污點和容忍
在調(diào)度 DaemonSet 的 Pod 時,污點和容忍會被考量到,同時,以下容忍(toleration)將被自動添加到 DaemonSet 的 Pod 中:文章來源地址http://www.zghlxwxcb.cn/news/detail-495878.html
Toleration Key | Effect | Version | 描述 |
---|---|---|---|
node.kubernetes.io/not-ready | NoExecute | 1.13+ | 節(jié)點出現(xiàn)問題時(例如網(wǎng)絡故障),DaemonSet 容器組將不會從節(jié)點上驅逐 |
node.kubernetes.io/unreachable | NoExecute | 1.13+ | 節(jié)點出現(xiàn)問題時(例如網(wǎng)絡故障),DaemonSet 容器組將不會從節(jié)點上驅逐 |
node.kubernetes.io/disk-pressure | NoSchedule | 1.8+ | |
node.kubernetes.io/memory-pressure | NoSchedule | 1.8+ | |
node.kubernetes.io/unschedulable | NoSchedule | 1.12+ | 默認調(diào)度器針對 DaemonSet 容器組,容忍節(jié)點的 unschedulable 屬性 |
node.kubernetes.io/network-unavailable | NoSchedule | 1.12+ | 默認調(diào)度器針對 DaemonSet 容器組,在其使用 host network 時,容忍節(jié)點的 network-unavailable 屬性 |
到了這里,關于k8s控制器之DaemonSet--第三彈DaemonSet 是如何調(diào)度的的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!