Connect ArangoDB cluster hosted on Kubernetes pods via Python

307 views Asked by At

I have a 3 node system, on which I have hosted a basic ArangoDB cluster having 3 dbservers. I am using Python-arango library, which says that to connect to the clusters, we need to supply the list of IPs with the port 8529 to ArangoClient class.My Python code is running in a different pod.

Using Arangosh, I can access the coordinator pods using localhost:8529 configuration. However, on Arangosh, I can only access one coordinator pod at once. Since the Arango arrangement is a cluster, I would want to connect to all three coordinator pods at once in a roundrobin manner. Now as per the Kubernetes documentation in case of MongoDB, I can supply the list of the <pod_name.service_name> to the MongoClient and it would get connected. I am trying something similar with the Arango coordinator pods, but that does not seem to work. The examples in Arango documentation only point to writing 'localhost-1','localhost-2', etc.

To summarize, the issue in hand is that I do not know how to identify the IP of the Arango coordinator pods. I tried using the internal IPs of the coordinators, I tried using the http://pod_name.8529 and I have tried using the end point of the coordinator that shows in the Web UI (which begins with ssl, but I had replaced ssl with http) and yet got no success.

Would be grateful for any help in this context. Please let me know if some additional information is needed. Am stuck with this problem since a week now.

2

There are 2 answers

1
Harsh Manvar On

if you follow this : https://www.arangodb.com/2018/12/deploying-arangodb-3-4-on-kubernetes/

there is YAML config files it's creating multiple PODs. How your application should be connecting with ArragoDB is using the Kubernetes service.

So your application will be connecting to Kubernetes service and by default kubernets service manage the RoundRobin load balancing.

in example you can see it's creating three services

my-arangodb-cluster          ClusterIP      10.11.247.191   <none>           8529/TCP         46m
my-arangodb-cluster-ea       LoadBalancer   10.11.241.253   35.239.220.180   8529:31194/TCP   46m
my-arangodb-cluster-int      ClusterIP      None            <none>           8529/TCP         46m

service my-arangodb-cluster-ea publicly open. While service my-arangodb-cluster can be accessed internally using the application.

Your flow will be something like

Application > Arango service (Round robin) > Arango Pods   
0
Евгений Рябов On

I guess you either can connect to them using LoadBalancer as mentioned above, in that case k8s will balance your requests between coordinator pods, or you can explicitly create services for each coordinator and use their IP addresses in your python client configuration in the way you want