Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
468 views
in Technique[技术] by (71.8m points)

kubernetes - Can a Pod with an affinity for one node's label, but without a toleration for that node's taint, mount to that node?

Say you have Node1 with taint node1taint:NoSchedule and label node1specialkey=asdf. And Node2 with no taints.

Then you create PodA with affinity to Node1:

    apiVersion: v1
    kind: Pod
    metadata:
      labels:
        name: PodA
    spec:
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
            - matchExpressions:
              - key: node1specialKey
                operator: Exists
      containers:
      - image: busybox
        name: PodA

Which pod should the node schedule to? Will the affinity override the taint?

Thanks!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The pod will not schedule anywhere, because it does not tolerate Node1's taint and it does not have an affinity for Node2.

Here is the missing pod taint that would, in combination with the affinity, successfully schedule PodA on Node1.

tolerations:
- key: "node1taint"
  operator: "Exists"
  effect: "NoSchedule"

A taint is more powerful than an affinity. The pod needs the toleration, too, because affinity alone is not strong enough here in Kubernetes-land.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...