简体   繁体   English

允许在 Kubernetes master 上调度 Pod?

[英]Allow scheduling of pods on Kubernetes master?

I set up Kubernetes on CoreOS on bare metal using the generic install scripts .我使用通用安装脚本在裸机上的 CoreOS 上设置了 Kubernetes。 It's running the current stable release, 1298.6.0, with Kubernetes version 1.5.4.它运行当前的稳定版本 1298.6.0,Kubernetes 版本为 1.5.4。

We'd like to have a highly available master setup, but we don't have enough hardware at this time to dedicate three servers to serving only as Kubernetes masters, so I would like to be able to allow user pods to be scheduled on the Kubernetes master.我们希望有一个高度可用的 master 设置,但我们目前没有足够的硬件来专用三台服务器来仅作为 Kubernetes master 服务,所以我希望能够允许用户 pod 被安排在Kubernetes 大师。 I set --register-schedulable=true in /etc/systemd/system/kubelet.service but it still showed up as SchedulingDisabled.我在 /etc/systemd/system/kubelet.service 中设置了 --register-schedulable=true 但它仍然显示为 SchedulingDisabled。

I tried to add settings for including the node as a worker, including adding worker TLS certs to /etc/kubernetes/ssl, adding those settings to kubelet.service, adding an /etc/kubernetes/worker-kubeconfig.yaml that pointed to those certs, and added that information to the /etc/kubernetes/manifests/kube-proxy.yaml.我尝试添加设置以将节点包含为工作人员,包括将工作人员 TLS 证书添加到 /etc/kubernetes/ssl,将这些设置添加到 kubelet.service,添加指向那些的 /etc/kubernetes/worker-kubeconfig.yaml certs,并将该信息添加到 /etc/kubernetes/manifests/kube-proxy.yaml。 I used my existing nodes as a template for what to add.我使用我现有的节点作为添加内容的模板。 This registered another node under the master's hostname and then both it and the original master node showed up as NotReady,SchedulingDisabled.这在主节点的主机名下注册了另一个节点,然后它和原始主节点都显示为 NotReady,SchedulingDisabled。

This question indicates that scheduling pods on the master node should be possible, but there is barely anything else that I can find on the subject. 这个问题表明应该可以在主节点上调度 pod,但我几乎找不到关于这个主题的任何其他内容。

如果您使用的是 Kubernetes 1.7 及更高版本:

kubectl taint node mymasternode node-role.kubernetes.io/master:NoSchedule-

使用以下命令清除所有主控

kubectl taint nodes --all node-role.kubernetes.io/master-

First, get the name of the master一、获取master的名字

kubectl get nodes

NAME     STATUS   ROLES    AGE   VERSION
yasin   Ready    master   11d   v1.13.4

as we can see there is one node with the name of yasin and the role is master .我们可以看到有一个名为yasin的节点,角色是master If we want to use it as worker we should run如果我们想将它用作工人,我们应该运行

kubectl taint nodes yasin node-role.kubernetes.io/master-

For anyone using kops on AWS.对于在 AWS 上使用 kops 的任何人。 I wanted to enable scheduling of Pods on master.我想在 master 上启用 Pod 调度。

$ kubectl get nodes -owide was giving me this output: $ 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
...
...

And $ kubectl describe nodes ip-1**-**-**-***.********.master.internal :$ kubectl describe nodes ip-1**-**-**-***.********.master.internal

...
...
Taints:             <none>
Unschedulable:      true
...                 ^^^^
...

Patching the master with this command:使用以下命令修补主节点

$ kubectl patch node MASTER_NAME -p "{\"spec\":{\"unschedulable\":false}}"

worked for me and scheduling of Pods is now enabled.为我工作,现在启用了 Pod 的调度。

Ref: https://github.com/kubernetes/kops/issues/639#issuecomment-287015882参考: https ://github.com/kubernetes/kops/issues/639#issuecomment-287015882

I don't know why the master node shows up as NotReady ;我不知道为什么主节点显示为NotReady it shouldn't.它不应该。 Try executing kubectl describe node mymasternode to find out.尝试执行kubectl describe node mymasternode来找出答案。

The SchedulingDisabled is because the master node is tainted with dedicated=master:NoSchedule SchedulingDisabled是因为主节点被dedicated=master:NoSchedule污染

Execute this command against all your masters to remove the taint:对所有主人执行此命令以删除污点:

kubectl taint nodes mymasternode dedicated-

To understand why that works read up on taints and tolerations .要了解为什么这有效,请阅读taints 和 tolerations

Allow scheduling of pods on the master允许在 master 上调度 pod

kubectl taint node --all node-role.kubernetes.io/master:NoSchedule-

Verify the master isn't tainted验证主人没有被污染

kubectl describe node | egrep -i taint

Taints: <none>

Schedule and run test pod in master在 master 中安排和运行测试 pod

kubectl run -it  busybox-$RANDOM --image=busybox --restart=Never -- date

This answer is a combination of other SO answers, from Victor G, Aryak Sengupta, and others.这个答案是其他 SO 答案的组合,来自 Victor G、Aryak Sengupta 和其他人。

node-role.kubernetes.io/master节点角色.kubernetes.io/master

is deprecated in favor of: 不推荐使用,有利于:

node-role.kubernetes.io/control-plane node-role.kubernetes.io/control-plane

Official kubernetes documentation: node-role-kubernetes-io-master kubernetes 官方文档: node-role-kubernetes-io-master

So for versions +v1.20 the solution is :所以对于 +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-

Another way to list all taints in nodes and untaint the tainted one.另一种列出节点中所有污点并清除受污染节点的方法。

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 does not have any taint. lab-a 没有任何污点。 so we untaint lab-b:所以我们不污染lab-b:

root@lab-a:~# k taint node lab-b node-role.kubernetes.io/master:NoSchedule-
node/lab-b untainted

Install jq in ubuntu by: apt-get install jq在 ubuntu 中安装 jq: apt-get install jq

Since Openshift 4.x CoreOs is directly integrated on Kubernetes configuration (you can make all masters schedulable this way由于 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}]'

or using或使用

oc edit schedulers.config.openshift.io cluster 

and edit the field并编辑该字段

spec:
    mastersSchedulable: true

The answer is答案是

kubectl taint nodes --all node-role.kubernetes.io/master-

according to: https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/create-cluster-kubeadm/#control-plane-node-isolation根据: https ://kubernetes.io/docs/setup/production-environment/tools/kubeadm/create-cluster-kubeadm/#control-plane-node-isolation

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM