Hi,

Here is the consul_kv’s data flow png:

https://user-images.githubusercontent.com/548385/107141841-6ced3e00-6966-11eb-8aa4-bc790a4ad113.png

BTW, I need some time to prepare:

  *   doc
     *   english
     *   chinese
  *   tests
  *   CI
     *   run two instance of consul servers
  *   code
     *   a little details adjust


2021年2月7日 21:35,Zexuan Luo 
<spacewan...@apache.org<mailto:spacewan...@apache.org>> 写道:

Ignore my question. It seems they are two different things.

Zexuan Luo <spacewan...@apache.org<mailto:spacewan...@apache.org>> 于2021年2月7日周日 
下午9:32写道:

PR is welcome!
BTW, does it require nginx-upsync-module?

聂永 <niey...@staff.weibo.com<mailto:niey...@staff.weibo.com>> 于2021年2月7日周日 
下午5:22写道:

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:

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_yamlroutes:
 -
   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 :))



Reply via email to