apache / apisix

The Cloud-Native API Gateway
https://apisix.apache.org/blog/
Apache License 2.0
14.58k stars 2.53k forks source link

feat: make dns resolution answers TTL configurable #11107

Open darkSheep404 opened 8 months ago

darkSheep404 commented 8 months ago

Description

we using upstream config in yml like that

upstreams:
  - id: app
    name: app
    pass_host: node
    nodes:
      "app.test.com": 1
    scheme: https

currently app.test.com point to 2 instance A (ip : 1.1.1) ,B (ip: 2.2.2) if A down, app.test.com will auto point to B(ip: 2.2.2) when using nginx we can use below code to let nginx refresh ip of app.test.com every 10 seconds to ensure get the lastest ip

location /lst-dns-test/ {
   resolver 6.6.6.6  valid=10s;   # 6.6.6.6 is a dns server
   set $proxy_url "app.test.com";
   proxy_pass http://$proxy_url;
}

can we do this in apisix for below upstream ?

upstreams:
  - id: app
    name: app
    pass_host: node
    nodes:
      "app.test.com": 1
    scheme: https

Environment

hanqingwu commented 8 months ago

https://apisix.apache.org/docs/apisix/discovery/dns/ Does this help you?

darkSheep404 commented 8 months ago

https://apisix.apache.org/docs/apisix/discovery/dns/ Does this help you?

thanks for your help but seems this config can only let upstreams use a dns server, can not set valid=10s; to keep refresh to get lastest ip ?

hanqingwu commented 8 months ago

yes, I think dns resolve is realtime , no cache valid for 10s .