Application deployment constraint on the basis of hostname

Hello Team,

Consider a scenario where we have 6 nodes acting as nomad clients. Now I want to deploy a job in such a way that it will deploy the application only on 2 specific machines rather than all 6. This means the job should spin one instance of app each on both the machines.

Is there any way we can set some constraint as hostname of the machine. If it is possible then it will be very easy to manage as we just have to specify the instance value as 2(1 per node) and constraints in an array like [hostname1, hostname2] in the job file.

Any suggestions please. Can anyone share the template of job file here.

It seems that you should be able to use a constraint https://www.nomadproject.io/docs/job-specification/constraint with the ${attr.unique.hostname} property https://www.nomadproject.io/docs/runtime/interpolation#node-variables-

Are you having any specific issues with that?

Thanks a lot for sharing. Actually I’m on beginner stage and don’t know much of it…

This variable can help me but is there any way I can put these restrictions at client level. Because, I don’t want any other job to run on it. Other developers are already pushing their jobs and in that case it is difficult to ask everyone(330+) to add a constraint in job file.

Can we add any constraint or flag at nomad client level and then within the job file if that specific flag is set, only then the application will deploy within the specific machine.

Its like taint and tolerant concept in Kubernetes.