一个 pod 运行 可以在多个节点上吗?
Can a pod run on multiple nodes?
我有一个 kubernetes master
和三个 kubernetes nodes
。我在特定节点上制作了一个 运行ning 的 pod。我想 运行 那个 pod 在 2 个节点上。我怎样才能做到这一点? replica
概念对我有帮助吗?如果是怎么办?
直接在节点上 运行 pods 不是一个好习惯,因为 nodes/pods 随时可能崩溃。最好使用 K8S 文档中提到的 K8S 控制器 here。
K8S 支持多个容器,并且可以根据需要使用适当的控制器。通过查看 OP,很难说要使用哪个控制器。
是,您可以将pods分配给集群的一个或多个节点,这里有一些选项可以实现这一点:
nodeSelector is the simplest recommended form of node selection constraint. nodeSelector is a field of PodSpec. It specifies a map of key-value pairs. For the pod to be eligible to run on a node, the node must have each of the indicated key-value pairs as labels (it can have additional labels as well). The most common usage is one key-value pair.
Node affinity is conceptually similar to nodeSelector -- it allows you to constrain which nodes your pod is eligible to be scheduled on, based on labels on the node.
nodeSelector provides a very simple way to constrain pods to nodes with particular labels. The affinity/anti-affinity feature, greatly expands the types of constraints you can express. The key enhancements are
- The affinity/anti-affinity language is more expressive. The language offers more matching rules besides exact matches created with a logical AND operation;
- you can indicate that the rule is "soft"/"preference" rather than a hard requirement, so if the scheduler can't satisfy it, the pod will still be scheduled;
- you can constrain against labels on other pods running on the node (or other topological domain), rather than against labels on the node itself, which allows rules about which pods can and cannot be co-located
A DaemonSet ensures that all (or some) Nodes run a copy of a Pod. As nodes are added to the cluster, Pods are added to them. As nodes are removed from the cluster, those Pods are garbage collected. Deleting a DaemonSet will clean up the Pods it created.
Some typical uses of a DaemonSet are:
- running a cluster storage daemon on every node
- running a logs collection daemon on every node
- running a node monitoring daemon on every node
请检查 this link 以阅读有关如何将 pods 分配给节点的更多信息。
如果你想在每个节点上 运行 pod,你可以使用 daemonset。
我看到的是您正在尝试在每个节点上部署 pod,如果您允许调度程序根据资源决定需要在何处部署 pod 会更好。
这在所有最坏的情况下都是最好的。
我的意思是在节点出现故障的情况下。
我有一个 kubernetes master
和三个 kubernetes nodes
。我在特定节点上制作了一个 运行ning 的 pod。我想 运行 那个 pod 在 2 个节点上。我怎样才能做到这一点? replica
概念对我有帮助吗?如果是怎么办?
直接在节点上 运行 pods 不是一个好习惯,因为 nodes/pods 随时可能崩溃。最好使用 K8S 文档中提到的 K8S 控制器 here。
K8S 支持多个容器,并且可以根据需要使用适当的控制器。通过查看 OP,很难说要使用哪个控制器。
是,您可以将pods分配给集群的一个或多个节点,这里有一些选项可以实现这一点:
nodeSelector is the simplest recommended form of node selection constraint. nodeSelector is a field of PodSpec. It specifies a map of key-value pairs. For the pod to be eligible to run on a node, the node must have each of the indicated key-value pairs as labels (it can have additional labels as well). The most common usage is one key-value pair.
Node affinity is conceptually similar to nodeSelector -- it allows you to constrain which nodes your pod is eligible to be scheduled on, based on labels on the node.
nodeSelector provides a very simple way to constrain pods to nodes with particular labels. The affinity/anti-affinity feature, greatly expands the types of constraints you can express. The key enhancements are
- The affinity/anti-affinity language is more expressive. The language offers more matching rules besides exact matches created with a logical AND operation;
- you can indicate that the rule is "soft"/"preference" rather than a hard requirement, so if the scheduler can't satisfy it, the pod will still be scheduled;
- you can constrain against labels on other pods running on the node (or other topological domain), rather than against labels on the node itself, which allows rules about which pods can and cannot be co-located
A DaemonSet ensures that all (or some) Nodes run a copy of a Pod. As nodes are added to the cluster, Pods are added to them. As nodes are removed from the cluster, those Pods are garbage collected. Deleting a DaemonSet will clean up the Pods it created.
Some typical uses of a DaemonSet are:
- running a cluster storage daemon on every node
- running a logs collection daemon on every node
- running a node monitoring daemon on every node
请检查 this link 以阅读有关如何将 pods 分配给节点的更多信息。
如果你想在每个节点上 运行 pod,你可以使用 daemonset。 我看到的是您正在尝试在每个节点上部署 pod,如果您允许调度程序根据资源决定需要在何处部署 pod 会更好。 这在所有最坏的情况下都是最好的。 我的意思是在节点出现故障的情况下。