I'm to setup druid cluster with k8s and I'm seeking for help about how to expose redirection between pods outside k8s cluster. Say I have two ClusterIP services to expose pods outside k8s.
Could you please give me some suggestion on how to deal with this situation? Any tips is appreciate.
Here is the return after running wget -S -O - 10.0.0.1:8081
--2017-07-21 16:36:18-- http://10.0.0.1:8081/ Connecting to 10.0.0.1:8081... connected. HTTP request sent, awaiting response... HTTP/1.1 307 Temporary Redirect Date: Fri, 21 Jul 2017 08:36:25 GMT Location: http://coordinator:8081/ Content-Length: 0 Server: Jetty(9.3.16.v20170120) Location: http://coordinator:8081/ [following] --2017-07-21 16:36:18-- http://coordinator:8081/ Resolving coordinator (coordinator)... failed: Temporary failure in name resolution. wget: unable to resolve host address 'coordinator'
The problem is not with kubernetes. The application server (Jetty) issues the redirect (to 'coordinator'; not 'coordinator1/2' which is another problem), not kube-proxy.
Probably the simplest solution is to setup an nginx inside your cluster to do reverse proxy to handle that redirect.
(You also don't need 2 services like you have now either)
One solution that comes to my mind (although a bit overenginered) is to make sure you always hit only the leader.
If you can create a readiness check against your pods that returns ok if it is the leader and link them to a common service, that service will always direct to the active leader.
nginx + confd
I had exactly the same problem and found the best solution in installing an nginx reverse proxy, forwarding all traffic to the current leader. The nginx config gets updated by confd, which is watching zookeeper for changes at the overlord/coordinator discovery keys.
To set things up, I found this article quite helpful.