gpt4 book ai didi

kubernetes - 备份Kubernetes节点

转载 作者:行者123 更新时间:2023-12-02 12:13:05 29 4
gpt4 key购买 nike

我用1个master 2个 worker Kubernetes Cluster。
船长和1. worker :在位置a
2. worker :在地点b。

位置a和b彼此相距很远。

我想在位置a处运行Pod,但如果向下运行则在位置b处创建。

我想在最坏的情况下在位置b创建一个pod。

如何在Kubernetes中做到这一点?

最佳答案

这是社区维基的答案。

正如@Burak在他的评论中提到的:

您正在寻找的是node affinity:

– it allows you to constrain which nodes your pod is eligible to be scheduled on, based on labels on the node.

Node affinity is specified as field nodeAffinity of field affinity in the PodSpec.

Here’s an example of a pod that uses node affinity:


apiVersion: v1
kind: Pod
metadata:
name: with-node-affinity
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/e2e-az-name
operator: In
values:
- e2e-az1
- e2e-az2
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 1
preference:
matchExpressions:
- key: another-node-label-key
operator: In
values:
- another-node-label-value
containers:
- name: with-node-affinity
image: k8s.gcr.io/pause:2.0

您可以在链接的文档中找到所有必要的详细信息。

请让我知道是否有帮助。

关于kubernetes - 备份Kubernetes节点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60308132/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com