Editing Kubernetes pod affinity and anti affinity
Jump to navigation
Jump to search
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 5: | Line 5: | ||
0/11 nodes are available: 1 [[Insufficient cpu]], 1 Too many pods, 10 nodes(s) didn't match Pod's node [[affinity]]/selector | 0/11 nodes are available: 1 [[Insufficient cpu]], 1 Too many pods, 10 nodes(s) didn't match Pod's node [[affinity]]/selector | ||
− | 0/2 nodes are available: 1 Too many pods, 1 nodes(s) | + | 0/2 nodes are available: 1 Too many pods, 1 nodes(s) didn't match Pod's node [[affinity]]/selector |
− | |||
− | |||
− | |||
− | |||
== Official examples == | == Official examples == | ||
[[apiVersion]]: v1 | [[apiVersion]]: v1 | ||
+ | |||
[[kind:]] [[Pod]] | [[kind:]] [[Pod]] | ||
+ | |||
[[metadata]]: | [[metadata]]: | ||
+ | |||
name: [[with-node-affinity]] | name: [[with-node-affinity]] | ||
+ | |||
spec: | spec: | ||
− | [[affinity | + | |
+ | [[affinity]]: | ||
+ | |||
[[nodeAffinity]]: | [[nodeAffinity]]: | ||
+ | |||
requiredDuringSchedulingIgnoredDuringExecution: | requiredDuringSchedulingIgnoredDuringExecution: | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | - key: | + | nodeSelectorTerms: |
+ | |||
+ | - matchExpressions: | ||
+ | |||
+ | - key: topology.kubernetes.io/zone | ||
operator: In | operator: In | ||
Line 56: | Line 35: | ||
values: | values: | ||
− | + | - antarctica-east1 | |
− | + | - antarctica-west1 | |
− | |||
− | |||
preferredDuringSchedulingIgnoredDuringExecution: | preferredDuringSchedulingIgnoredDuringExecution: | ||
− | - weight: | + | - weight: 1 |
− | + | preference: | |
− | + | matchExpressions: | |
− | + | - key: another-node-label-key | |
− | + | operator: In | |
− | + | values: | |
− | + | - another-node-label-value | |
− | |||
− | |||
− | |||
− | |||
containers: | containers: | ||
− | - name: with- | + | - name: with-node-affinity |
− | + | image: registry.k8s.io/pause:2.0 | |
+ | |||
+ | |||
+ | <pre> | ||
+ | apiVersion: v1 | ||
+ | |||
+ | kind: Pod | ||
+ | |||
+ | metadata: | ||
+ | |||
+ | name: with-pod-affinity | ||
+ | |||
+ | spec: | ||
+ | |||
+ | affinity: | ||
+ | |||
+ | podAffinity: | ||
+ | |||
+ | requiredDuringSchedulingIgnoredDuringExecution: | ||
+ | |||
+ | - labelSelector: | ||
+ | |||
+ | matchExpressions: | ||
+ | |||
+ | - key: security | ||
+ | |||
+ | operator: In | ||
+ | |||
+ | values: | ||
+ | |||
+ | - S1 | ||
+ | |||
+ | topologyKey: topology.kubernetes.io/zone | ||
+ | |||
+ | podAntiAffinity: | ||
+ | |||
+ | preferredDuringSchedulingIgnoredDuringExecution: | ||
+ | |||
+ | - weight: 100 | ||
+ | |||
+ | podAffinityTerm: | ||
+ | |||
+ | labelSelector: | ||
+ | |||
+ | matchExpressions: | ||
+ | |||
+ | - key: security | ||
+ | |||
+ | operator: In | ||
+ | |||
+ | values: | ||
+ | |||
+ | - S2 | ||
+ | |||
+ | topologyKey: topology.kubernetes.io/zone | ||
+ | |||
+ | containers: | ||
+ | |||
+ | - name: with-pod-affinity | ||
+ | |||
+ | image: registry.k8s.io/pause:2.0 | ||
+ | </pre> | ||
== Related == | == Related == | ||
* [[Kubernetes Pod Topology Spread Constraints]] | * [[Kubernetes Pod Topology Spread Constraints]] | ||
− | + | [[default-scheduler]] | |
− | |||
− | |||
− | |||
− | |||
− | |||
== See also == | == See also == | ||
− | |||
* {{K8s pods}} | * {{K8s pods}} | ||
− | |||
[[Category:K8s]] | [[Category:K8s]] |
Advertising: