Skip to main content

Run a Custom Connector Without Building an Image

A custom connector 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.
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.

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):
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, 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:
Create a container-spec.yaml file that mounts the volume and puts it on the Python path:
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:
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:
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:
For the other Helm values, see Kubernetes Helm Values.
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:
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/:
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:
Then start the stack, or recreate the ingestion container if it’s already running:
3

Verify the Module Can Be Imported

Check that Python inside the container imports the module from the mounted directory:
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
  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
  7. Configure What to Ingest, then click Create & Deploy to run it.