Skip to content

About

Helm chart for Postgres connector

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

postgres-connector

Helm chart that deploys the Timescale Postgres connector — a stateless service that replicates Postgres into TimescaleDB. Runs on any Kubernetes flavor, including OpenShift.

Install

Pick a release from the Releases page and install the packaged chart directly:

helm install postgres-connector \
  https://github.com/timescale/postgres-connector-chart/releases/download/v0.1.0/postgres-connector-0.1.0.tgz \
  -f my-values.yaml

To always install the latest release, resolve the tag at install time (the chart .tgz is a versioned asset, so there is no fixed "latest" URL):

REPO=timescale/postgres-connector-chart
TAG=$(gh release view --repo "$REPO" --json tagName -q .tagName)
VERSION=${TAG#v}
helm install postgres-connector \
  "https://github.com/$REPO/releases/download/$TAG/postgres-connector-$VERSION.tgz" \
  -f my-values.yaml

Or clone and install from source (use this to track main ahead of a release):

helm install postgres-connector . -f my-values.yaml

Required values

config:
  version: 1
  connectors:
    - id: high-volume-metrics
      source:
        database_url: $SOURCE_URL1
        publications:
          - metrics_pub
      target:
        database_url: $TARGET_URL
        tables:
          - source:
              schema_name: public
              table_name: metrics1
            hypertable_config:
              primary_dimension:
                column_name: time
                range:
                  partition_interval: 1 day
    - id: low-volume-metrics
      source:
        database_url: $SOURCE_URL2
        publications:
          - metrics_pub2
      target:
        database_url: $TARGET_URL
        tables:
          - source:
              schema_name: public
              table_name: metrics2

env:
  - name: SOURCE_URL1
    valueFrom:
      secretKeyRef: { name: db-creds, key: source-url-1 }
  - name: SOURCE_URL2
    valueFrom:
      secretKeyRef: { name: db-creds, key: source-url-2 }
  - name: TARGET_URL
    valueFrom:
      secretKeyRef: { name: db-creds, key: target-url }

Use $VAR expansion in database_url fields for credentials and inject the variables via env.

How it works

The chart runs the live-sync CLI of the image. For each connector in config.connectors:

  • A Deployment with one pod runs live-sync run. Kubernetes expands a $VAR database_url from env. The chart stores a literal database_url and an SSH private key in its own Secret.
  • After each helm install and helm upgrade, a hook Job runs live-sync refresh-publication and applies target.tables. A change to target.tables does not restart the pod. When the refresh fails, for example for an entry that matches no table in the publication, the release fails, and the Job pod shows the error.
  • A change to a field that the run pod uses restarts the pod of that connector only.

The containers get the connection strings in environment variables, not in the process arguments.

Database credentials Secret

The chart does not manage database credentials. Create the Secret referenced by env separately so the connection strings stay out of your values file (and out of source control). Minimal example:

# db-creds.yaml — apply with: kubectl apply -f db-creds.yaml -n <namespace>
apiVersion: v1
kind: Secret
metadata:
  name: db-creds
type: Opaque
stringData:
  source-url-1: "postgres://USER:PASS@SOURCE_HOST1:5432/DBNAME?sslmode=require"
  source-url-2: "postgres://USER:PASS@SOURCE_HOST2:5432/DBNAME?sslmode=require"
  target-url: "postgres://USER:PASS@TARGET_HOST:5432/DBNAME?sslmode=require"

stringData lets you paste plain connection strings; Kubernetes base64-encodes them on apply. The Secret must live in the same namespace as the release.

Multiple connectors

The connectors list accepts more than one connector, as in the example above. Each entry is fully isolated: own replication slot, own publications, own source and target.

Each connector runs in its own pod, so a restart or crash of one connector does not stop the others. Each pod gets the resources of the values file, so the total requests grow with the number of connectors.

Config schema

Top-level:

Field Type Required Description
version int yes Config schema version. Must be 1.
connectors list yes One or more connector definitions. At least one is required.

connectors[]

Field Type Required Description
id string yes Unique connector identifier. Either a UUID or a string of alphanumerics, underscores, and hyphens. Must be unique across the file.
drop bool no When true, the next helm upgrade stops the connector and drops its replication slots, origins, and catalog rows. You can also remove the entry (see Removing a connector).
config object no Replication tuning (see below). Defaults applied when omitted.
source object yes Source Postgres configuration.
target object yes Target TimescaleDB configuration.

connectors[].config (replication)

Field Type Default Description
enabled bool true Whether replication is active for this connector. When false, the Deployment of the connector has 0 replicas, and no refresh runs.
table_sync_workers int 4 Parallel workers used during the initial table sync. Must be 1–100.
initial_data_copy bool true Whether to perform the initial snapshot copy before streaming changes. Set to false to skip the snapshot and stream from the current LSN.

connectors[].source

Field Type Required Description
database_url string yes Postgres connection string for the source. Supports $VAR expansion from environment.
publications list of strings yes Existing Postgres logical-replication publications to subscribe to. At least one is required.
ssh_config object no SSH tunnel for reaching the source (see below).

connectors[].source.ssh_config

Field Type Required Description
host string yes SSH bastion host.
port int no (default 22) SSH port (1–65535).
user string yes SSH user.
password string no SSH password (use private key auth where possible).
private_key string yes Base64-encoded private key, or @/path/to/keyfile for a key file in the container.
host_key string no Expected host public key for verification.

ssh_config needs a literal database_url, because the chart adds the tunnel parameters to the connection string. A $VAR value fails the render.

connectors[].target

Field Type Required Description
database_url string yes TimescaleDB/Postgres connection string for the target. Supports $VAR expansion.
skip_replica_identity_index bool no Global default for the per-table setting below.
tables list no Per-table source-to-target mapping and hypertable configuration. It is not a filter: every table of the publications syncs (see Tables).

Tables

Every table of the publications syncs. An entry of target.tables sets the target name and settings of a table. A table without an entry syncs to the same name.

To stop the sync of a table, remove it from the publication on the source. Removal of its entry from target.tables does not stop its sync.

connectors[].target.tables[]

Field Type Required Description
source object yes Source table: { schema_name, table_name }.
target object no Target table: { schema_name, table_name }. Defaults to the source pair when omitted.
hypertable_config object no If set, creates a hypertable on the target with the given dimensions.
skip_replica_identity_index bool no When true, skip creating the replica identity index on the target. Falls back to the target-level default.

connectors[].target.tables[].hypertable_config

Field Type Required Description
primary_dimension object yes Primary partitioning dimension. Must be a range dimension.
secondary_dimensions list no Additional dimensions, each either range or hash.

Each dimension has:

Field Type Required Description
column_name string yes Column used for partitioning.
range.partition_interval string one of Time/interval per chunk, e.g. 1 day.
hash.num_partitions int one of Number of hash partitions. Must be ≥ 2. Not allowed on primary_dimension.

Exactly one of range or hash must be set per dimension.

Updating the config

Edit config: in your values file and run helm upgrade. The upgrade waits for the table-list refresh of each running connector (see How it works).

Removing a connector

Remove the entry from config.connectors and run helm upgrade. After Helm deletes the connector pod, a hook Job drops the replication slots on the source, and the replication origins and catalog rows on the target. The synced tables and their data stay on the target. A connector with a new id is a new connector, so a change of id drops the old connector and copies the tables again.

The chart finds a removed connector with lookup, so this works only when Helm can read the cluster. helm template and GitOps tools such as Argo CD do not drop a removed connector. With these tools, set drop: true on the entry, sync, and then remove the entry.

When the drop Job fails, the upgrade fails, and the Job pod shows the error. To try again, add the entry back with drop: true and run helm upgrade.

Uninstall

helm uninstall drops every connector of the release: its replication slots on the source, and its replication origins and catalog rows on the target. The synced tables and their data stay on the target. The drop runs in a Job after Helm deletes the connector pods, because a running pod holds its replication slot.

To delete the release and keep the connectors for a later install, run helm uninstall --no-hooks. The replication slots then stay on the source and keep WAL until a connector uses them again.

Upgrade from a chart that runs connector-src-postgres

Older versions of the chart run all connectors in one connector-src-postgres pod. The subscription name is the connector id in both versions, so the new pods continue from the same replication slots, and no data is copied again.

These changes are breaking:

  • target.tables is not a filter. The old chart synced only the tables in the list, and no tables for an empty list. Now every table of the publications syncs. See Tables.
  • helm uninstall drops the connectors. See Uninstall.
  • The Service has no grpc port. The chart ignores service.grpcPort.
  • Each connector gets its own pod, with the resources of the values file.

Before the upgrade, make each publication contain only the tables of its target.tables list. For example:

ALTER PUBLICATION my_pub SET TABLE public.metrics, public.events;

If you do not, the refresh after the upgrade starts the initial copy of each published table that is not in the list. A connector without a list syncs all tables of its publications.

The upgrade then does these steps:

  1. Helm creates one Deployment for each connector, and updates the Secret and the Service.
  2. Helm deletes the old Deployment. Each new pod waits until the old pod releases the replication slot, and then continues from it.
  3. The refresh Job of each running connector applies target.tables.

Monitoring progress

The connector exposes its internal state in the target database under the _ts_live_sync schema and uses logical replication slots named live_sync_* on the source. Set SOURCE and TARGET to the same connection strings used in your config.

Table sync status

psql "$TARGET" -c "
  SELECT state, last_error, count(*)
  FROM _ts_live_sync.subscription_rel
  GROUP BY 1, 2 ORDER BY 1, 2;
"

Tables with errors appear as separate rows grouped by last_error.

State Meaning
i Initial state, table data sync not started
d Initial table data sync is in progress
f Initial table data sync completed, catching up with incremental changes
s Synchronized, waiting for the main apply worker to take over
r Table is ready, applying changes in real-time

COPY progress during initial sync

The number of rows returned should usually match table_sync_workers from the connector config.

psql "$SOURCE" -c "SELECT * FROM pg_stat_progress_copy;"

Replication lag

On the source, via pg_replication_slots:

psql "$SOURCE" -c "
  SELECT slot_name,
    pg_size_pretty(pg_current_wal_flush_lsn() - confirmed_flush_lsn) AS lag
  FROM pg_replication_slots
  WHERE slot_name LIKE 'live_sync_%' AND slot_type = 'logical';
"

On the target, via _ts_live_sync.subscription (also surfaces last_error):

psql "$TARGET" -c "
  SELECT
    pg_size_pretty(source_flush_lsn - last_replicated_lsn) AS lag_bytes,
    (metrics_updated_at - last_replicated_txn_time) AS lag_duration,
    *
  FROM _ts_live_sync.subscription;
"

Metrics and dashboards

  • Prometheus: a ServiceMonitor is created by default (requires the Prometheus Operator). Disable with serviceMonitor.enabled: false.
  • Grafana: a ConfigMap labeled grafana_dashboard: "1" is created for the kube-prometheus-stack Grafana sidecar. Disable with grafana.dashboard.enabled: false.

Telemetry

The connector sends usage telemetry to telemetry.timescale.com: an event for each command, with the connector ID, the build, and source and target database information. To disable it, set this value:

telemetry:
  enabled: false

Vertical Pod Autoscaler

The chart can create a VerticalPodAutoscaler for the Deployment of each connector. The cluster must have VPA installed. These keys are not in values.yaml:

vpa:
  enabled: true
  updateMode: "Off"        # default; also "Initial", "Recreate", or "InPlaceOrRecreate"
  minAllowed: { cpu: 100m, memory: 256Mi }   # optional
  maxAllowed: { cpu: "2", memory: 4Gi }      # optional
  • With "Off", VPA only writes recommendations. To see them, run kubectl describe vpa <connector>. The pods keep resources.
  • With "Recreate", VPA evicts the pod to change its resources. The connector stops until the new pod starts, and then it continues from its slot.
  • With podDisruptionBudget.enabled, the PDB can block these evictions.
  • VPA keeps the ratio between requests and limits of resources.
  • The refresh and drop Jobs always use resources.

OpenShift

Works under the default restricted SCC without modification — the chart sets no runAsUser and ships only non-root, capability-dropped containers with a read-only root filesystem.

Values

See values.yaml. The connector has no gRPC endpoint any more, so the chart does not use service.grpcPort.

Releases

Releases are automated by release-please. Use Conventional Commits — feat: bumps the minor version, fix: bumps the patch, feat!: / BREAKING CHANGE: bumps the major. release-please opens a release PR on every push to main; merging it creates a tag, a GitHub Release, and bumps version in Chart.yaml.

About

Helm chart for Postgres connector

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages