Hi,
First of all, OpenResty is a lifesaver. Thanks for creating it.
I'm trying to do loadbalancing in kubernetes cluster.
Scenario:
I've a websocket(socketio with redis backend for clustering) application with multiple replicas. And OpenResty is my reverse proxy/entry point. I want sticky sessions for this web service app. I'm using headless service for aforementioned applicaton.
root@ngx-54846c7555-2d2z8:/# dig headerecho.app.svc.cluster.local
; <<>> DiG 9.11.5-P4-5.1+deb10u6-Debian <<>> headerecho.app.svc.cluster.local
;; global options: +cmd
;; Got answer:
;; WARNING: .local is reserved for Multicast DNS
;; You are currently testing what happens when an mDNS query is leaked to DNS
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 60993
;; flags: qr aa rd; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1
;; WARNING: recursion requested but not available
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
; COOKIE: f0ca6cd2f23e3f76 (echoed)
;; QUESTION SECTION:
;headerecho.app.svc.cluster.local. IN A
;; ANSWER SECTION:
headerecho.app.svc.cluster.local. 5 IN A 10.42.0.113
headerecho.app.svc.cluster.local. 5 IN A 10.42.0.112
;; Query time: 0 msec
;; SERVER: 10.43.0.10#53(10.43.0.10)
;; WHEN: Thu Feb 24 12:37:05 UTC 2022
;; MSG SIZE rcvd: 169
As you can see, the DNS query is returning 2 IP addresses(of 2 replicas)
I've tried using lua-resty-loadbalancer reference
But it requires IP addresses to be passed on, with no direct dns resolution.
I'm by no means an expert in lua. To be frank, super noob.
If anyone can give some suggestions or solutions, appreciate it a lot.
Thanks once again.