Skip to content

Instantly share code, notes, and snippets.

@bijay-shrestha
Last active June 30, 2019 09:52
Show Gist options
  • Save bijay-shrestha/536cbb9aec639e5ad54c928b1172d0ac to your computer and use it in GitHub Desktop.
Save bijay-shrestha/536cbb9aec639e5ad54c928b1172d0ac to your computer and use it in GitHub Desktop.

What is Consul?

Consul is a distributed service mesh to connect, secure, and configure services across any runtime platform and public or private cloud

Consul Installation and usage

  1. 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
  1. Move consul to /usr/local/bin/
sudo mv consul /usr/local/bin/
  1. 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)
  1. 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

  1. Then, create a spring boot application and integrate with the consul tool. Follow this link

  2. To bootstrap consul clusters you can also follow this link

  3. Click here for a step by step demonstration of consul usage.

  4. application.yml for normal spring-boot application with integrated consul is

spring:
  application: {name: 'consul-backend'}
  cloud:
    consul:
      enabled: 'true'
      host: http://localhost
      port: 8500
      discovery: {healthCheckInterval: 300s}
      config: {fail-fast: true}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment