|
| 1 | +# Configuring your driver for ArangoDB access |
| 2 | + |
| 3 | +In this chapter you'll learn how to configure a driver for accessing |
| 4 | +an ArangoDB deployment in Kubernetes. |
| 5 | + |
| 6 | +The exact methods to configure a driver are specific to that driver. |
| 7 | + |
| 8 | +## Database endpoint(s) |
| 9 | + |
| 10 | +The endpoint(s) (or URLs) to communicate with is the most important |
| 11 | +parameter your need to configure in your driver. |
| 12 | + |
| 13 | +Finding the right endpoints depend on wether your client application is running in |
| 14 | +the same Kubernetes cluster as the ArangoDB deployment or not. |
| 15 | + |
| 16 | +### Client application in same Kubernetes cluster |
| 17 | + |
| 18 | +If your client application is running in the same Kubernetes cluster as |
| 19 | +the ArangoDB deployment, you should configure your driver to use the |
| 20 | +following endpoint: |
| 21 | + |
| 22 | +```text |
| 23 | +https://<deployment-name>.<namespace>.svc:8529 |
| 24 | +``` |
| 25 | + |
| 26 | +Only if your deployment has set `spec.tls.caSecretName` to `None`, should |
| 27 | +you use `http` instead of `https`. |
| 28 | + |
| 29 | +### Client application outside Kubernetes cluster |
| 30 | + |
| 31 | +If your client application is running outside the Kubernetes cluster in which |
| 32 | +the ArangoDB deployment is running, your driver endpoint depends on the |
| 33 | +external-access configuration of your ArangoDB deployment. |
| 34 | + |
| 35 | +If the external-access of the ArangoDB deployment is of type `LoadBalancer`, |
| 36 | +then use the IP address of that `LoadBalancer` like this: |
| 37 | + |
| 38 | +```text |
| 39 | +https://<load-balancer-ip>:8529 |
| 40 | +``` |
| 41 | + |
| 42 | +If the external-access of the ArangoDB deployment is of type `NodePort`, |
| 43 | +then use the IP address(es) of the `Nodes` of the Kubernetes cluster, |
| 44 | +combined with the `NodePort` that is used by the external-access service. |
| 45 | + |
| 46 | +For example: |
| 47 | + |
| 48 | +```text |
| 49 | +https://<kubernetes-node-1-ip>:30123 |
| 50 | +``` |
| 51 | + |
| 52 | +You can find the type of external-access by inspecting the external-access `Service`. |
| 53 | +To do so, run the following command: |
| 54 | + |
| 55 | +```bash |
| 56 | +kubectl get service -n <namespace-of-deployment> <deployment-name>-ea |
| 57 | +``` |
| 58 | + |
| 59 | +The output looks like this: |
| 60 | + |
| 61 | +```bash |
| 62 | +NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR |
| 63 | +example-simple-cluster-ea LoadBalancer 10.106.175.38 192.168.10.208 8529:31890/TCP 1s app=arangodb,arango_deployment=example-simple-cluster,role=coordinator |
| 64 | +``` |
| 65 | + |
| 66 | +In this case the external-access is of type `LoadBalancer` with a load-balancer IP address |
| 67 | +of `192.168.10.208`. |
| 68 | +This results in an endpoint of `https://192.168.10.208:8529`. |
| 69 | + |
| 70 | +## TLS settings |
| 71 | + |
| 72 | +As mentioned before the ArangoDB deployment managed by the ArangoDB operator |
| 73 | +will use a secure (TLS) connection unless you set `spec.tls.caSecretName` to `None` |
| 74 | +in your `ArangoDeployment`. |
| 75 | + |
| 76 | +When using a secure connection, you can choose to verify the server certificates |
| 77 | +provides by the ArangoDB servers or not. |
| 78 | + |
| 79 | +If you want to verify these certificates, configure your driver with the CA certificate |
| 80 | +found in a Kubernetes `Secret` found in the same namespace as the `ArangoDeployment`. |
| 81 | + |
| 82 | +The name of this `Secret` is stored in the `spec.tls.caSecretName` setting of |
| 83 | +the `ArangoDeployment`. If you don't set this setting explicitly, it will be |
| 84 | +set automatically. |
| 85 | + |
| 86 | +Then fetch the CA secret using the following command (or use a Kubernetes client library to fetch it): |
| 87 | + |
| 88 | +```bash |
| 89 | +kubectl get secret -n <namespace> <secret-name> --template='{{index .data "ca.crt"}}' | base64 -D > ca.crt |
| 90 | +``` |
| 91 | + |
| 92 | +This results in a file called `ca.crt` containing a PEM encoded, x509 CA certificate. |
| 93 | + |
| 94 | +## Query requests |
| 95 | + |
| 96 | +For most client requests made by a driver, it does not matter if there is any kind |
| 97 | +of load-balancer between your client application and the ArangoDB deployment. |
| 98 | + |
| 99 | +{% hint 'info' %} |
| 100 | +Note that even a simple `Service` of type `ClusterIP` already behaves as a load-balancer. |
| 101 | +{% endhint %} |
| 102 | + |
| 103 | +The exception to this is cursor related requests made to an ArangoDB `Cluster` deployment. |
| 104 | +The coordinator that handles an initial query request (that results in a `Cursor`) |
| 105 | +will save some in-memory state in that coordinator, if the result of the query |
| 106 | +is too big to be transfer back in the response of the initial request. |
| 107 | + |
| 108 | +Follow-up requests have to be made to fetch the remaining data. |
| 109 | +These follow-up requests must be handled by the same coordinator to which the initial |
| 110 | +request was made. |
| 111 | + |
| 112 | +As soon as there is a load-balancer between your client application and the ArangoDB cluster, |
| 113 | +it is uncertain which coordinator will actually handle the follow-up request. |
| 114 | + |
| 115 | +To resolve this uncertainty, make sure to run your client application in the same |
| 116 | +Kubernetes cluster and synchronize your endpoints before making the |
| 117 | +initial query request. |
| 118 | +This will result in the use (by the driver) of internal DNS names of all coordinators. |
| 119 | +A follow-up request can then be sent to exactly the same coordinator. |
| 120 | + |
| 121 | +If your client application is running outside the Kubernetes cluster this is much harder |
| 122 | +to solve. |
| 123 | +The easiest way to work around it, is by making sure that the query results are small |
| 124 | +enough. |
| 125 | +When that is not feasible, it is also possible to resolve this |
| 126 | +when the internal DNS names of your Kubernetes cluster are exposed to your client application |
| 127 | +and the resuling IP addresses are routeable from your client application. |
| 128 | +To expose internal DNS names of your Kubernetes cluster, your can use [CoreDNS](https://coredns.io). |
0 commit comments