Hi, I had shared a topic 《基于APISIX的定制开发》 in Apisix DevCon 2020, which referred to our consul key&value service discovery module a little. And we want to submit it as a PR for APISIX now.
For users who used nginx-upsync-module<https://github.com/weibocom/nginx-upsync-module> and consul key value for service discovery way, maybe need it. This module called consul_kv, and its worker process data flow is below: [cid:[email protected]] How to use it 1. enable the consul_kv module in yaml discovery: consul_kv: servers: - "http://127.0.0.1:8500" - "http://127.0.0.1:8600" prefix: "upstreams" skip_keys: - "upstreams/unused_api/" timeout: connect: 1000 read: 1000 wait: 60 weight: 1 delay: 5 connect_type: "long" default_server: host: "127.0.0.1" port: 20999 metadata: fail_timeout: 1 weight: 1 max_fails: 1 2. register your api service into consul by key&value curl \ -X PUT \ -d ' {"weight": 120, "max_fails": 2, "fail_timeout": 1}' \ http://127.0.0.1:8500/v1/kv/upstreams/webpages/172.19.5.12:8000 curl \ -X PUT \ -d ' {"weight": 120, "max_fails": 2, "fail_timeout": 1}' \ http://127.0.0.1:8500/v1/kv/upstreams/webpages/172.19.5.13:8000 3. setup your route --- apisix_yaml routes: - uri: /* upstream: service_name: http://127.0.0.1:8500/v1/kv/upstreams/webpages/ discovery_type: consul_kv type: roundrobin If it ok, I prepare to submit the codes, tests and docs later :))
