pgvector

by cagriekin

Helm chartv2.8.0App 18Verified publisher

PostgreSQL with the pgvector extension for vector search, plus streaming replication, agent failover (Kubernetes Lease or etcd-quorum DCS), optional PgPool-II, S3 backups, TLS, and metrics

About this chart

PostgreSQL with pgvector

PostgreSQL Helm chart with pgvector extension for vector similarity search, native streaming replication with a lease-based Go failover agent, optional PGPool-II for connection pooling and read/write splitting.

This chart shares all templates with the pg chart via symlinks. The only differences are the default image (pgvector/pgvector) and automatic CREATE EXTENSION IF NOT EXISTS vector on startup.

Features

  • PostgreSQL 18 with pgvector extension for vector similarity search
  • Lease-based HA agent (pg-ha-agent, PID 1 in the postgresql container) for automatic failover, replication management, and primary Service selector updates — no HA sidecars (the repmgrd and service-updater sidecars were removed in 2.0.0; the pgBackRest and metrics-exporter sidecars are unaffected)
  • Stale-primary protection: a crashed primary that restarts after a standby was promoted rejoins as a standby (via pg_rewind) instead of resuming read-write on a divergent timeline
  • Read-only <fullname>-readonly service targeting standby pods for read scaling (HA mode)
  • Optional PGPool-II for connection pooling and read/write splitting
  • Support for existing secrets or auto-generated passwords
  • StatefulSet-based deployment with persistent storage
  • PostgreSQL configuration injection via ConfigMap (postgresql.conf overrides, pg_hba.conf entries)
  • PostStart lifecycle hooks with primary-aware execution in HA setups
  • Pod disruption budgets for safe node drains
  • Configurable update strategy, resource limits, probes, and affinity
  • Prometheus exporters for PostgreSQL and PGPool-II metrics with ServiceMonitor support
  • Automated S3 backups via CronJob with retention management
  • pgBackRest for WAL-based incremental backups and point-in-time recovery

Installation

helm repo add cagriekin https://cagriekin.github.io/charts
helm install my-pgvector cagriekin/pgvector

With Read Replicas

helm install my-pgvector cagriekin/pgvector --set postgresql.replicaCount=3

With PGPool-II Enabled

helm install my-pgvector cagriekin/pgvector \
  --set postgresql.replicaCount=3 \
  --set pgpool.enabled=true

With Existing Secret

kubectl create secret generic pg-secret \
  --from-literal=username=myuser \
  --from-literal=password=mypassword \
  --from-literal=database=mydb \
  --from-literal=repmgr-password=myrepmgrpassword

helm install my-pgvector cagriekin/pgvector \
  --set postgresql.existingSecret.enabled=true \
  --set postgresql.existingSecret.name=pg-secret

Or with custom key names:

kubectl create secret generic pg-secret \
  --from-literal=user=myuser \
  --from-literal=pass=mypassword \
  --from-literal=db=mydb \
  --from-literal=repmgr-pass=myrepmgrpassword

helm install my-pgvector cagriekin/pgvector \
  --set postgresql.existingSecret.enabled=true \
  --set postgresql.existingSecret.name=pg-secret \
  --set postgresql.existingSecret.usernameKey=user \
  --set postgresql.existingSecret.passwordKey=pass \
  --set postgresql.existingSecret.databaseKey=db \
  --set postgresql.existingSecret.repmgrPasswordKey=repmgr-pass

Using pgvector

After installation, the vector extension is automatically created. You can start using vector types immediately:

-- Create a table with vector column
CREATE TABLE items (
  id SERIAL PRIMARY KEY,
  embedding vector(1536)
);

-- Insert vectors
INSERT INTO items (embedding) VALUES ('[1,2,3,...]');

-- Find similar vectors
SELECT * FROM items ORDER BY embedding <-> '[1,2,3,...]' LIMIT 5;

Configuration

Common Parameters

ParameterDescriptionDefault
imagePullSecretsPull secrets applied to every pod template (StatefulSet, pgpool and exporter Deployments, backup and pgBackRest CronJobs)[]
busyboxImage.repositoryImage for the helper init containers (permission fixups, config copy/templating) across the StatefulSet, pgpool, and exporter pods; override for air-gapped/private registriesbusybox
busyboxImage.tagHelper init image tag1.37
busyboxImage.pullPolicyHelper init image pull policyIfNotPresent
busyboxImage.digestOptional digest pin (sha256:...), appended as repository:tag@digest""

