将部署匹配到特定的节点池
Match Deployment to specific nodepool
我正在寻找是否可以将特定 Deployment 分配给特定节点池的方法。
我打算使用 kubernetes 部署大型应用程序。我想知道是否有一种方法可以将部署分配给特定的节点池。换句话说,我们有 3 种类型的服务:
- 一般服务,低性能和低副本数
- 监控服务,需要高 I/O 和高性能服务器
- 模块服务,最苛刻的服务,我们的目标是为此分配最大的预算。
所以显然我们希望最好地将节点分配给特定的部署,这样就不会浪费资源,例如,低层服务器节点池 X 将仅由一般服务部署使用,高层服务器节点池 Y 将仅被使用由监控服务使用,最高层服务器将仅由模块服务使用。
我知道有大量的文章谈论 pod affinity 和其他相关的东西,但我似乎无法找到符合以下内容的任何内容:
How to assign Deployment to specific node pool
提前致谢!
这可以使用 Taints and Tolerations 来实现。它们是什么的快速总结(来自他们的文档):
Node affinity, is a property of Pods that attracts them to a set of nodes (either as a preference or a hard requirement). Taints are the opposite -- they allow a node to repel a set of pods.
Tolerations are applied to pods, and allow (but do not require) the
pods to schedule onto nodes with matching taints.
Taints and tolerations work together to ensure that pods are not
scheduled onto inappropriate nodes. One or more taints are applied to
a node; this marks that the node should not accept any pods that do
not tolerate the taints.
或者简单地使用 NodeSelector
当您注册节点以加入 kubernetes 集群时,您可以使用 kubelet 指定污点和标签 --register-with-taints label=value --node-labels=label2=value2
。
或者您可以对已注册的节点使用 kubectl taint。
然后当您要部署 pod/deployment/statefulset 时,您可以指定其 nodeSelector
和 Tolerations
spec:
nodeSelector:
label2: value2
tolerations:
- key: "label"
operator: "Equal"
value: "value"
effect: "NoSchedule"
另一种方法(除了 Yayotrón 提出的方法之外)是使用 NodeAffinity 和 AntiAffinity。有关详细信息,请在此处查看官方文档:https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/
污点和容忍度非常严格,根本不可能在其他节点上进行调度。
使用 Affinity 和 Antiaffinity,您可以指定您希望它是严格的 (RequiredDuringSchedulingIgnoredDuringExecution) 还是软限制 (PreferredDuring....)
我正在寻找是否可以将特定 Deployment 分配给特定节点池的方法。
我打算使用 kubernetes 部署大型应用程序。我想知道是否有一种方法可以将部署分配给特定的节点池。换句话说,我们有 3 种类型的服务:
- 一般服务,低性能和低副本数
- 监控服务,需要高 I/O 和高性能服务器
- 模块服务,最苛刻的服务,我们的目标是为此分配最大的预算。
所以显然我们希望最好地将节点分配给特定的部署,这样就不会浪费资源,例如,低层服务器节点池 X 将仅由一般服务部署使用,高层服务器节点池 Y 将仅被使用由监控服务使用,最高层服务器将仅由模块服务使用。
我知道有大量的文章谈论 pod affinity 和其他相关的东西,但我似乎无法找到符合以下内容的任何内容:
How to assign Deployment to specific node pool
提前致谢!
这可以使用 Taints and Tolerations 来实现。它们是什么的快速总结(来自他们的文档):
Node affinity, is a property of Pods that attracts them to a set of nodes (either as a preference or a hard requirement). Taints are the opposite -- they allow a node to repel a set of pods.
Tolerations are applied to pods, and allow (but do not require) the pods to schedule onto nodes with matching taints.
Taints and tolerations work together to ensure that pods are not scheduled onto inappropriate nodes. One or more taints are applied to a node; this marks that the node should not accept any pods that do not tolerate the taints.
或者简单地使用 NodeSelector
当您注册节点以加入 kubernetes 集群时,您可以使用 kubelet 指定污点和标签 --register-with-taints label=value --node-labels=label2=value2
。
或者您可以对已注册的节点使用 kubectl taint。
然后当您要部署 pod/deployment/statefulset 时,您可以指定其 nodeSelector
和 Tolerations
spec:
nodeSelector:
label2: value2
tolerations:
- key: "label"
operator: "Equal"
value: "value"
effect: "NoSchedule"
另一种方法(除了 Yayotrón 提出的方法之外)是使用 NodeAffinity 和 AntiAffinity。有关详细信息,请在此处查看官方文档:https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/
污点和容忍度非常严格,根本不可能在其他节点上进行调度。 使用 Affinity 和 Antiaffinity,您可以指定您希望它是严格的 (RequiredDuringSchedulingIgnoredDuringExecution) 还是软限制 (PreferredDuring....)