Mount extra volumes into PostgreSQL instances¶
You can mount additional Kubernetes volumes into the PostgreSQL container so every instance in the cluster sees the same files. Use this in scenarios when PostgreSQL needs files outside the data directory. For example:
-
Add full-text search dictionaries, synonym maps, and thesaurus files under the server’s shared data directory (SHAREDIR), in
tsearch_data. -
Add other shared support files that you want to supply without rebuilding the PostgreSQL image
Use a ConfigMap, Secret, PersistentVolumeClaim, emptyDir, or another volume source that Kubernetes supports. The Operator mounts these volumes on the database container for the instance set that you configure. After you apply the change, the Operator restarts PostgreSQL so the new mounts take effect.
Add an extra volume¶
This example mounts full text search dictionary files from a ConfigMap
into $SHAREDIR/tsearch_data on every instance. The PostgreSQL version used in this example is 18.
-
Create a ConfigMap with your dictionary files. Keys become file names in the mounted directory:
kubectl create configmap my-fts-dicts \ --from-file=mydict.dict \ --from-file=mydict.affix \ --from-file=mydict.stop \ -n <namespace> -
Edit the
instancessection of your cluster Custom Resource. Add anextraVolumesentry with a unique name, a volume source, and at least one mount path.For Percona Distribution for PostgreSQL,
SHAREDIRis/usr/pgsql-<postgresVersion>/share. Adjust the path to match your PostgreSQL major version:spec: instances: - name: instance1 extraVolumes: - name: fts-dicts volumeSource: configMap: name: my-fts-dicts mounts: - mountPath: /usr/pgsql-18/share/tsearch_data/mydict.dict subPath: mydict.dict readOnly: true - mountPath: /usr/pgsql-18/share/tsearch_data/mydict.affix subPath: mydict.affix readOnly: true - mountPath: /usr/pgsql-18/share/tsearch_data/mydict.stop subPath: mydict.stop readOnly: trueUse
subPathwhen you want to add your dictionary files intotsearch_datawithout wiping what PostgreSQL already ships there. If you mount a volume on the wholetsearch_datadirectory, that volume replaces the directory contents for the container, so the built-in files are no longer available there. -
Apply the Custom Resource:
kubectl apply -f deploy/cr.yaml -n <namespace>
The Operator restarts PostgreSQL instance Pods to apply the new mounts.
Verify the mount¶
Confirm that the volume appears on an instance Pod:
kubectl get pod -n <namespace> \
-l postgres-operator.crunchydata.com/instance-set=instance1 \
-o jsonpath='{.items[0].spec.volumes[*].name}{"\n"}'
The output includes your volume name (for example, fts-dicts).
Check that the files are present in the container:
kubectl exec -n <namespace> <instance-pod> -c database -- \
ls -l /usr/pgsql-18/share/tsearch_data/mydict.dict
Considerations¶
- Changing extraVolumes causes PostgreSQL to restart.
- Mounts apply to the PostgreSQL database container for that instance set. They do not mount into sidecar containers. For sidecar mounts, use the sidecar volume options instead. See Add sidecar containers.
- Prefer
subPathmounts when you add files next to the built-intsearch_datacontent.
Created: September 9, 2026