Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kubectl run set nodeSelector

Tags:

Is there a way to specify the nodeSelector when using the Kubernetes run command?

I don't have a yaml file and I only want to override the nodeSelector.

I tried the following but didn't work:

kubectl run myservice --image myserviceimage:latest --overrides='{ "nodeSelector": { "beta.kubernetes.io/os": "windows" } }'
like image 938
nbilal Avatar asked Jul 03 '18 19:07

nbilal


People also ask

How do you change nodeSelector?

You can change the nodeSelector values through kubectl edit deploy [DEPLOYMENT] -n [NAMESPACE] -o yaml . Once changed, the old pod will be terminated, and the new one will be scheduled on the new node.

How do I assign a pod to a specific node?

You can add the nodeSelector field to your Pod specification and specify the node labels you want the target node to have. Kubernetes only schedules the Pod onto nodes that have each of the labels you specify. See Assign Pods to Nodes for more information.

What is nodeSelector?

A node selector specifies a map of key/value pairs that are defined using custom labels on nodes and selectors specified in pods. For the pod to be eligible to run on a node, the pod must have the same key/value node selector as the label on the node.


1 Answers

nodeSelector must be wrapped with a spec. Like so

kubectl run -ti --rm test --image=ubuntu:18.04 --overrides='{"spec": { "nodeSelector": {"kubernetes.io/hostname": "eks-prod-4"}}}'
like image 182
RubenLaguna Avatar answered Sep 27 '22 20:09

RubenLaguna