[英]Kubernetes Pod Scheduling failed with 1 node(s) did not match pod affinity/anti-affinity
We have got a Kube.netes cluster up and running (with 1 master and 1 slave).我们已经启动并运行了一个 Kube.netes 集群(有 1 个主服务器和 1 个从服务器)。
Recently we added a new worker node (temp-worker) which was successful and all were on Cent OS 8最近我们添加了一个新的工作节点(temp-worker),它是成功的并且都在 Cent OS 8 上
Node Details节点详情
NAME STATUS ROLES AGE VERSION
master-node Ready control-plane,master 34d v1.20.2
temp-worker Ready <none> 5h48m v1.20.2
worker-node-2 Ready worker 34d v1.20.0
I tried with the following pod specification (with 2 replicas), however pod remained in state Pending我尝试使用以下 pod 规范(有 2 个副本),但是 pod 仍处于 state Pending
Pod Spec Pod规格
podAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: app #security
operator: DoesNotExist
topologyKey: kubernetes.io/hostname
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100
podAffinityTerm:
labelSelector:
matchExpressions:
- key: app #security
operator: In
values:
- hello-app
topologyKey: kubernetes.io/hostname
Pod logs Pod 日志
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Warning FailedScheduling 3m50s default-scheduler 0/3 nodes are available: 1 node(s) didn't match pod affinity rules, 1 node(s) didn't match pod affinity/anti-affinity, 2 node(s) had volume node affinity conflict.
Warning FailedScheduling 3m50s default-scheduler 0/3 nodes are available: 1 node(s) didn't match pod affinity rules, 1 node(s) didn't match pod affinity/anti-affinity, 2 node(s) had volume node affinity conflict.
I tried by changing the operator values (eg In, NotIn etc) in pod specification but nothing changed我尝试通过更改 pod 规范中的运算符值(例如 In、NotIn 等)但没有任何改变
I would like to understand why it reports error for the newly added worker-node.我想了解为什么它会报告新添加的工作节点的错误。 What did I do wrong?我做错了什么?
From this kube.netes doc “The Deployment controller stops the bad rollout automatically, and stops scaling up the new ReplicaSet.从这个 kube.netes 文档“部署 controller 自动停止错误的部署,并停止扩展新的 ReplicaSet。 This depends on the rollingUpdate parameters (maxUnavailable specifically) that you have specified.这取决于您指定的 rollingUpdate 参数(特别是 maxUnavailable)。 Kube.netes by default sets the value to 25%.” Kube.netes 默认将该值设置为 25%。”
Means that it prevents Kube.netes from evicting one pod out of three.这意味着它可以防止 Kube.netes 驱逐三个 pod 中的一个。 You are attempting a deployment update.您正在尝试部署更新。
Try adding the Max unavailable to deployment.尝试将不可用的 Max 添加到部署中。
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 1
As per this doc check whether all conditions are satisfied in your pod affinity.根据此文档,检查您的 pod 亲和力是否满足所有条件。
Try specifying the label values in the podAffinity, Maybe there are no matching nodes available in the that label values follow this doc for more information.尝试在 podAffinity 中指定 label 值,也许在 label 值中没有可用的匹配节点,请关注此文档以获取更多信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.