Overview
pgvector adds avector column type and approximate nearest-neighbor indexes to PostgreSQL, so embeddings live in the same database as the relational data they describe. This template deploys PostgreSQL 18 with pgvector 0.8.6 on a persistent volume, with an optional PgBouncer connection pooler and optional scheduled backups to AWS S3, GCS, or a self-hosted MinIO instance.
The extension is not just installed in the image — the template creates it for you on first boot, in the database named in your credentials secret. A fresh install can store vectors and run similarity queries with no setup SQL.
Database credentials are not template values. PostgreSQL reads its username, password and database name from a dictionary secret you create before installing, so no password passes through Helm or lands in the release.
pgvector on Control Plane operates as a single-replica deployment. Do not scale up the replica count, as this would result in multiple isolated instances rather than a replicated cluster. For automatic failover, see High Availability.
What Gets Created
- Stateful pgvector Workload — (
RELEASE_NAME-pgvector): a single replica of PostgreSQL 18 with pgvector 0.8.6, listening on port5432. - Volume Set — (
RELEASE_NAME-pgvector-vs): persistent storage for the data directory, with optional autoscaling and a final snapshot retained for 7 days. - First-Boot SQL Secret — (
RELEASE_NAME-pgvector-init): an opaque secret mounted at/docker-entrypoint-initdb.d/00-pgvector.sql, holding theCREATE EXTENSIONstatements. It contains no credentials. - Identity & Policy — (
RELEASE_NAME-pgvector-identity,RELEASE_NAME-pgvector-policy): an identity bound to the database, pooler and backup workloads, and a policy granting itrevealon exactly the secrets this release uses — nothing else. When backups are enabled, the identity also carries the Cloud Account binding the backup job uses to reach your bucket. - PgBouncer Workload (optional) — (
RELEASE_NAME-pgbouncer): a connection pooler in front of PostgreSQL, created whenpgbouncer.enabled: true. - Backup Cron Workload (optional) — (
RELEASE_NAME-pgvector-backup): a scheduledpg_dumpallthat writes compressed SQL dumps to AWS S3, GCS or MinIO, created whenbackup.enabled: true.
This template does not create a GVC. You must deploy it into an existing GVC.
Prerequisites
One secret must exist before you install. It holds the credentials your applications put in their connection strings. The values never pass through Helm, so they do not land in the release. Secrets are org-level, so no GVC flag is involved.1
Create the database credentials secret
A dictionary secret holding exactly three keys — Set
username, password and database. PostgreSQL creates that role and that database on first boot, and the template creates the vector extension inside it:config.credentialsSecretName to the name you used. Secret names are org-wide, so give each release its own.2
Read the secret back later
Pass
-o yaml. A bare cpln secret reveal prints only a summary table, not the values:accessKey and secretKey. Nothing else is required.
Installation
To install, follow the instructions for your preferred method:UI
Browse, install, and manage templates visually
CLI
Manage templates from your terminal
Terraform
Declare templates in your Terraform configurations
Pulumi
Declare templates in your Pulumi programs
Configuration
The defaultvalues.yaml for this template:
Credentials
config.credentialsSecretName— Name of the dictionary secret holdingusername,passwordanddatabase. PostgreSQL creates that role and that database on first boot, and this is the credential your applications put in their connection strings.
cpln://secret/... references, so the values appear in neither the Helm release nor the stored workload spec.
These credentials are only applied on first startup, when the data directory is empty. Rotating the secret afterwards does not change the stored password; change it inside PostgreSQL with
ALTER ROLE ... WITH PASSWORD and update the secret to match. A cpln:// reference is also only resolved when a replica starts, so force a redeployment of the workload after updating a secret it already reads.Extensions
config.extraExtensions— Additional extensions created alongsidevectorat first boot. Each entry must be an extension the image already ships, such aspg_trgm,pgcryptoorbtree_gin. Names are validated at render time against^[a-z][a-z0-9_]*$, so an entry with punctuation or capitals fails the install rather than reaching the database.
vector extension itself is always created and does not need to be listed here.
Resources
resources.minCpu/resources.minMemory— Minimum CPU and memory guaranteed to the workload.resources.maxCpu/resources.maxMemory— Maximum CPU and memory the workload can use.
On a stateful workload the ratio of
maxCpu to minCpu may not exceed 4:1. The shipped 1000m / 300m is 3.33:1; raising maxCpu without raising minCpu can cross the limit and is rejected when the workload is applied.Storage
volumeset.capacity— Initial volume size in GiB (minimum 10).volumeset.autoscaling.enabled— Allow the volume to grow as it fills. When enabled:maxCapacity— Maximum volume size in GiB.minFreePercentage— Trigger a scale-up when free space drops below this percentage.scalingFactor— Multiply the current capacity by this factor when scaling up.
Internal Access
internalAccess.type— Controls which workloads can connect to pgvector on port5432:
internalAccess.workloads— The workload links allowed in, used withsame-gvcorworkload-list.
Public Access
publicAccess.enabled— Publish port5432through a TCP load balancer, reachable from outside the org. Off by default.
status.canonicalEndpoint in the workload:
internalAccess or publicAccess, re-test rather than trusting the first response.
PgBouncer Connection Pooling
PgBouncer is an optional connection pooler that sits in front of PostgreSQL and multiplexes application connections into a smaller pool of real database connections — useful for the bursty, short-lived connections typical of retrieval and embedding services. When enabled, it becomes the primary connection endpoint for your applications:pgbouncer.enabled— Enable or disable PgBouncer.pgbouncer.image— PgBouncer container image.pgbouncer.poolMode— Controls how connections are reused:
pgbouncer.defaultPoolSize— Number of real PostgreSQL connections PgBouncer maintains per pool (default:25).pgbouncer.maxClientConn— Maximum number of client connections PgBouncer accepts (default:1000). Clients past the limit are refused at connect time; the database itself is unaffected.pgbouncer.replicas— Number of PgBouncer instances. PgBouncer is stateless and can be scaled horizontally.pgbouncer.resources.cpu/pgbouncer.resources.memory— Resources allocated to each PgBouncer replica.
PgBouncer reads the same credentials secret and identity as the pgvector workload — no additional secrets or IAM configuration is required. Its
userlist.txt and pgbouncer.ini are generated at startup from the username, password and database keys in that secret.Backup
Backup is disabled by default. When enabled, a cron workload runspg_dumpall on the configured schedule and uploads compressed SQL dumps to AWS S3, GCS or MinIO. The job authenticates with the username and password from your credentials secret.
backup.enabled— Enable scheduled backups.backup.image— Backup container image, matched to the server’s major version. The shipped18.1.0tag carries a PostgreSQL 18 client.backup.schedule— Cron expression for backup frequency (default: daily at 2am UTC). Interval forms such as*/15 * * * *are accepted.backup.provider—aws,gcp, orminio.backup.resources.cpu/backup.resources.memory— Resources for the backup cron container.backup.PROVIDER.prefix— Folder path within the bucket where backups are stored.
Using pgvector
Thevector extension is already created in the database named in your credentials secret, so there is no setup SQL to run:
Distance Operators
Index Types and Recall
Both index types build on this image and are chosen by the planner on cost — noenable_seqscan tricks required.
Approximate indexes trade recall for speed, so an exact match can be missed at the default settings. Raising
hnsw.ef_search to 400 turned a 4-of-5 exact-match result into 5 of 5. Large index builds are much faster after SET maintenance_work_mem = '512MB';.
Dimension Limits
Avector column holds up to 16,000 dimensions but can only be indexed up to 2,000. That is the most common surprise: 1,536-dimension embeddings index fine, while 3,072-dimension ones are rejected with column cannot have more than 2000 dimensions for hnsw index. Use halfvec, which indexes up to 4,000 dimensions, or reduce the dimensionality.
Backup Prerequisites
Only needed whenbackup.enabled: true.
AWS S3
-
Create an S3 bucket. Set
backup.aws.bucketto its name andbackup.aws.regionto its region. -
If you do not have a Control Plane Cloud Account set up, follow the Create a Cloud Account guide. Set
backup.aws.cloudAccountNameto its name. -
Create an IAM policy with the following JSON, replacing
YOUR_BUCKET_NAME:
-
Set
backup.aws.policyNameto the name of the policy created in step 3. The template attaches it to the workload’s identity, and attaches nothing else — the bucket in your policy is the only storage the backup job can reach. -
Set
backup.aws.prefixto the folder path where backups will be stored.
GCS
-
Create a GCS bucket. Set
backup.gcp.bucketto its name. -
If you do not have a Control Plane Cloud Account set up, follow the Create a Cloud Account guide. Set
backup.gcp.cloudAccountNameto its name. -
Add the Storage Admin role to the GCP service account associated with the Cloud Account. The template additionally binds the identity to
roles/storage.objectAdminon exactly the bucket inbackup.gcp.bucket. -
Set
backup.gcp.prefixto the folder path where backups will be stored.
MinIO
No Cloud Account is needed — credentials are supplied as a secret.-
Create a bucket in MinIO. Set
backup.minio.bucketto its name. -
Set
backup.minio.endpointto the MinIO S3 API address including the port. For the MinIO template deployed in the same GVC, usehttp://WORKLOAD_NAME:9000. -
Create a dictionary secret holding exactly the keys
accessKeyandsecretKey, and setbackup.minio.credentialsSecretNameto its name. For the MinIO template these are itsadmin.usernameandadmin.password:
- Set
backup.minio.prefixto the folder path where backups will be stored.
The policy this template creates grants the workload
reveal on the database credentials secret, the first-boot SQL secret, and — only when backup.provider: minio — the MinIO credentials secret. Nothing else.Restoring a Backup
The dumps are whole-clusterpg_dumpall output and contain CREATE EXTENSION IF NOT EXISTS vector, so restore into a database whose image carries pgvector. Replaying one into a stock postgres:18 fails at that line and the tables are never created.
Run the following from a client with access to the backup bucket, using the username and password from your credentials secret.
AWS S3:
Use a PostgreSQL 18
psql for the restore. An older client reaches the end of a PG18 dump and prints invalid command \unrestrict. The restore still completes correctly, but the message is alarming and avoidable.High Availability
This template is a single server on a single volume. A node failure reschedules the workload and reattaches the same volume, so the exposure is downtime, not data loss:
Nothing serializes the rollout on a stateful workload, so treat every upgrade as a planned write outage of roughly a minute and a half. Data on the volume survives both events intact, including built HNSW graphs, which are not rebuilt.
For automatic failover, use the PostgreSQL Highly Available template, whose image also carries pgvector. It is not the same build:
Both
hnsw and ivfflat exist in 0.8.0, so the gap is fixes and refinements rather than a missing index type. It is still a different pgvector release on a different database major, so verify against your own queries before treating the two as interchangeable.
Connecting
Important Notes
- Create the credentials secret before installing. A reference to a secret that does not exist wedges the workload with no log output at all; see Prerequisites for the one command that shows the reason.
- The
vectorextension is created by this template, not by the image. It lands in the database named in your credentials secret, on first boot only. config.extraExtensionsand the credentials are read only when the data directory is empty. Add an extension later withCREATE EXTENSION IF NOT EXISTS ..., and rotate a password withALTER ROLE ... WITH PASSWORD, updating the secret to match.- PgBouncer in
transactionmode leaks session settings between clients — includinghnsw.ef_search. UseSET LOCALinside a transaction, orpoolMode: session. See PgBouncer Connection Pooling. publicAccessis unencrypted — the image ships no TLS certificate, sosslmode=requirefails. Prefer internal access.- Do not scale past one replica. A second stateful replica gets its own volume, which is a second empty database rather than a replica.
- A
cpln helm upgraderestarts the server — measured at 92 seconds of failed writes. The first upgrade after an install re-applies resources even when the values are byte-identical. - Restore with a PostgreSQL 18
psql, into an image that carries pgvector. A stockpostgres:18fails on the dump’sCREATE EXTENSIONline. - Data lives on the volume set and survives redeploys;
cpln helm uninstalldeletes it, taking the database with it. Your credentials secret is yours and is left alone. - Firewall changes take 30 seconds to a few minutes to take effect. After changing
internalAccessorpublicAccess, re-test rather than trusting the first response.
External References
pgvector Documentation
Upstream reference for vector types, operators, and index tuning
pgvector Image
The image this template deploys, and its available tags
PostgreSQL 18 Documentation
Official documentation for the server version shipped here
PgBouncer Documentation
PgBouncer configuration reference
Cloud Accounts
Create a Control Plane Cloud Account for backup storage access
pgvector Template
View the source files, default values, and chart definition