-
Start a consul process as a server on the master node.
-
Start a consul process as an agent on both app1 and app2.
-
Add a service with the name "producer" to /etc/consul.d on app1 and app2 and do a
consul reload
. The Consul service guide -
Use the HTTP API and check that you got a result for the queried service
curl http://localhost:8500/v1/catalog/service/<service name>
- Do the same with the DNS API
dig @127.0.0.1 -p 8600 <service name>.service.consul
The consumer app currently integrates with the producer on a hardcoded IP and port.
THIS IS NOT OK!!!
Your job is to decouple the consumer from that producer instance by introducing a whiff of service discovery. How you do it is up to you:
- By using consuls DNS API (NB: SRV records)
- By using consuls HTTP API
- Or some other way, if you've got any good ideas
Extend the startup script of the application to use the maintance API to tell Consul the application is available when it starts, and mark it as unavailable when it exits.
If you've got the time, try to integrate consul-template with a loadbalancer (NginX/HAProxy/Apache)
E.g. have an HAProxy instance loadbalance requests to a dynamic set of producer apps.