consul

# - manually administering to configurations can be an anti-pattern
# - this era of automation and microservices should mean that Consul should never be touched by a human
# - Any agent may run in one of two modes: client or server

# SHOW LEADER
curl http://localhost:8500/v1/status/leader

# GET
curl http://8.8.8.8:8500/v1/kv/x?raw

# PUT
curl -X PUT http://8.8.8.8:8500/v1/kv/x -d '555'

# DELETE
curl -X DELETE http://8.8.8.8:8500/v1/kv/alex/w

# KEYS
curl http://8.8.8.8:8500/v1/kv/services?keys

# ADD CLIENT
# ON CLIENT TYPE
consul join -rpc-addr=CLIENT_BIND_ADDR:8400 CONSUL_SERVER

# LIST NODES
curl --header "X-Consul-Token: abcd1234" http://127.0.0.1:8500/v1/agent/members
# SERVER
# cat 20-agent.json
{
"server": true,
"bind_addr": "172.22.0.115",
"client_addr": "172.22.0.115",
"ui": true,
"encrypt": "yAGZtpXn4lOfltz7IyzdqQ==",
"datacenter": "test",
"data_dir": "/var/lib/consul",
"start_join": ["172.22.0.115", "172.22.0.116", "172.22.0.117"],
"retry_join": ["172.22.0.115", "172.22.0.116", "172.22.0.117"],
"log_level": "INFO"
}
INSERT "bootstrap_expect": 3, at first time

# cat web.json
{"service": {"name": "web", "tags": ["rails"], "port": 80}}
# CLIENT
# cat 20-agent.json
{
"server": false,
"bind_addr": "172.22.0.168",
"client_addr": "172.22.0.168",
"encrypt": "yAGZtpXn4lOfltz7IyzdqQ==",
"datacenter": "test",
"data_dir": "/var/lib/consul",
"log_level": "INFO",
"retry_join": [
  "172.22.0.115",
  "172.22.0.116",
  "172.22.0.117"
  ]
}
# cat elasticsearch-server.json
{"service": {"name": "elastic", "tags": ["db"], "port": 9201}}

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>