Note: I am not asking about Consul HTTP port 8500. Can I call an API exposed by a microservice, which is discovered using Consul, just by the .service.consul/ WITHOUT specifying the port number?
I am using Consul for discovering multiple versions of a microservice. This microservice (written in Java) has port predetermined:
Service registered in consul as - my-service.service.consul (service port is, let us say 3030). I have another version of the same micro service registered with consul: my-servicev2.service.consul (port 3033).
Service definition (altered for the example):
{
"Address": <IP address>,
"CreateIndex": 111,
"ModifyIndex": 000,
"Node": <node name>,
"ServiceAddress": "",
"ServiceEnableTagOverride": false,
"ServiceID": "my-servicev2",
"ServiceName": "my-servicev2",
"ServicePort": 3033,
"ServiceTags": [
"v2"
],
"TaggedAddresses": {
"lan": <LAN IP>,
"wan": <WAN IP>
}
}
I can ping and dig the service using dig @localhost my-service.service.consul' orping -c2 my-service.service.consul`
But, how can I access one of the APIs exposed by this microservice without explicitly using the ServicePort?
Here is what is working:
curl http://my-servicev2.service.consul:3033/health -> resolves the service name, maps it to one of the deployed VM IP, and gives back the API response. In this case something like: `{"build"`: 'OK"}`
However, I should be able to access the API without specifying the port number like this:
curl http://my-servicev2.service.consul/health ->{"build": "OK"}`
Is this possible in Consul?
I've tried registering the service without Port value, and it added 0 as port value.