tzssangglass opened a new issue #4713:
URL: https://github.com/apache/apisix/issues/4713


   APISIX supports service discovery using etcd. There is no service discovery 
API in the official implementation of etcd, so the only way to let APISIX to 
discover services is to implement your own framework for service registration. 
This is also the way used by APISIX.
   
   In the custom service registration framework, simply convert the information 
of the backend service into APISIX `upstream` format and write it to the 
`/apisix/admin/upstreams` directory of etcd using APISIX admin api or etcd data 
read/write interface, which completes the service registration.
   
   for example:
   
   ```shell
   $ curl http://127.0.0.1:9080/apisix/admin/upstreams/myAPIProvider  -H 
'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -i -X PUT -d '
   {
       "type":"roundrobin",
       "nodes":{
           "39.97.63.215:80": 1
       }
   }'
   ```
   
   Here `myAPIProvider` is a backend service information converted to APISIX 
`upstream` format. This is the service registration, and when you config the 
APISIX `route`, you can use `myAPIProvider` directly as an `upstream`, for 
example:
   
   ```shell
   $ curl "http://127.0.0.1:9080/apisix/admin/routes/1"; -H "X-API-KEY: 
edd1c9f034335f136f87ad84b625c8f1" -X PUT -d '
   {
     "uri": "/get",
     "upstream_id": "myAPIProvider"
   }'
   ```
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to