The Mode platform provides users with a hub for performing ad hoc analysis, self-service reporting and visualization, as well as sharing analysis with collaborators. In addition to providing SQL access to your data, you can also use Python notebooks and popular data analysis libraries for additional kinds of analysis. One of the key features of Mode is its ability to query a wide array of backends – and now that includes Hydrolix.
Figure 1. Using the Mode SQL interface to query Hydrolix data.
Hydrolix uses the Clickhouse API to provide SQL access to data and the Clickhouse JDBC driver is supported by Mode. Now Mode users can continue to use it as a collaboration platform while gaining access to their data stored in Hydrolix.
The first step in using Mode with Hydrolix is planning how you will access the cluster from Mode. We have two options:
- exposing the Hydrolix cluster to the internet and defining a list of allowed IP addresses or
- using the Mode Bridge.
If you want to expose the Hydrolix cluster to the internet, you will need to edit the hydrolixcluster.yaml file. In the spec section, add to the spec section, the following:
1 2 3 4 | Spec: … ip_allowlist: – source: 0.0.0.0/0 |
The specification source: 0.0.0.0/0 in the ip_allowlist will allow connections from all IP addresses.
The Mode Bridge is software provided by Mode that runs in your Kubernetes cluster where it has local network access to the query heads of the Hydrolix cluster.
If you choose to use the Mode Bridge, you’ll create a bridge connection in Mode and then configure a Kubernetes deployment that uses an image provided by Mode.
To create a bridge connection, authenticate to Mode and open https://app.mode.com/settings/data_source_bridges. Specify a name for the bridge connection and click the Create Bridge button. This will generate values for the MODE_ACCESS_TOKEN, MODE_TOKEN_SECRET, and MODE_SERVER. You will use these to define environment variables in the Kubernetes deployment. Figure 2 shows an example of creating a bridge connector and the generating values for the three environment variables.
Figure 2. Creating a MODE_ACCESS_TOKEN and MODE_TOKEN_SECRET at app.mode.com/settings/access_tokens.
Once you have values for the three container environment variables, you can configure the deployment using the deployment template in Listing 1. The template uses a single replica but two can be used for high availability. The specified CPU, ephemeral storage, and memory may need to be increased based on your workload.
Listing 1. Mode/Hydrolix Deployment Template
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | piVersion: apps/v1 kind: Deployment metadata: annotations: name: mode–bridge namespace: <<Hydrolix cluster namespace>> spec: replicas: 1 selector: matchLabels: app: mode–bridge template: metadata: annotations: labels: app: mode–bridge spec: containers: – env: – name: MODE_ACCESS_TOKEN value: <<access token value>> – name: MODE_TOKEN_SECRET value: <<token secret value>> – name: MODE_SERVER value: <<Mode server URL including port>> image: modeanalytics/bridge–client:latest name: mode–bridge resources: limits: ephemeral–storage: 256Mi memory: 256Mi requests: cpu: 250m ephemeral–storage: 256Mi memory: 256Mi |
You should edit the template to change <
Assuming you have saved the template yaml to hydrolix-mode-bridge.yaml and edited the namespace and environment variables, then deploy the bridge using:
1 | kubectl apply –f hydrolix–mode–bridge.yaml |
You can verify the Mode Bridge deployment by executing the following:
1 | kubectl get –f modeBridge.yaml |
The results should look something like:
1 2 | NAME READY UP–TO–DATE AVAILABLE AGE mode–bridge 1/1 1 1 5m31s |
Next, within Mode, you can set up the bridge connection and connect to the database. From the Mode portal, connect to a database here and specify a Clickhouse database as shown in Figure 3.
Figure 3. Choose Clickhouse as the type of database to connect to.
When prompted to enter credentials, click on the link to use the Bridge connector, as shown in Figure 4.
Figure 4. Click the bridge connector link to specify a bridge to use.
A list of bridge connections will be displayed. Choose the appropriate bridge for your database. Once you have selected a bridge connection, you can specify your database connection information using the form shown in Figure 5.
The display name is a human readable reference to the database and the optional description provides additional information about the database. The host should be a DNS name of the Hydrolix cluster. The port should be set to 8088, which is the default port of the Hydrolix internal traefik service. The database name is the name of the Hydrolix project you want to work with. The default workspace access is View, which allows all Workspace members to view content accessible to this connection.
Figure 5. Mode dialog to specify database connection information.
Once the database connection is established, you will be able to query the Hydrolix database from Mode.