简体   繁体   中英

Kubernetes apply nodeSelector via command

Is there a way to apply a nodeSelector via command? (like kubectl apply )

It would be nice if it is applicable on running deployments or namespaces, otherwise applying to running pods is also fine.

Any tips are appreciated

You can use the kubectl patch command, like this:

kubectl patch deployments nginx-deployment -p '{"spec": {"template": {"spec": {"nodeSelector": {"kube.netes.io/hostname": "node-2"}}}}}'

After successful patch all pods of the deployment will be restarted on a node matching the selector.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM