Ich bin mit einem SCN-Cluster in Docker-Containern mit der folgenden Docker-compose.yaml Datei:Entdeckung nsqd Serveradresse von nslookupd
version: '2'
services:
nsqlookupd:
image: nsqio/nsq
command: /nsqlookupd
ports:
- "4160"
- "4161:4161"
nsqd:
image: nsqio/nsq
command: /nsqd --lookupd-tcp-address=nsqlookupd:4160 --data-path=/data
volumes:
- data:/data
ports:
- "4150:4150"
- "4151:4151"
nsqadmin:
image: nsqio/nsq
command: /nsqadmin --lookupd-http-address=nsqlookupd:4161
ports:
- "4171:4171"
volumes:
data:
Alles in Ordnung läuft. Aber, wenn ich den/die Knoten Endpunkt auf dem nsqdlookup Server aufrufen bekomme ich diese:
$ http http://localhost:4161/nodes
HTTP/1.1 200 OK
Content-Length: 238
Content-Type: application/json; charset=utf-8
Date: Tue, 24 Jan 2017 08:44:27 GMT
{
"data": {
"producers": [
{
"broadcast_address": "7dd3d550e7f8",
"hostname": "7dd3d550e7f8",
"http_port": 4151,
"remote_address": "172.18.0.4:57156",
"tcp_port": 4150,
"tombstones": [],
"topics": [],
"version": "0.3.8"
}
]
},
"status_code": 200,
"status_txt": "OK"
}
Die Broadcast-Adresse sieht aus wie der Name/Host-Namen des Containers. Ich habe versucht, auf Port 4151 nur für den Fall zu pingen, aber es schlägt fehl.
> http http://7dd3d550e7f8:4151/ping
http: error: ConnectionError: HTTPConnectionPool(host='7dd3d550e7f8', port=4151): Max retries exceeded with url: /ping (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x000001C397173EF0>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed',)) while doing GET request to URL: http://7dd3d550e7f8:4151/ping
Das Gleiche gilt für die Remote-Adresse:
> http http://172.18.0.4:4151/ping
http: error: ConnectionError: HTTPConnectionPool(host='172.18.0.4', port=4151): Max retries exceeded with url: /ping (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x000001C0D9545F28>: Failed to establish a new connection: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond',)) while doing GET request to URL: http://172.18.0.4:4151/ping
Alles funktioniert, wenn ich localhost oder 127.0.0.1 verwenden:
> http http://localhost:4151/ping
HTTP/1.1 200 OK
Content-Length: 2
Content-Type: text/plain; charset=utf-8
Date: Tue, 24 Jan 2017 08:51:30 GMT
OK
Aber, das ist Betrug. Der springende Punkt der nsqlookupd-Server ist, dass sie die nsqd-Server verfolgen, sodass Clients dynamisch eine Liste mit responsiven Servern abrufen können.
Ist eine zugängliche URL/IP-Adresse für nsqd-Knoten vom nslookupd-Server möglich, wenn die nsqd-Knoten in Docker-Containern ausgeführt werden?
Gibt es eine magische Beschwörung, damit es funktioniert?
Hat jemand versucht, vielleicht mit Swarm oder Kubernetes?
Habe das gleiche Problem. Mit PetSet/StatefulSet einfach zu überwinden, aber auf GKE ist es noch nicht verfügbar –