# Connecting Apache Druid clusters

> Connect Apache Superset to Apache Druid on the Stackable Data Platform using the DruidConnection CustomResource.

The operator can automatically connect Superset clusters that it manages to Apache Druid clusters managed by the [Stackable operator for Apache Druid](https://docs.stackable.tech/home/stable/druid/index.md).

To do so, create a _DruidConnection_ resource:

```yaml
apiVersion: superset.stackable.tech/v1alpha1
kind: DruidConnection
metadata:
  name: superset-druid-connection
spec:
  superset:  (1)
    name: superset
    namespace: default
  druid:  (2)
    name: druid
    namespace: default
```

(1) The `name` and `namespace` in `spec.superset` refer to the Superset cluster that you want to connect. Following our example above, the name is `superset`.
(2) In `spec.druid` you specify the `name` and `namespace` of your Druid cluster. Following our example above, the name is `druid`.

The `namespace` part is optional in both cases; if it is omitted it will default to the namespace of the DruidConnection.

Once Superset startup is complete and the database is initialized, the Superset operator will create a [Job](https://kubernetes.io/docs/concepts/workloads/controllers/job/) that will connect to the Superset cluster to run an import command to add the Druid cluster as a datasource.

> **Important:** The Job is connecting to the Superset Pods. If you are restricting network traffic in your Kubernetes cluster, make sure to configure a [NetworkPolicy](https://kubernetes.io/docs/concepts/services-networking/network-policies/) that allows the Job to connect to Superset.

Once the Job is completed you can see the Druid cluster as a database in the user interface under Data > Databases:

![Superset databases showing the connected Druid cluster](https://docs.stackable.tech/home/stable/superset/_images/superset-databases.png)

## Further reading

Read the CRD reference for the [DruidConnection](https://hub.stackable.tech/crds/superset.stackable.tech/v1alpha1/druidconnection?release=26.11) CustomResource.
