You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apisix.apache.org by 李 奕浩 <yi...@hotmail.com> on 2023/01/06 16:23:16 UTC

Change: optimize the Consul discovery plugin to obtain precise service node info from Consul cluster

Hi, community,

I wanted to talk to you about the optimization of the Consul discovery.

WHAT

Currently, the Consul discovery plugin can dump all services info in APISIX, Specific usage reference:

https://github.com/apache/apisix/blob/master/docs/en/latest/discovery/consul.md

In Consul discovery Lua code, the Consul discovery plugin used /catalog/services to check update and /agent/services to get all services info. for some situation, it can not get all services info from this /agent/services, reference reading: https://developer.hashicorp.com/consul/api-docs/agent/service

The /agent/service endpoints interact with services on the local agent in Consul. These should not be confused with services in the catalog.

WHY

  1.  Optimize Consul discovery plugin to make the APISIX more robust

  2.  Obtain the services info form Consul to be more precise

HOW

  1.  Obtain all services with /catalog/services, reference: Consul List Services<https://developer.hashicorp.com/consul/api-docs/catalog#list-services>

  2.  Obtain nodes for each service with /catalog/service/:service, reference: Consul List Nodes for Service<https://developer.hashicorp.com/consul/api-docs/catalog#list-nodes-for-service>

  3.  Save this service node info in local variable

Best Regard

Yihao LI

My GitHub: https://github.com/Fabriceli

Re: Change: optimize the Consul discovery plugin to obtain precise service node info from Consul cluster

Posted by 李 奕浩 <yi...@hotmail.com>.
Thanks for your reply, I had post a question in Consul Discuss: https://discuss.hashicorp.com/t/how-to-get-all-service-ip-port-via-consul-api/48712
They suggest using catalog/service/:service_id to fetch service info.




2023年1月9日 15:00,YuanSheng Wang <me...@apache.org> 写道:

hi:

I am not familiar with consul, but it seems that we should use `
/catalog/services`.

ANSWER 1:
https://stackoverflow.com/questions/44240633/single-api-to-list-all-the-services-consul-cluster

I advise to submit a question to the `consul` project:
https://github.com/hashicorp/consul

I think they can tell us which way is best.


On Sat, Jan 7, 2023 at 12:23 AM 李 奕浩 <yi...@hotmail.com> wrote:

Hi, community,

I wanted to talk to you about the optimization of the Consul discovery.

WHAT

Currently, the Consul discovery plugin can dump all services info in
APISIX, Specific usage reference:


https://github.com/apache/apisix/blob/master/docs/en/latest/discovery/consul.md

In Consul discovery Lua code, the Consul discovery plugin used
/catalog/services to check update and /agent/services to get all services
info. for some situation, it can not get all services info from this
/agent/services, reference reading:
https://developer.hashicorp.com/consul/api-docs/agent/service

The /agent/service endpoints interact with services on the local agent in
Consul. These should not be confused with services in the catalog.

WHY

 1.  Optimize Consul discovery plugin to make the APISIX more robust

 2.  Obtain the services info form Consul to be more precise

HOW

 1.  Obtain all services with /catalog/services, reference: Consul List
Services<
https://developer.hashicorp.com/consul/api-docs/catalog#list-services>

 2.  Obtain nodes for each service with /catalog/service/:service,
reference: Consul List Nodes for Service<
https://developer.hashicorp.com/consul/api-docs/catalog#list-nodes-for-service


 3.  Save this service node info in local variable

Best Regard

Yihao LI

My GitHub: https://github.com/Fabriceli



--

*MembPhis*
My GitHub: https://github.com/membphis
Apache APISIX: https://github.com/apache/apisix


Re: Change: optimize the Consul discovery plugin to obtain precise service node info from Consul cluster

Posted by YuanSheng Wang <me...@apache.org>.
hi:

I am not familiar with consul, but it seems that we should use `
/catalog/services`.

ANSWER 1:
https://stackoverflow.com/questions/44240633/single-api-to-list-all-the-services-consul-cluster

I advise to submit a question to the `consul` project:
https://github.com/hashicorp/consul

I think they can tell us which way is best.


On Sat, Jan 7, 2023 at 12:23 AM 李 奕浩 <yi...@hotmail.com> wrote:

> Hi, community,
>
> I wanted to talk to you about the optimization of the Consul discovery.
>
> WHAT
>
> Currently, the Consul discovery plugin can dump all services info in
> APISIX, Specific usage reference:
>
>
> https://github.com/apache/apisix/blob/master/docs/en/latest/discovery/consul.md
>
> In Consul discovery Lua code, the Consul discovery plugin used
> /catalog/services to check update and /agent/services to get all services
> info. for some situation, it can not get all services info from this
> /agent/services, reference reading:
> https://developer.hashicorp.com/consul/api-docs/agent/service
>
> The /agent/service endpoints interact with services on the local agent in
> Consul. These should not be confused with services in the catalog.
>
> WHY
>
>   1.  Optimize Consul discovery plugin to make the APISIX more robust
>
>   2.  Obtain the services info form Consul to be more precise
>
> HOW
>
>   1.  Obtain all services with /catalog/services, reference: Consul List
> Services<
> https://developer.hashicorp.com/consul/api-docs/catalog#list-services>
>
>   2.  Obtain nodes for each service with /catalog/service/:service,
> reference: Consul List Nodes for Service<
> https://developer.hashicorp.com/consul/api-docs/catalog#list-nodes-for-service
> >
>
>   3.  Save this service node info in local variable
>
> Best Regard
>
> Yihao LI
>
> My GitHub: https://github.com/Fabriceli
>


-- 

*MembPhis*
My GitHub: https://github.com/membphis
Apache APISIX: https://github.com/apache/apisix