Difference between revisions of "Assigning Pods to Nodes"

From wikieduonline
Jump to navigation Jump to search
Line 1: Line 1:
 
* https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/
 
* https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/
  
 +
== Example ==
 +
<pre>
 +
apiVersion: v1
 +
kind: Pod
 +
metadata:
 +
  name: with-node-affinity
 +
spec:
 +
  affinity:
 +
    nodeAffinity:
 +
      requiredDuringSchedulingIgnoredDuringExecution:
 +
        nodeSelectorTerms:
 +
        - matchExpressions:
 +
          - key: topology.kubernetes.io/zone
 +
            operator: In
 +
            values:
 +
            - antarctica-east1
 +
            - antarctica-west1
 +
      preferredDuringSchedulingIgnoredDuringExecution:
 +
      - weight: 1
 +
        preference:
 +
          matchExpressions:
 +
          - key: another-node-label-key
 +
            operator: In
 +
            values:
 +
            - another-node-label-value
 +
  containers:
 +
  - name: with-node-affinity
 +
    image: registry.k8s.io/pause:2.0
 +
</pre>
  
 +
== Related ==
 
* [[Assign Pods to Nodes using Node Affinity]]
 
* [[Assign Pods to Nodes using Node Affinity]]
 
* [[Kubernetes Node Affinity]]
 
* [[Kubernetes Node Affinity]]

Revision as of 12:52, 25 July 2024

Example

apiVersion: v1
kind: Pod
metadata:
  name: with-node-affinity
spec:
  affinity:
    nodeAffinity:
      requiredDuringSchedulingIgnoredDuringExecution:
        nodeSelectorTerms:
        - matchExpressions:
          - key: topology.kubernetes.io/zone
            operator: In
            values:
            - antarctica-east1
            - antarctica-west1
      preferredDuringSchedulingIgnoredDuringExecution:
      - weight: 1
        preference:
          matchExpressions:
          - key: another-node-label-key
            operator: In
            values:
            - another-node-label-value
  containers:
  - name: with-node-affinity
    image: registry.k8s.io/pause:2.0

Related

See also

Advertising: