consul

概念

nodes: 实例节点
services: 服务(一般是 http/rpc client)

install

# download from :https://www.consul.io/downloads.html
# start agent
consul agent -dev
# test 
consul members
curl localhost:8500/v1/catalog/nodes
# tag service
echo '{"service": {"name": "web", "tags": ["rails"], "port": 80}}' \
    | sudo tee /etc/consul.d/web.json

test dns:

dig @127.0.0.1 -p 8600 web.service.consul
web.service.consul.	0	IN	A	127.0.0.1

HTTP API

set key v

curl --request PUT --data bar http://localhost:8500/v1/kv/foo

get key v

curl http://localhost:8500/v1/kv/foo

delete key v

curl --request DELETE http://localhost:8500/v1/kv/foo

agent

agent members:

curl http://localhost:8500/v1/agent/members

reload

curl  --request PUT http://localhost:8500/v1/agent/reload

log monitor:

http://localhost:8500/v1/agent/monitor?loglevel=WARN

event

show

curl http://localhost:8500/v1/event/list

catalog

list node:

curl http://localhost:8500/v1/catalog/nodes

dc list:

curl http://localhost:8500/v1/catalog/datacenters

services:

curl http://localhost:8500/v1/catalog/services

List Nodes for Service:

curl http://localhost:8500/v1/catalog/services/myersguo.github.com

List Service for node:

curl http://10.8.163.168:2280/v1/catalog/node/n6-028-xxx

«« flask algorithm »»