I am using the Bitnami Postgresql-HA Helm charts to run a Postgresql cluster in Kubernetes. I also have a PersistentVolumeClaim (PVC) full of data that isn't going into the database. I'd like to mount this PVC in my Postgres pods so that the database can read and reference that data.
I tried editing the postgresql.extraVolumes
and postgresql.extraVolumeMounts
parameters in the Helm chart's values.yaml, but it came back with:
StatefulSet.apps "app" is invalid: spec: Forbidden: updates to stateful set spec for fields other than 'replicas', 'template', 'updateStrategy', and 'minReadySeconds' are forbidden
I also tried editing the pods directly with kubectl edit
and adding the volumes under spec.volumes
and spec.containers.volumeMounts
, but that came back with
spec: Forbidden: pod updates may not change fields other than 'spec.containers[*].image', 'spec.initContainers[*].image', 'spec.activeDeadlineSeconds', 'spec.tolerations' (only additions to existing tolerations), 'spec.terminationGracePeriodSeconds' (allow it to be set to 1 if it was previously negative)
The above makes me think that the answer to my question is a straight-up "no" but I haven't come up with a definitive "no" answer from my research yet, so I'm asking the question anyways.
I know I could blow away everything I have running and re-install with Helm, but I'd rather not do that because there's schema and users in the database that I don't want to lose.
Thank you for the help!
Under default circumstances, you can remove and recreate a StatefulSet
without losing any data. Which would allow you to apply a new configuration with your extra volume.
Your first error message, is due to many fields being immutable in a StatefulSet
.
However you can usually delete a StatefulSet
and recreate it with your additional volume, without losing data in the existing volumes. This is because it is the default behavior of a StatefulSet
to release ownership of the the PersistentVolumeClaim
on deletion and then re-attach when a new StatefulSet
with the same name is created.
No volumes are deleted and no data is lost when a StatefulSet
is removed, under default circumstances.
One thing you should double-check prior to deleting your StatefulSet
, is if its manifest has .spec.persistentVolumeClaimRetentionPolicy
block and if it does, whether or not whenDeleted
has a value of Delete
. If it does and you are running on a cluster with the StatefulSetAutoDeletePVC
feature gate enabled (has been enabled by default since Kubernetes 1.27
), then your volumes will be deleted.
The Bitnami postgresql-ha
chart defaults everything to Retain
, so unless its been overridden in values, you should be fine with deleting the StatefulSet
and recreating.
See StatefulSet
docs here.