Difference between revisions of "Spec.NodeSelector"

From wikieduonline
Jump to navigation Jump to search
 
(17 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
+
{{lc}}
 +
* https://www.eksworkshop.com/beginner/140_assigning_pods/node_selector/
  
 
* https://kubernetes.io/docs/tasks/configure-pod-container/assign-pods-nodes/#create-a-pod-that-gets-scheduled-to-your-chosen-node
 
* https://kubernetes.io/docs/tasks/configure-pod-container/assign-pods-nodes/#create-a-pod-that-gets-scheduled-to-your-chosen-node
Line 9: Line 10:
 
     env: test
 
     env: test
 
  spec:
 
  spec:
   containers:
+
   [[containers:]]
 
   - name: nginx
 
   - name: nginx
 
     image: nginx
 
     image: nginx
Line 15: Line 16:
 
   [[nodeSelector:]]
 
   [[nodeSelector:]]
 
     [[disktype]]: ssd
 
     [[disktype]]: ssd
 +
 +
<pre>
 +
apiVersion: v1
 +
 +
kind: Pod
 +
 +
metadata:
 +
 +
  name: nginx
 +
 +
spec:
 +
 +
  nodeName: foo-node # schedule pod to specific node
 +
 +
  containers:
 +
 +
  - name: nginx
 +
 +
    image: nginx
 +
 +
    imagePullPolicy: IfNotPresent
 +
</pre>
 +
 +
== [[Karpenter]] ==
 +
nodeSelector:
 +
  [[topology.kubernetes.io/]]zone: us-west-2a
 +
  [[karpenter.sh/capacity-type]]: spot
 +
 +
nodeSelector:
 +
  [[karpenter.sh/provisioner-name:]] XXXXX
 +
 +
== DaemonSet ==
 +
Stop [[DaemonSet]] by appliying a [[nodeSelector]]
 +
* <code>[[kubectl patch]] daemonset <name-of-daemon-set> -p '{"spec": {"template": {"spec": {"nodeSelector": {"non-existing": "true"}}}}}'</code>
 +
Start [[DaemonSet]] by removing the [[nodeSelector]] :
 +
* <code>kubectl patch daemonset <name-of-daemon-set> --type json -p='[{"op": "remove", "path": "[[/spec/template/spec/nodeSelector/]]non-existing"}]'</code>
  
 
== Activities ==
 
== Activities ==
Line 27: Line 64:
 
* <code>[[kubectl apply]]</code>
 
* <code>[[kubectl apply]]</code>
 
* <code>[[nodeAffinity]]</code>
 
* <code>[[nodeAffinity]]</code>
 +
* [[Kubernetes Pod Topology Spread Constraints]]
 +
* <code>[[selector:]]</code>
  
 
== See also ==
 
== See also ==
* {{kind}}
+
* {{K8s nodes}}
* {{K8s}}
+
* {{Pods}}
 +
* {{affinity}}
  
 
[[Category:Kubernetes]]
 
[[Category:Kubernetes]]

Latest revision as of 07:22, 25 July 2024

apiVersion: v1
kind: Pod
metadata:
  name: nginx
  labels:
    env: test
spec:
  containers:
  - name: nginx
    image: nginx
    imagePullPolicy: IfNotPresent
  nodeSelector:
    disktype: ssd
apiVersion: v1

kind: Pod

metadata:

  name: nginx

spec:

  nodeName: foo-node # schedule pod to specific node

  containers:

  - name: nginx

    image: nginx

    imagePullPolicy: IfNotPresent

Karpenter[edit]

nodeSelector:
  topology.kubernetes.io/zone: us-west-2a
  karpenter.sh/capacity-type: spot
nodeSelector:
  karpenter.sh/provisioner-name: XXXXX

DaemonSet[edit]

Stop DaemonSet by appliying a nodeSelector

  • kubectl patch daemonset <name-of-daemon-set> -p '{"spec": {"template": {"spec": {"nodeSelector": {"non-existing": "true"}}}}}'

Start DaemonSet by removing the nodeSelector :

Activities[edit]

Related terms[edit]

See also[edit]

Advertising: