If we have question like this
"This Pod should only be scheduled on a master node"
Can we use “nodeName” instead of using tolerations & nodeseletor?
I had this question in killer and the solution given has tolerations & nodeseletor
but I used “nodeName” which also gives the same result
so bit confuse if we can use “nodeName” if we only want to assign the pod to particular node
Both are used because:
- taints allow the node to repel pods but but it doesn’t guarantee that a node with matching tolerations would be place on it
2. using “nodeSelector” guarantees that the pod will be placed on that node
thanks for replying
but my question is regarding
“nodeName” vs “tolerations & nodeseletor”
can we use nodeName only to put the pod let’s say only on master
nodeName isn’t the recommended option especially when using nodes provisioned by your cloud provider. You’d rather want to combine nodeSelector with taints and tolerations
I believe I actually read that recommendation within the K8s documentation
but with exam point of view is that ok to use it to save some of your time?
Baskar Lingam Ramachandran:
since in the question a word is there about scheduling, using nodeSelector with nodeAffinity is the right approach
Using nodeName means bypassing the scheduler
this is the killer.sh question I was refering
Create a single Pod of image
httpd:2.4.41-alpine in Namespace
default. The Pod should be named
pod1 and the container should be named
pod1-container. This Pod should only be scheduled on a master node, do not add new labels any nodes.
so probably if not mentioned i can use nodeName
ok you can’t add labels but you can make use of the labels that come with the master node In this case though, nodeName should satisfy the question.
the outcome is the same, but the question in my opinion is not very specific and “nodname” should be accepted unless the word “scheduled” means by using the scheduler which nodename does not use (it bypasses it)
Hi @saad naeem I also saw the same question and had the same doubt. I think we should be setting a tint and also the nodeName. I feel it is better to follow what is given in the answer.