[英]Allow scheduling of pods on Kubernetes master?
我使用通用安裝腳本在裸機上的 CoreOS 上設置了 Kubernetes。 它運行當前的穩定版本 1298.6.0,Kubernetes 版本為 1.5.4。
我們希望有一個高度可用的 master 設置,但我們目前沒有足夠的硬件來專用三台服務器來僅作為 Kubernetes master 服務,所以我希望能夠允許用戶 pod 被安排在Kubernetes 大師。 我在 /etc/systemd/system/kubelet.service 中設置了 --register-schedulable=true 但它仍然顯示為 SchedulingDisabled。
我嘗試添加設置以將節點包含為工作人員,包括將工作人員 TLS 證書添加到 /etc/kubernetes/ssl,將這些設置添加到 kubelet.service,添加指向那些的 /etc/kubernetes/worker-kubeconfig.yaml certs,並將該信息添加到 /etc/kubernetes/manifests/kube-proxy.yaml。 我使用我現有的節點作為添加內容的模板。 這在主節點的主機名下注冊了另一個節點,然后它和原始主節點都顯示為 NotReady,SchedulingDisabled。
這個問題表明應該可以在主節點上調度 pod,但我幾乎找不到關於這個主題的任何其他內容。
如果您使用的是 Kubernetes 1.7 及更高版本:
kubectl taint node mymasternode node-role.kubernetes.io/master:NoSchedule-
使用以下命令清除所有主控
kubectl taint nodes --all node-role.kubernetes.io/master-
一、獲取master的名字
kubectl get nodes
NAME STATUS ROLES AGE VERSION
yasin Ready master 11d v1.13.4
我們可以看到有一個名為yasin
的節點,角色是master
。 如果我們想將它用作工人,我們應該運行
kubectl taint nodes yasin node-role.kubernetes.io/master-
對於在 AWS 上使用 kops 的任何人。 我想在 master 上啟用 Pod 調度。
$ kubectl get nodes -owide
給了我這個輸出:
NAME STATUS
...
...
ip-1**-**-**-***.********.compute.internal Ready node
ip-1**-**-**-***.********.master.internal Ready,SchedulingDisabled master
^^^^^^^^^^^^^^^^^^
ip-1**-**-**-***.********.compute.internal Ready node
...
...
和$ kubectl describe nodes ip-1**-**-**-***.********.master.internal
:
...
...
Taints: <none>
Unschedulable: true
... ^^^^
...
使用以下命令修補主節點:
$ kubectl patch node MASTER_NAME -p "{\"spec\":{\"unschedulable\":false}}"
為我工作,現在啟用了 Pod 的調度。
參考: https ://github.com/kubernetes/kops/issues/639#issuecomment-287015882
我不知道為什么主節點顯示為NotReady
; 它不應該。 嘗試執行kubectl describe node mymasternode
來找出答案。
SchedulingDisabled
是因為主節點被dedicated=master:NoSchedule
污染
對所有主人執行此命令以刪除污點:
kubectl taint nodes mymasternode dedicated-
要了解為什么這有效,請閱讀taints 和 tolerations 。
kubectl taint node --all node-role.kubernetes.io/master:NoSchedule-
kubectl describe node | egrep -i taint
Taints: <none>
kubectl run -it busybox-$RANDOM --image=busybox --restart=Never -- date
這個答案是其他 SO 答案的組合,來自 Victor G、Aryak Sengupta 和其他人。
kubernetes 官方文檔: node-role-kubernetes-io-master
所以對於 +v1.20 版本,解決方案是:
kubectl taint node <master-node> node-role.kubernetes.io/control-plane:NoSchedule- kubectl taint node <master-node> node-role.kubernetes.io/master:NoSchedule-
另一種列出節點中所有污點並清除受污染節點的方法。
root@lab-a:~# kubectl get nodes -o json | jq ".items[]|{name:.metadata.name, taints:.spec.taints}"
{
"name": "lab-a",
"taints": null
}
{
"name": "lab-b",
"taints": [
{
"effect": "NoSchedule",
"key": "node-role.kubernetes.io/master"
}
]
}
lab-a 沒有任何污點。 所以我們不污染lab-b:
root@lab-a:~# k taint node lab-b node-role.kubernetes.io/master:NoSchedule-
node/lab-b untainted
在 ubuntu 中安裝 jq: apt-get install jq
由於 Openshift 4.x CoreOs 直接集成在 Kubernetes 配置中(您可以通過這種方式使所有 master 可調度
# edit the field spec.mastersSchedulable to set a value true
$ oc patch schedulers.config.openshift.io cluster --type json \
-p '[{"op": "add", "path": "/spec/mastersSchedulable", "value": true}]'
或使用
oc edit schedulers.config.openshift.io cluster
並編輯該字段
spec:
mastersSchedulable: true
答案是
kubectl taint nodes --all node-role.kubernetes.io/master-
根據: https ://kubernetes.io/docs/setup/production-environment/tools/kubeadm/create-cluster-kubeadm/#control-plane-node-isolation
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.