> ## Documentation Index
> Fetch the complete documentation index at: https://docs.getcollate.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Run a Custom Connector Without Building an Image

> Run a custom connector on the published ingestion image by mounting its code into the ingestion pods on Argo Workflows or into the Docker Compose ingestion container.

# Run a Custom Connector Without Building an Image

A [custom connector](https://docs.getcollate.io/ai-2-0/connectors/custom-connectors.md) is a Python class that the ingestion process imports
by name. Instead of building a new ingestion image that contains your code, keep the published ingestion image and
mount your connector code into it:

* **Kubernetes with Argo Workflows**: store the code in a ConfigMap. Collate adds it to every ingestion pod it runs.
* **Docker Compose**: mount a local directory into the `ingestion` (Airflow) container.

In both cases, changes to the code are used by the next pipeline run, with no image rebuild and no redeploy.

## How It Works

The ingestion framework imports the class set in **Source Python Class Name** (`sourcePythonClass`) with a
regular Python import. Any module on the Python path of the ingestion process can be imported, so two settings
are enough:

* A volume that mounts your connector code into the ingestion container.
* A `PYTHONPATH` environment variable that points at the mounted directory.

> [!NOTE]
>
> The mount only adds your code. If the connector needs a Python library that isn't in the ingestion image, install
> it in the image, for example with a [custom ingestion image](https://docs.getcollate.io/ai-2-0/connectors/custom-connectors.md).

## Kubernetes with Argo Workflows

This applies to Collate deployments that you manage with Helm on Kubernetes, where ingestion runs on Argo
Workflows. For each pipeline, Collate creates an Argo workflow. You give Collate two YAML files that it merges into
every workflow it creates:

* A **workflow spec** file that adds a volume with your connector code.
* A **container spec** file that mounts the volume in the ingestion container and sets `PYTHONPATH`.

Lists are merged, not replaced, so the environment variables and mounts that Collate sets stay in place.

**1. Store the Connector Code in a ConfigMap**

Create a ConfigMap with your connector modules in the namespace where Argo runs the ingestion workflows, which is
the `ARGO_NAMESPACE` of your deployment (`argo` by default):

```bash theme={null}
kubectl -n argo create configmap custom-connectors --from-file=connectors/
```

Each file in `connectors/` becomes a module at the top level of the mount, for example `my_database.py` defines
the `my_database` module. A ConfigMap holds the files of a single directory and up to 1 MiB of data. For packages
with subdirectories or larger code, use another volume type in the next step, such as a PersistentVolumeClaim.

To try this out, use the [Custom Database connector example](https://github.com/open-metadata/OpenMetadata/blob/main/ingestion/tests/integration/custom_connectors/custom_database.py),
a single self-contained file.

**2. Create the Workflow and Container Spec Files**

Create a `workflow-spec.yaml` file that adds the ConfigMap as a volume:

```yaml theme={null}
volumes:
  - name: custom-connectors
    configMap:
      name: custom-connectors
      optional: true
```

Create a `container-spec.yaml` file that mounts the volume and puts it on the Python path:

```yaml theme={null}
env:
  - name: PYTHONPATH
    value: /opt/custom_connectors
volumeMounts:
  - name: custom-connectors
    mountPath: /opt/custom_connectors
    readOnly: true
```

Collate adds these settings to every ingestion workflow, not only to the ones for your custom connector.
`optional: true` keeps the other pipelines running if the `custom-connectors` ConfigMap doesn't exist. Without
it, every ingestion pod waits for the missing ConfigMap and never starts.

Store both files in a ConfigMap in the namespace where Collate runs:

```bash theme={null}
kubectl -n <collate-namespace> create configmap argo-ingestion-overlays \
  --from-file=workflow-spec.yaml --from-file=container-spec.yaml
```

**3. Point Collate at the Spec Files**

Add the following to your Helm values. It mounts the files in the Collate pods and sets the
`ARGO_INGESTION_WORKFLOW_SPEC_FILE_PATH` and `ARGO_INGESTION_CONTAINER_SPEC_FILE_PATH` environment variables:

```yaml theme={null}
extraEnvs:
  - name: ARGO_INGESTION_WORKFLOW_SPEC_FILE_PATH
    value: /opt/argo-overlays/workflow-spec.yaml
  - name: ARGO_INGESTION_CONTAINER_SPEC_FILE_PATH
    value: /opt/argo-overlays/container-spec.yaml
extraVolumes:
  - name: argo-overlays
    configMap:
      name: argo-ingestion-overlays
extraVolumeMounts:
  - name: argo-overlays
    mountPath: /opt/argo-overlays
    readOnly: true
```

The chart applies these values to the Collate server, to the database migrations container, and to the
scheduled deploy and reindex jobs. All of them read the files, so set the environment variables and the mount
together. If a process has the environment variables but not the files, it fails with
`Failed to load ingestion workflow spec config file`.

Then upgrade the release:

```bash theme={null}
helm upgrade <release> <chart> -n <collate-namespace> -f values.yaml
```

For the other Helm values, see [Kubernetes Helm Values](https://docs.getcollate.io/ai-2-0/how-to-guides/deployment/byoc/kubernetes/helm-values.md).

**4. Redeploy Existing Pipelines**

Collate builds the Argo workflow of a pipeline when it deploys the pipeline. Pipelines deployed before you added
the spec files don't have the mount until you redeploy them. New pipelines get it when you create them.

### Update the Connector Code

Replace the ConfigMap content:

```bash theme={null}
kubectl -n argo create configmap custom-connectors --from-file=connectors/ \
  --dry-run=client -o yaml | kubectl apply -f -
```

Each run starts a new pod that mounts the current ConfigMap, so the next run uses the new code. You don't need to
restart Collate or redeploy the pipeline.

If you change the spec files themselves, restart the Collate server so it reads them again, then redeploy the
pipelines.

## Docker Compose

This applies to Docker Compose deployments where ingestion runs in the `ingestion` (Airflow) container. Airflow
passes the container environment to every task, so pipelines triggered from the UI can import the connector.

**1. Place the Connector Code in a Directory**

Put your connector modules in a directory next to your `docker-compose.yml`, for example `connectors/`:

```
.
├── docker-compose.yml
├── docker-compose.override.yml
└── connectors/
    └── my_database.py        # defines class MyDatabaseSource(Source)
```

To organize the code as a package, add a subdirectory with an `__init__.py` file, for example
`connectors/my_package/__init__.py`.

**2. Mount the Directory in the Ingestion Container**

Create a `docker-compose.override.yml` file next to `docker-compose.yml`. Docker Compose merges it with the main
file automatically:

```yaml theme={null}
services:
  ingestion:
    environment:
      PYTHONPATH: /opt/airflow/custom_connectors
    volumes:
      - ./connectors:/opt/airflow/custom_connectors:ro
```

Then start the stack, or recreate the `ingestion` container if it's already running:

```bash theme={null}
docker compose up -d
```

**3. Verify the Module Can Be Imported**

Check that Python inside the container imports the module from the mounted directory:

```bash theme={null}
docker exec openmetadata_ingestion python -c "import my_database; print(my_database.__file__)"
```

The output should be `/opt/airflow/custom_connectors/my_database.py`.

### Update the Connector Code

Each pipeline run imports the connector again, so changes to files in `connectors/` are used by the next run.
You don't need to restart the container or redeploy the pipeline.

## Configure the Service

Create a Custom Database service that points to your connector class:

1. In the left navigation, click **Connections**.

2. Click **Add New Service**.

3. From the service type dropdown, select **Database Services**, then click the **Custom Database** connector card.

   ![Custom Database card in the list of database services](https://mintcdn.com/collatedocs/Atox4GALi1wJZ0Yw/public/images/ai-2.0/connectors/custom-connectors-volume-mount/select-custom-database.png?fit=max\&auto=format\&n=Atox4GALi1wJZ0Yw\&q=85\&s=60607db9c15c5f9fd4b5dd084a88a626)

4. Enter a unique **Service Name**.

5. Select an **Ingestion Runner**.

6. In **Source Python Class Name**, enter the module and class name relative to the mounted directory:

   * `my_database.MyDatabaseSource` for `my_database.py`.
   * `my_package.my_database.MyDatabaseSource` for `my_package/my_database.py`.

   ![Source Python Class Name field in Scope & Options on the Connect step](https://mintcdn.com/collatedocs/Atox4GALi1wJZ0Yw/public/images/ai-2.0/connectors/custom-connectors-volume-mount/source-python-class-name.png?fit=max\&auto=format\&n=Atox4GALi1wJZ0Yw\&q=85\&s=0425f05760de6e7f5243d5689a7213f8)

7. Configure **What to Ingest**, then click **Create & Deploy** to run it.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.