Consul is a distributed service mesh to connect, secure, and configure services across any runtime platform and public or private cloud
- Download and install Consul on Ubuntu 18.04 from here
or
export VER="1.5.1"
wget https://releases.hashicorp.com/consul/${VER}/consul_${VER}_linux_amd64.zip
and extract the file using
unzip consul_${VER}_linux_amd64.zip
- Move consul to
/usr/local/bin/
sudo mv consul /usr/local/bin/
- To verify Consul is properly installed, run consul -v on your system.
# consul -v
Consul v1.5.1
Protocol 2 spoken by default, understands 2 to 3 (agent will automatically use protocol >2 when speaking to compatible agents)
- Bootstrap consul using following command.
$ consul agent -server -bootstrap-expect=1 -data-dir=consul-data -ui -bind=10.13.184.21
Notes on above commands can be found here
-
Then, create a
spring boot application
and integrate with the consul tool. Follow this link -
To bootstrap consul clusters you can also follow this link
-
Click here for a step by step demonstration of consul usage.
-
application.yml
for normal spring-boot application with integratedconsul
is
spring:
application: {name: 'consul-backend'}
cloud:
consul:
enabled: 'true'
host: http://localhost
port: 8500
discovery: {healthCheckInterval: 300s}
config: {fail-fast: true}