The semantics of label selectors, or the semantics of pod affinity/anti-affinity, they both are very related.
What does "empty" mean in pod affinity/anti-affinity labelselectors, what does null/{} mean in pod affinity/anti-affinity, are they the same? I can use this to colocate a pod with another. what if the plan was to make sure they were not colocated? apiVersion: v1 kind: Pod metadata: name: nginx-pod3 spec: affinity: podAffinity: requiredDuringSchedulingIgnoredDuringExecution: - labelSelector: matchLabels: app: nginx topologyKey: kubernetes.io/hostname podAntiAffinity: requiredDuringSchedulingIgnoredDuringExecution: - topologyKey: kubernetes.io/hostname containers: - name: nginx image: nginx:1.7.9 ports: - containerPort: 80 On Friday, April 28, 2017 at 3:44:34 PM UTC-7, David Oppenheimer wrote: > > It's not clear to me if you are asking about YAML/API server behavior, or > the semantics of label selectors, or the semantics of pod > affinity/anti-affinity. > > > > On Fri, Apr 28, 2017 at 3:26 PM, 'Kenneth Massada' via Kubernetes user > discussion and Q&A <kubernet...@googlegroups.com <javascript:>> wrote: > >> Could someone help clarify difference between empty and null? >> https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/ >> says An empty label selector (that is, one with zero requirements) selects >> every object in the collection. A null label selector (which is only >> possible for optional selector fields) selects no objects consider this: >> affinity: podAffinity: requiredDuringSchedulingIgnoredDuringExecution: - >> labelSelector: matchLabels: app: nginx topologyKey: >> kubernetes.io/hostname podAntiAffinity: >> requiredDuringSchedulingIgnoredDuringExecution: - labelSelector: >> matchLabels: null topologyKey: kubernetes.io/hostname The current >> behavior is then schedule pod on all nodes that have a pod app:nginx BUT do >> not schedule pod on "every" of the nodes. or schedule it none nodes and >> node that has a pod app:nginx consider affinity: podAffinity: >> requiredDuringSchedulingIgnoredDuringExecution: - labelSelector: >> matchLabels: app: nginx topologyKey: kubernetes.io/hostname >> podAntiAffinity: requiredDuringSchedulingIgnoredDuringExecution: - >> topologyKey: kubernetes.io/hostname The current behavior is then >> schedule pod on all nodes that have a pod app:nginx BUT do not schedule it >> on "none" of the nodes. schedule it on all nodes and node that has a pod >> app:nginx {}/null act as every Empty act as all so according to the YAML >> construct "{}" is also null. >> however, {} this looks more like empty? so is empty omitting? >> >> I guess the use case here is >> >> PodAffinity: app:nginx AND podAntiAffinity: NONE >> >> Kenneth >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Kubernetes user discussion and Q&A" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to kubernetes-use...@googlegroups.com <javascript:>. >> To post to this group, send email to kubernet...@googlegroups.com >> <javascript:>. >> Visit this group at https://groups.google.com/group/kubernetes-users. >> For more options, visit https://groups.google.com/d/optout. >> > > -- You received this message because you are subscribed to the Google Groups "Kubernetes user discussion and Q&A" group. To unsubscribe from this group and stop receiving emails from it, send an email to kubernetes-users+unsubscr...@googlegroups.com. To post to this group, send email to kubernetes-users@googlegroups.com. Visit this group at https://groups.google.com/group/kubernetes-users. For more options, visit https://groups.google.com/d/optout.