I was wondering if there was a one line kubectl command to add the nodeSelector in the pod yaml? (I have already attached a label to the node) I am trying to automate this and hence I want to avoid manually downloading the yaml file and adding the nodeSelector. Any ideas using sed or kubectl replace would be appreciated.
Is there a one line kubectl command to add the nodeSelector in the pod yaml?
1.5k views Asked by Contraboy At
2
You can add
nodeSelector
in pod spec.As the k8s doc : nodeSelector is the simplest recommended form of node selection constraint. nodeSelector is a field of PodSpec. It specifies a map of key-value pairs. For the pod to be eligible to run on a node, the node must have each of the indicated key-value pairs as labels (it can have additional labels as well). The most common usage is one key-value pair.
update
I found a way to do this: