Geeks With Blogs
Josh Reuben

HashiCorp Consul https://www.consul.io/ provides an easy to use, multi-region Service Discovery / Health-Check + distributed config keyval store. If you have ever hacked away at coding ZooKeeper to support distributed systems, Consul's Agent based architecture requires an order of magnitude less effort to roll out.

Here's my Consul QuickRef:

CLI options:

  • agent - Runs a Consul agent
    • -dev
    • -server
    • -config-dir=xxx
    • -data-dir=xxx
    • -bind=
    • -bootstrap-expect=<#server-nodes>
    • -name=
    • -atlas-join, -atlas=, atlas-token=xxx
    • -ui #start the ui on http://localhost:8500/ui.
  • config-test - sanity test of config files
  • event - Fire a new event (can be handled by a watch)
    • -http-addr - of the agent
    • -datacenter
    • -name - of the event.
    • -node / service/ tag - regex target filters
    • -token
  • exec - Executes a command on Consul nodes. same options as event +
    • -wait, -wait-repl
  • force-leave Forces a member of the cluster to enter the "left" state
  • info Provides debugging information for operators
  • join Tell Consul agent to join cluster
  • keygen Generates a new encryption key
  • leave Gracefully leaves the Consul cluster and shuts down
  • lock semaphore distributed lock in KV store
    • -n #holders
    • -name
    • -pass-stdin
    • -try, -monitor-retry
  • maint - mark a service provided by a node or the node as a whole as "under maintenance"
    • -enable / disable
    • -reason
    • -service
  • members Lists the members of a Consul cluster:
    • -detailed
    • -status monitor Stream logs from a Consul agent
    • -log-level reload Triggers the agent to reload configuration files version Prints the Consul version watchWatch for changes in Consul
    • -http-addr , datacenter
    • -token
    • -key
    • -name (Event)
    • -passingonly=[true|false] - only passing services
    • -prefix
    • -service - Service to watch
    • -state - Check state to filter on
    • -tag - Service tag to filter on
    • -type - Watch type. Required, one of "key", "keyprefix", "services", "nodes", "service", "checks", or "event".

DNS:

dig @127.0.0.1 -p 9600 <node>.node.consul
[tag.]<service>.service[.datacenter].<domain>
dig @127.0.0.1 -p 9600 <tag>.<service>.service.consul SRV

API:

querystring params

  index=X-Consul-Index  - block until match ?
  wait  - timeout blocking
  consistent / stale - other consistency modes
  near
  passing

curl localhost:8500

/v1/acl/

  • create : Creates a new token with a given policy
  • update : Updates the policy of a token
  • destroy/ : Destroys a given token
  • info/ : Queries the policy of a given token
  • clone/ : Creates a new token by cloning an existing token
  • list : Lists all the active tokens

/v1/agent/

  • checks : Returns the checks the local agent is managing
  • services : Returns the services the local agent is managing
  • members : Returns the members as seen by the local serf agent
  • self : Returns the local node configuration
  • maintenance : Manages node maintenance mode
  • join/ : Triggers the local agent to join a node
  • force-leave/> : Forces removal of a node
  • check/register : Registers a new local check
  • check/deregister/ : Deregisters a local check
  • check/pass/ : Marks a local check as passing
  • check/warn/ : Marks a local check as warning
  • check/fail/ : Marks a local check as critical
  • check/update/ : Updates a local check
  • service/register : Registers a new local service
  • service/deregister/ : Deregisters a local service
  • service/maintenance/ : Manages service maintenance mode

/v1/catalog/

  • register : Registers a new node, service, or check
  • deregister : Deregisters a node, service, or check
  • datacenters : Lists known datacenters
  • nodes : Lists nodes in a given DC
  • services : Lists services in a given DC
  • service/ : Lists the nodes in a given service
  • node/ : Lists the services provided by a node

/v1/event/

  • fire/ : Fires a new user event
  • list : Lists the most recent events an agent has seen.

/v1/health/

  • node/ : Returns the health info of a node
  • checks/ : Returns the checks of a service
  • service/ : Returns the nodes and health info of a service
  • state/ : Returns the checks in a given state

/v1/kv/

  • GET , PUT , DELETE

/v1/coordinate/

  • datacenters : Queries for WAN coordinates of Consul servers
  • nodes : Queries for LAN coordinates of Consul nodes

/v1/query

  • Creates a new prepared query or lists all prepared queries
  • / : Updates, fetches, or deletes a prepared query
  • //execute : Executes a prepared query by its ID or optional name
  • //explain : Provides information about how a prepared query will be executed by its ID or optional name

/v1/session/

  • create : Creates a new session
  • destroy/ : Destroys a given session
  • info/ : Queries a given session
  • node/ : Lists sessions belonging to a node
  • list : Lists all active sessions
  • renew : Renews a TTL-based session

/v1/status/

  • leader : Returns the current Raft leader
  • peers : Returns the current Raft peer set

config:

/etc/consul.d/<service>.json

    {
      "service": {
        "name": "web",
        "tags": ["rails"],
        "port": 80,
        "check": {
          "script": "curl localhost >/dev/null 2>&1",
          "interval": "10s"
        }
      },
      "check": {
        "name": "ping",
        "script": "ping -c1 google.com >/dev/null",
        "interval": "30s"
      }
    }

five different kinds of checks

  • Script + Interval
  • HTTP + Interval
  • TCP + Interval
  • TTL + pass/fail endpoint
  • Docker Exec + Interval

watchers

watch the status of health checks and notify an external system when a check is critical. handler can be any executable - reads JSON input from stdin

types:

  • key - Watch a specific KV pair
  • keyprefix - Watch a prefix in the KV store
  • services - Watch the list of available services
  • nodes - Watch the list of nodes
  • service - Watch the instances of a service
  • checks - Watch the value of health checks
  • event - Watch for custom user events
Posted on Thursday, December 15, 2016 5:24 AM Cloud , Distributed Systems | Back to top


Comments on this post: Consul QuickRef

# re: Consul QuickRef
Requesting Gravatar...
This is such a great idea to follow. A timely information that is very useful to me. - Dr. Thomas Devlin
Left by Mike Kline on Dec 17, 2016 7:01 PM

# re: Consul QuickRef
Requesting Gravatar...
It’s really a great and helpful piece of line. I am glad that you shared this helpful info with us. Please keep us informed like this. pokemon go apk
Thanks for sharing
Left by pokemon go apk on Dec 20, 2016 7:25 AM

# nice article
Requesting Gravatar...
I loved the way you discuss the topic Consul QuickRef great work thanks for the sharing this valuable info. bhim I really enjoy reading this article.
Left by Bhim on Jan 08, 2017 11:41 AM

# re: Consul QuickRef
Requesting Gravatar...
I am truly delighted to glance at this blog posts which includes plenty
of valuable information, thanks for providing such information.
apps2apk
Left by ramya on Jan 19, 2017 9:35 AM

# re: Consul QuickRef
Requesting Gravatar...
I am thankfully to you that you share these information with us. I really learn lot of thinks to your blog.
Please share information about Facebook customer service number
Left by jems rock on Feb 12, 2017 7:34 AM

# re: Consul QuickRef
Requesting Gravatar...
I always find it very difficult to code a program and using this specific platform but after reading your post i fill that I code a program with else.
Facebook customer service number
Left by Stacy on Feb 12, 2017 8:12 AM

# re: Consul QuickRef
Requesting Gravatar...
I appreciate your blog. Thanks for sharing all this important information with us.
<a href="http://www.quicksupportservice.com/facebook-password-recovery.html”>Facebook Password Recovery
Left by Anabella on Feb 12, 2017 8:17 AM

# re: Consul QuickRef
Requesting Gravatar...
Great to come to your site as the information shared is good and is explained in simple words. Good stuff you are created, thank you for sharing a nice article. fastpokemap
Left by sahithi on Mar 22, 2017 7:16 AM

# re: Consul QuickRef
Requesting Gravatar...
I loved the way you discuss the topic great work thanks for the sharing this valuable info. I really enjoy reading this article.
http://ssapptricks.com/aliexpress-apk-download/
Left by AliExpress on Mar 22, 2017 2:18 PM

# apk free download
Requesting Gravatar...
Really appreciate for your amazing article. Keep going on, good stuff.Download filmywap apk for android.
Left by thilak on Apr 09, 2017 5:03 PM

# re: Consul QuickRef
Requesting Gravatar...
I loved the way you discuss the topic great work thanks for the sharing this valuable info. I really enjoy reading this article.

http://ssapptricks.com/gamestop/
Left by GameStop on Apr 24, 2017 9:45 PM

# http://ssapptricks.com/gamestop/
Requesting Gravatar...
This is a very interesting web page and I have enjoyed reading many of the articles and posts contained on the website, keep up the good work and hope to read some more interesting content in the future.
Left by GameStop on Apr 26, 2017 10:58 AM

# http://ssapptricks.com/yelp/
Requesting Gravatar...
Really appreciate for your amazing article. Keep going on, good stuff. Thank you for this valuable information.
Left by open in the Yelp app on Apr 29, 2017 8:30 PM

# http://ssapptricks.com/yelp/
Requesting Gravatar...
I loved the way you discuss the topic great work thanks for the sharing this valuable info. I really enjoy reading this article.
Left by open in the Yelp app on Apr 30, 2017 5:21 AM

# re: Consul QuickRef
Requesting Gravatar...
thank you very much for sharing amazing articles hereVOOT
Left by tinder on May 04, 2017 5:02 PM

# fastpokemap
Requesting Gravatar...
u discuss the topic great w
Left by paul on May 07, 2017 1:28 PM

# ssapptricks
Requesting Gravatar...
http://ssapptricks.com/blocket/
It is a great article. You will surely like this also because it is a great stuff, yeah it’s give us lots of interest and pleasure.
Left by Blocket on May 22, 2017 11:37 AM

# re: Consul QuickRef
Requesting Gravatar...
Blocket
vootapp80@gmail.com
http://ssapptricks.com/blocket/
It is a great article. You will surely like this also because it is a great stuff, yeah it’s give us lots of interest and pleasure.
Left by Blocket on May 22, 2017 7:36 PM

# http://tipsforapps.com/ace2three/
Requesting Gravatar...
The post is explained clearly so that we are able to understand it clearly.
Left by Ace2three on Jul 23, 2017 7:20 PM

# http://ssapptricks.com/symbolab/
Requesting Gravatar...

It​ ​is​ ​a​ ​great​ ​article.​ ​You​ ​will​ ​surely​ ​like​ ​this​ ​also​ ​because​ ​it​ ​is​ ​a​ ​great​ ​stuff,​ ​yeah
it’s​ ​give​ ​us​ ​lots​ ​of​ ​interest​ ​and​ ​pleasure.​ ​Their​ ​opportunities​ ​are​ ​so​ ​fantastic​ ​and
working​ ​style​ ​so​ ​speedy.​ ​Thank​ ​you​ ​for​ ​sharing​ ​the​ ​nice​ ​article.
Left by symboled on Jul 25, 2017 8:33 PM

# re: Consul QuickRef
Requesting Gravatar...

Valuable​ ​information!​ ​Looking​ ​forward​ ​to​ ​seeing​ ​your​ ​notes​ ​posted.​ ​The​ ​information​ ​you​ ​have
posted​ ​is​ ​very​ ​useful.​ ​Keep​ ​going​ ​on,​ ​good​ ​stuff.​ ​Thank​ ​you​ ​for​ ​this​ ​valuable​ ​information.​ ​I​ ​have
enjoyed​ ​reading​ ​many​ ​of​ ​the​ ​articles​ ​and​ ​posts​ ​contained​ ​on​ ​the​ ​website,​ ​keep​ ​up​ ​the​ ​good
work​ ​and​ ​hope​ ​to​ ​read​ ​some​ ​more​ ​interesting​ ​content​ ​in​ ​the​ ​future.
Left by symboled on Jul 26, 2017 10:24 AM

# re: Consul QuickRef
Requesting Gravatar...
Really appreciate for your amazing article. Keep going on, good stuff. Thank you for this valuable information. http://tipsforapps.com/gradeup/
Left by gradeuup on Aug 15, 2017 2:30 PM

# re: Consul QuickRef
Requesting Gravatar...
This is the right site for everyone who would like to find out about this topic. You realize so much its almost tough to argue with you (not that I actually would want to…HaHa). You definitely put a fresh spin on a topic which has been discussed for ages. Wonderful stuff, just great!
Jio4GVoice
Left by amijackson on Nov 22, 2017 7:28 PM

# re: Consul QuickRef
Requesting Gravatar...
I always find it very difficult to code a program and using this specific platform but after reading your post i fill that I code a program with else.
quicken customer support
Left by jazz on Nov 29, 2017 11:34 AM

Your comment:
 (will show your gravatar)


Copyright © JoshReuben | Powered by: GeeksWithBlogs.net