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" } }'
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.
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.
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.
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"}}}'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With