You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by GitBox <gi...@apache.org> on 2019/08/25 21:43:30 UTC
[GitHub] [couchdb] sergey-safarov opened a new issue #2142:
docker/kubrenetes nodes discovery
sergey-safarov opened a new issue #2142: docker/kubrenetes nodes discovery
URL: https://github.com/apache/couchdb/issues/2142
## Summary
I can create docker stack using this file
```yaml
version: "3.7"
networks:
main:
services:
couchdb:
image: couchdb:2.3.1
environment:
- NODENAME=couchdb-{{.Task.Slot}}
- COUCHDB_SECRET=monster
- ERL_FLAGS="-setcookie monster"
ports:
- "5984"
- "5986"
networks:
- main
deploy:
replicas: 5
```
And command
```sh
docker stack deploy --compose-file docker-compose.yaml kazoo
```
This will create
1. `kazoo_main` network
1. `couchdb` service
1. five couchdb containers with unique names
Could you implement following logic for couchdb node discovery and automatic cluster formation.
**resolv ${SEED_DNS_NAME}**
```sh
root@dbef6f82ce5f:/# nslookup ${SEED_DNS_NAME}
Server: 127.0.0.11
Address: 127.0.0.11#53
Non-authoritative answer:
Name: tasks.couchdb
Address: 10.0.52.7
Name: tasks.couchdb
Address: 10.0.52.6
Name: tasks.couchdb
Address: 10.0.52.5
Name: tasks.couchdb
Address: 10.0.52.4
Name: tasks.couchdb
Address: 10.0.52.3
```
Now we can couchdb nodes names
```sh
root@dbef6f82ce5f:/# curl http://10.0.52.3:5984/_membership
{"all_nodes":["couchdb@couchdb-5"],"cluster_nodes":["couchdb@couchdb-5"]}
root@dbef6f82ce5f:/# curl http://10.0.52.4:5984/_membership
{"all_nodes":["couchdb@couchdb-1"],"cluster_nodes":["couchdb@couchdb-1"]}
root@dbef6f82ce5f:/# curl http://10.0.52.5:5984/_membership
{"all_nodes":["couchdb@couchdb-2"],"cluster_nodes":["couchdb@couchdb-2"]}
root@dbef6f82ce5f:/# curl http://10.0.52.6:5984/_membership
{"all_nodes":["couchdb@couchdb-3"],"cluster_nodes":["couchdb@couchdb-3"]}
root@dbef6f82ce5f:/# curl http://10.0.52.7:5984/_membership
{"all_nodes":["couchdb@couchdb-4"],"cluster_nodes":["couchdb@couchdb-4"]}
```
Now we can join cluster nodes into cluster using commands
```
curl -X PUT "http://localhost:5986/_nodes/couchdb@couchdb-1/10.0.52.4" -d {}
curl -X PUT "http://localhost:5986/_nodes/couchdb@couchdb-2/10.0.52.5" -d {}
curl -X PUT "http://localhost:5986/_nodes/couchdb@couchdb-3/10.0.52.6" -d {}
curl -X PUT "http://localhost:5986/_nodes/couchdb@couchdb-4/10.0.52.7" -d {}
curl -X PUT "http://localhost:5986/_nodes/couchdb@couchdb-5/10.0.52.3" -d {}
```
Here I suggest extended command join syntax to use `runtime` containers IP address.
If couchdb node is restarted, then
1. node again resolve `${SEED_DNS_NAME}` and gets current couchdb nodes IP addresses;
1. request `/_node/_local/_system` resource from each IP and gets couchdb node
name behind each IP
1. update own map of couchdb nodes and their IP addresses
## Additional context
This feature may be used in `docker swarm` and `kubernetes` clouds.
In kubernetes need use statefulset + service like
```yaml
# file contains database headless service
# creates kubernetes dns records for database daemons
# required for database nodes discovery
apiVersion: v1
kind: Service
metadata:
name: db
spec:
type: ClusterIP
clusterIP: None
publishNotReadyAddresses: true
selector:
app: db
```
Kubernetes service yaml file must contain `publishNotReadyAddresses: true`
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services