Consul基础

Consul基础

简介

注册

  • HTTP API
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
curl -X PUT -d \
    '{
        "id": "jetty",
        "name": "jetty",
        "address": "192.168.1.200",
        "port": 8080,
        "tags": ["dev"],
        "checks": [{"http": "http://192.168.1.104:9020/health","interval": "5s"}]
    }' \
    http://192.168.1.100:8500/v1/agent/service/register




## 删除所有注册的service
  for key in `curl -X GET  'http://192.168.1.200:8500/v1/agent/services' | jq -r  'to_entries|.[] | select(.value.Tags | contains(["cluster=chubaofs-test-03"]) ) | .key'` ; do 
      echo "key: $key"; k=$key; 
      url="http://192.168.1.200:8500/v1/agent/service/deregister/$k" ; echo $url ; 
      curl -X PUT "$url" ; 
  done 

参考

updatedupdated2024-11-232024-11-23