Service discovery, monitoring, load balancing, and more with Consul

Cloud Nanny

Accessing Services Through DNS

The registered Consul services can be accessed through DNS, and one of the easiest ways is with Dnsmasq. Adding the /etc/dnsmasq.d/10-consul file shown in Listing 13 should enable Consul DNS lookup.

Listing 13

Consul DNS Lookup

$ cat /etc/dnsmasq.d/10-consul
# Enable forward lookup of the 'consul' domain:
server=/consul/127.0.0.1#8600
$ dig @localhost -p 8600 MyTomcatApp.service.consul
; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.62.rc1.57.amzn1 <<>> @localhost -p 8600 MyTomcatApp.service.consul
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 5337
;; flags: qr aa rd; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 0
;; WARNING: recursion requested but not available
;; QUESTION SECTION:
;MyTomcatApp.service.consul.    IN      A
;; ANSWER SECTION:
MyTomcatApp.service.consul. 0   IN      A       172.31.31.130
MyTomcatApp.service.consul. 0   IN      TXT     "VERSIONEDCONSULREGISTRATION=false"
MyTomcatApp.service.consul. 0   IN      TXT     "APPLICATION=app"
;; Query time: 1 msec
;; SERVER: 127.0.0.1#8600(127.0.0.1)
;; WHEN: Tue Jul 10 04:31:28 2018
;; MSG SIZE  rcvd: 134

Conclusions

Consul is one of the best tools for helping you manage your dynamic infrastructure in a cloud environment, and it works well not only with VMs and EC2 instances, but with containers as well. With the appropriate Consul templates, your entire application and production infrastructure maintenance can be automated and overhead reduced.

Infos

  1. Service mesh made easy: https://www.consul.io
  2. Consul architecture: https://www.consul.io/docs/internals/architecture.html

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy ADMIN Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

comments powered by Disqus