Hello,
I wanted to try nomad with Consul and the whole service discovery thing and so on. And so I did. This was a non-production small scale laze setup on my laptop. Everything should work out of the box with little to zero effort. And so it did, although there was some effort. I've used "nomad init" to generate "example.nomad" job, because I wanted to get something up really quick at this point and didn't want to prepare some dummy web app as this will come a bit later when I'm sure it's worth the time and effort. Here comes the catch. I've launched the job and went to look where to find Redis service in Consul. The only thing I could see was "global-redis-check". Ok, the check is in Consul, but where is the service? Couple hours later I've found out more or less by accident and, if I remember correctly, in unrelated thread in this group. You see, what I didn't know, what didn't occur to me, is the fact that:
1. the name of the service in "example.nomad" is "global-redis-check"
2. checks themselves aren't registered in Consul
Absolutely my bad on the fist count. Still, I would like to propose two things.
First one is to rename "gloabal-redis-check" in the example to something else. Be it "global-cache-redis", which is the default name when "name" attribute is omitted, resp. it's auto-generated name by nomad, or "cache-redis" or "name = ${BASE}". I believe this is more expected and more in line with what "production" setup will look like. I doubt anyone will use something like "global-redis-check" for service discovery(DNS). Also, the name is confusing, although I came up with explanation, sort of - "check if service is alive and registered in Consul" or something like that.
Second, please, update documentation(
https://www.nomadproject.io/docs/job-specification/service.html) and add the fact that service name in Consul is the same as the value of "name" attribute in service stanza, if present. Maybe add the fact that checks aren't being registered in Consul as well. I was searching for anything related to nomad-Consul registration, what the name of the service should look like in Consul, why it doesn't work for me etc. and I just couldn't find anything.
I understand this is more or less corner case and 99% of people won't either go or work this way or will simply read more. However, I still think it's valid, hence the post.
Best regards,
Z.