如何在kubernetes的主节点上运行Pod?

时间:2019-11-21 21:54:17

标签: kubernetes

我知道在主节点上运行pod违反kubernetes最佳实践!不过,在我的虚拟环境中,我想在主节点上运行pod。我该怎么办?

1 个答案:

答案 0 :(得分:2)

我找到了解决方案。您可以删除禁止taint在主节点上调度pod的kubernetes scheduler

# Get all nodes.
$ kubectl get nodes
NAME        STATUS   ROLES     AGE   VERSION
compute01   Ready    compute   16d   v1.15.0
master      Ready    master    16d   v1.15.0
web01       Ready    web       16d   v1.15.0

# Check if there is a NoSchedule taint on master node.  
$ kubectl get node master -o json
...
"taints": [
    {
        "effect": "NoSchedule",
        "key": "node-role.kubernetes.io/master"
    }
]
...

# Delete node-role.kubernetes.io/master taint from all nodes that have it.
$ kubectl taint nodes --all node-role.kubernetes.io/master-
node "node/master" untainted
taint "node-role.kubernetes.io/master" not found
taint "node-role.kubernetes.io/master" not found

如果要使您的主节点可再次调度,则必须使用bellow命令重新创建已删除的异味。

$ kubectl taint node master node-role.kubernetes.io/master=:NoSchedule
node/master tainted