-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Example with consul.io #1095
Comments
@throrin19 to use the DNS resolution provided by Consul (and leverage its load balancing), you need to specify the DNS resolver address in the Kong configuration, specifically you would need the following entry: dns_resolver: server
dns_resolvers_available:
server:
address: "1.1.1.1:53" Where At this point any upstream hostname, for example |
Can I use 2-3 DNS server? Will Kong load balancing between them? Can Kong detect failed dns server and won't query to that dns server? |
When I change configuration to: dns_resolver: dnsmasqdns_resolver: server dnsmasq:port: 8053I can't restart Kong: |
@jimmypk that doesn't look like a valid YAML format, try with proper indentation, like: dns_resolver: server
dns_resolvers_available:
server:
address: "192.168.9.31:8600" Kong will only accept one address. In order to load balancer the DNS queries across multiple servers, then you need to put a TCP load balancer in front of your DNS servers and point to the load balancer in the |
I forgot the syntax when copy to here. The kong.yml is the same with your post. But it still doesn't run. I check log file at /usr/local/kong/logs/error.log
If I remove 4 lines of dns. Kong starts normally. I don't know why can't configure dns (that is consule dns server). Currently I use kong version 0.7.0 "you need to put a TCP load balancer in front of your DNS servers" => DNS is UDP protocol, we can't use TCP load balancer for DNS query. |
Touchè, I wanted to say a UDP load balancer.
Those errors should not affect the DNS resolutions. I will try locally with Consul and let you know the results of my test. |
Kong started ok with dns of consul server. |
Kong will execute a normal DNS query, and it currently doesn't support SRV queries. Does Consul only support SRV queries or also normal queries? |
Consul only support SRV queries for service discovery. |
@jimmypk got it - then support for SRV should be introduced in 0.9.0 since we will adopt https://github.com/openresty/lua-resty-dns for DNS resolutions by then, and the lua-resty-dns module should support SRV. |
Thanks for your roadmap. |
@thefosk Hi, are u already working on this or is just planned? |
This is only planned, there are other things we must address before, including first releasing 0.8. |
hey @thibaultcha I would like to help with this, maybe I can open an issue to discuss with you guys the better way to implement this, what do you think? |
The But the |
OK, I'll do some palliative method until we can discuss again. There is an issue tracking the refactor/cli change? |
@jimmypk I was reading the Consul documentation, and it seems like it supports both A and SRV records for service discovery (as opposed to your previous comment which stated that it only supports SRV records):
|
I think that using the A records from consul and settings the ports mannually could be palliative, but considering my scenario, where all upstreams are docker containers, registered on consul with random ports (avoiding ports conflicts on docker), this still doesn't resolves the issue. One thing that I'd used with vanilla nginx, is to generate |
I'm a little late to the discussion but was dropping in to point out that consul-template (as @geovanisouza92 noted) would work quite well for specifying nginx upstreams |
Any news about the release of Kong 0.9 and SRV change? 0.9.0 RC1 doesn't seems explicit about it. |
@Kemicalish It looks the answer to your question was given in the relevant pull request. Unfortunately, the SRV resolver won't make it into 0.9. |
Considering this question answered so far. |
Container internal port and external port is not the same, how to do it better |
@huyifanstar I'd suggest starting a new issue and explain the difficulty you're having. |
consul-server and kong-server: kong Error An unexpected error occurred. 2016-11-30 02:37:03 kongnginx_kong_1 migrating core for database kong |
@jimmypk consul-server and kong-server: kong Error An unexpected error occurred. |
with all the linked issues closed, is it safe to assume that Kong now supports querying SRV records as well? this is important for multiple nodejs instances running on a single host |
It does in the |
0.10.0 whether to include the keepalive function, it can inspect the health status of services ? |
Hi, @thefosk |
@magicliang from 0.10 onwards Kong does its own dns resolution. You can configure multiple dns servers, which will be queried randomly (load will be equally distributed). There are however no healthchecks for the dns servers to mark them down or bad. Kong will not query on every request, it will cache results and only requery when the ttl expires. |
Thanks for the answers. dns_resolver: server And I can understand there is no health check. But when a dns server is down, it will not respond to a SRV request, will Kong retry dns resolving in next dns server? |
I do some search about the SRV DNS record, my understanding is that every DNS server can configure a ttl for certain records, and it is the client that decides whether to purge the stale cache and get new records. I think that is what Kong will do, am I correct? |
if you change the dns_resolver, you must run the kong migrations!!! |
@huangnanyang no. you do not have to run migrations for changing the dns resolver. Migrations are only to update the structures in the DB when entities get new properties for example. Setting another dns server in the config file will only require a reload. @magicliang missed your question before, sorry about that. But for future reference: Yes, Kong will honor the TTL it received. Once it expires Kong will request the name again from the nameserver and use that new info going forward. |
I use docker registrator container: webservice container: login: http://172.16.100.101:8500 I can see my webservice dig @172.16.100.101 -p 8600 helloworld.service.consul ;; QUESTION SECTION: ;; ANSWER SECTION: ;; Query time: 0 msec kong container: I have add apis: I also can visit : http://172.16.100.101:8000/helloworld but I want use consul DNS so I do this then I add apis : but I cann't visit http://172.16.100.101:8000/helloworld kong logs write error: sorry for my poor English! |
Kong:0.11.0 |
Hi,
I start to change all of my company architecture from monolyth API to microservices approache. After several weeks, we find Kong to (correct me if i am wrong) make the proxy and api gateway part and Consul to make the registrator part.
After several days, I find how to add into consul automatically all my services and now i search how to add this services into Kong automatically and how to set the loadBalancer if I have x occurences of one microservice.
Have you examples, sources, documentations, .. to do this ?
Thanks.
PS : Sorry for my english
The text was updated successfully, but these errors were encountered: