I'm learning about microservices recently. I tried using consul for service discovery. I wonder if I deploy the consul server, so where should i store endpoint of that server? Is it good to hard code in env variable of each services?
Create
/etc/consul.d/config.json
The key is start_join with value of the IP of Consul server e.g.,
"start_join": [ "10.128.0.2" ]
For a cluster solution of more than one Consul instances:
"start_join": [ "10.128.0.2", "10.128.0.3" ]
The default server port is 8300 but you may override with the ports object offering multiple ports to override e.g.,
"ports": {
"server": 8300
}
For a full reference of the available options, you may check the Consul Documentation, and all the available ports options