Pinning images by digest (#26). Every image block — postgresql.image, ha.image, pgpool.image, pgpool.metrics.image, prometheusExporter.image, busyboxImage, backup.rclone.image, and pgbackrest.cronjob.image — accepts an optional digest (e.g. sha256:…). When set, the image is rendered as repository:tag@digest so a mutable-tag repush cannot silently change what runs. Empty (default) pulls by tag.

PostgreSQL Parameters

ParameterDescriptionDefault
postgresql.image.repositoryPostgreSQL image repositorypgvector/pgvector
postgresql.image.tagPostgreSQL image tag. Must bundle the same PostgreSQL point release as ha.image.tag (#302) — copy-ext's no-clobber copy keeps a drifted image from corrupting the running server, but CREATE EXTENSION vector still needs a matching point release to load safely. Bump only in lockstep with ha.image.0.8.5-pg18-trixie
postgresql.image.pullPolicyImage pull policyIfNotPresent
postgresql.majorVersionPostgreSQL major version in image.tag; builds the extension paths (/usr/lib/postgresql/<major>/lib, /usr/share/postgresql/<major>/extension) when extensions.enabled=true. With ha.enabled the server runs from the HA image and follows ha.image.majorVersion regardless of postgresql.image; the chart fails to render if the two majors differ. Set both to "17" (with a -pg17 repmgr tag) to run PostgreSQL 17 — see Choosing the PostgreSQL major."18"
postgresql.replicaCountNumber of PostgreSQL replicas (total instances = replicaCount + 1); values > 0 require ha.enabled=true1
postgresql.databaseDatabase namepostgres
postgresql.usernameDatabase username (a superuser; the chart's own tooling logs in as it)postgres
postgresql.app.usernameNon-superuser application role, owns postgresql.database except postgres (see the pg chart README, "Application role and connection reserves")app_user
postgresql.resources.requests.cpuCPU request100m
postgresql.resources.requests.memoryMemory request256Mi
postgresql.resources.limits.cpuCPU limit1000m
postgresql.resources.limits.memoryMemory limit1Gi
postgresql.persistence.enabledEnable persistencetrue
postgresql.persistence.sizeStorage size10Gi
postgresql.persistence.emptyDir.sizeLimitsizeLimit for the non-persistent (persistence.enabled=false) PGDATA emptyDir; empty = unbounded""
postgresql.persistence.storageClassStorage class""
postgresql.updateStrategy.typeStatefulSet update strategyRollingUpdate
postgresql.updateStrategy.rollingUpdate.partitionPartition for rolling update0
postgresql.podAnnotationsAnnotations for PostgreSQL pods{}
postgresql.priorityClassNamepriorityClassName for PostgreSQL pods""
postgresql.affinityAffinity rules for PostgreSQL pods{}
postgresql.annotationsAdditional annotations{}
postgresql.podSecurityContextPod-level securityContext for StatefulSet{fsGroup: 103, runAsNonRoot: true, seccompProfile.type: RuntimeDefault}
postgresql.containerSecurityContextContainer-level securityContext for all PostgreSQL containers{runAsUser: 101, runAsGroup: 103, allowPrivilegeEscalation: false, capabilities.drop: [ALL]}

Liveness and Readiness Probes

ParameterDescriptionDefault
postgresql.livenessProbe.enabledEnable liveness probetrue
postgresql.livenessProbe.initialDelaySecondsInitial delay30
postgresql.livenessProbe.periodSecondsCheck interval10
postgresql.livenessProbe.timeoutSecondsTimeout5
postgresql.livenessProbe.failureThresholdFailure threshold10
postgresql.readinessProbe.enabledEnable readiness probetrue
postgresql.readinessProbe.initialDelaySecondsInitial delay5
postgresql.readinessProbe.periodSecondsCheck interval10
postgresql.readinessProbe.timeoutSecondsTimeout5
postgresql.readinessProbe.failureThresholdFailure threshold6
postgresql.startupProbe.enabledEnable startup probe (suspends liveness/readiness until PostgreSQL first accepts connections over loopback TCP — the bootstrap's socket-only transient postmaster no longer counts, #350 — so first-boot recovery and WAL replay cannot be killed by the liveness probe)true
postgresql.startupProbe.periodSecondsCheck interval10
postgresql.startupProbe.timeoutSecondsTimeout5
postgresql.startupProbe.failureThresholdFailure threshold (periodSeconds x this = total startup budget, 1800s; it also bounds a standby's first clone, #288, and in standalone mode the postStart hook's wait for the real server, floor 300s, #370)180

The startup probe, and the readiness probe in standalone mode, ask pg_isready over 127.0.0.1 (#350), the one address the bootstrap's transient postmaster and the stock image's init-time server never open, so Ready means the real postmaster. listen_addresses must therefore keep IPv4 loopback: a postgresql.configuration.listen_addresses without *, 0.0.0.0, localhost or 127.0.0.1 fails the render. An IPv6-only ::/::1 does not count (PostgreSQL binds it IPV6_V6ONLY).

In agent mode the readiness probe is the agent's httpGet /readyz (#395), answered from what its reconcile loop already observes, with no psql or pg_isready per probe. It needs the pg-ha image at 2.6.0 or later. See the pg chart README for the states it reports NotReady.

Pod Disruption Budgets

ParameterDescriptionDefault
postgresql.podDisruptionBudget.enabledEnable PDB for PostgreSQLtrue
postgresql.podDisruptionBudget.maxUnavailableMax pods unavailable during a voluntary disruption1
postgresql.podDisruptionBudget.unhealthyPodEvictionPolicyAllow evicting not-yet-Ready pods so a stuck pod cannot wedge a drain (k8s >=1.27)AlwaysAllow
pgpool.podDisruptionBudget.enabledEnable PDB for PGPool-IItrue
pgpool.podDisruptionBudget.minAvailableMinimum available pods1

PostgreSQL Configuration

Runtime configuration can be injected without rebuilding images. Settings are written to a ConfigMap, mounted into the pod, and loaded via include_dir.

ParameterDescriptionDefault
postgresql.configurationMap of postgresql.conf parameters{}
postgresql.pgHbaList of pg_hba.conf entries, written by the agent (HA) or by the postStart hook once the real server answers (standalone, #370)[]
postgresql.extraVolumesExtra pod-level volumes — mount a file identically on every replica (e.g. a pgsodium key); see the pg chart README[]
postgresql.extraVolumeMountsExtra mounts for the postgresql container; each must reference a postgresql.extraVolumes entry[]
postgresql.extraEnvExtra env vars for the postgresql container (supports value and valueFrom); may not reuse a chart-set name[]
postgresql.extensions.enabledEnable extensions supporttrue
postgresql.extensions.packagesDebian/PGDG packages to apt-get install before the copy step, for additional extensions beyond vector (pg_cron, …); {major} substitutes postgresql.majorVersion; see the pg chart README[]
postgresql.extensions.aptSourcesNon-PGDG apt sources (e.g. Pigsty) to add before installing packages; see the pg chart README. A pgdg entry is refused at render time (#320) — both images already configure PGDG under their own keyring, and a second entry makes apt reject the whole source list[]
postgresql.extensions.image.repositoryPrebuilt extension image — packages resolved once at build time, so pods do a plain cp with no apt and no egress at pod start, and the copy container stays unprivileged (the apt path needs root, which PSA-restricted rejects); see the pg chart README""
postgresql.extensions.image.tag / .digest / .pullPolicyTag ({major} substitutes postgresql.majorVersion), digest pin, and pull policy for the above. A tag or digest is required"" / "" / IfNotPresent
postgresql.extensions.envcore-v1 EnvVar list for the two extension init containers — chiefly http_proxy, so the install goes through your own apt mirror and no external host needs opening; see the pg chart README[]
postgresql.extensions.envFromSame as env, as core-v1 EnvFromSource; see the pg chart README[]
postgresql.extensions.extraVolumescore-v1 Volume list for the extension init containers, for what env can't express (an apt.conf.d snippet, a mirror sources.list); see the pg chart README[]
postgresql.extensions.extraVolumeMountsWhere extraVolumes land inside both extension in

Deploy pgvector with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has pgvector on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartpgvector is pinned at v2.8.0 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below
opentenant validate opentenant.yaml
terraform init && terraform apply