<p>Today I want to change the PostgreSQL statefulset PVC name, to my surprise, I did not found any clain about the PVC in the kubernetes deployment define, this is the kubernetes deployment define of PostgreSQL:</p>
<pre><code>apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: reddwarf-postgresql-postgresql
  namespace: reddwarf-storage
  uid: 787a18c8-f6fb-4deb-bb07-3c3d123cf6f9
  resourceVersion: '21931453'
  generation: 30
  creationTimestamp: '2021-08-05T05:29:03Z'
  labels:
    app.kubernetes.io/component: primary
    app.kubernetes.io/instance: reddwarf-postgresql
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/name: postgresql
    helm.sh/chart: postgresql-10.9.1
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: &gt;
      {&quot;apiVersion&quot;:&quot;apps/v1&quot;,&quot;kind&quot;:&quot;StatefulSet&quot;,&quot;metadata&quot;:{&quot;annotations&quot;:{&quot;meta.helm.sh/release-name&quot;:&quot;reddwarf-postgresql&quot;,&quot;meta.helm.sh/release-namespace&quot;:&quot;reddwarf-storage&quot;},&quot;creationTimestamp&quot;:&quot;2021-08-05T05:29:03Z&quot;,&quot;generation&quot;:12,&quot;labels&quot;:{&quot;app.kubernetes.io/component&quot;:&quot;primary&quot;,&quot;app.kubernetes.io/instance&quot;:&quot;reddwarf-postgresql&quot;,&quot;app.kubernetes.io/managed-by&quot;:&quot;Helm&quot;,&quot;app.kubernetes.io/name&quot;:&quot;postgresql&quot;,&quot;helm.sh/chart&quot;:&quot;postgresql-10.9.1&quot;},&quot;managedFields&quot;:[{&quot;apiVersion&quot;:&quot;apps/v1&quot;,&quot;fieldsType&quot;:&quot;FieldsV1&quot;,&quot;fieldsV1&quot;:{&quot;f:metadata&quot;:{&quot;f:annotations&quot;:{&quot;.&quot;:{},&quot;f:meta.helm.sh/release-name&quot;:{},&quot;f:meta.helm.sh/release-namespace&quot;:{}},&quot;f:labels&quot;:{&quot;.&quot;:{},&quot;f:app.kubernetes.io/component&quot;:{},&quot;f:app.kubernetes.io/instance&quot;:{},&quot;f:app.kubernetes.io/managed-by&quot;:{},&quot;f:app.kubernetes.io/name&quot;:{},&quot;f:helm.sh/chart&quot;:{}}},&quot;f:spec&quot;:{&quot;f:podManagementPolicy&quot;:{},&quot;f:replicas&quot;:{},&quot;f:revisionHistoryLimit&quot;:{},&quot;f:selector&quot;:{},&quot;f:serviceName&quot;:{},&quot;f:template&quot;:{&quot;f:metadata&quot;:{&quot;f:labels&quot;:{&quot;.&quot;:{},&quot;f:app.kubernetes.io/component&quot;:{},&quot;f:app.kubernetes.io/instance&quot;:{},&quot;f:app.kubernetes.io/managed-by&quot;:{},&quot;f:app.kubernetes.io/name&quot;:{},&quot;f:helm.sh/chart&quot;:{},&quot;f:role&quot;:{}},&quot;f:name&quot;:{}},&quot;f:spec&quot;:{&quot;f:affinity&quot;:{&quot;.&quot;:{},&quot;f:podAntiAffinity&quot;:{&quot;.&quot;:{},&quot;f:preferredDuringSchedulingIgnoredDuringExecution&quot;:{}}},&quot;f:automountServiceAccountToken&quot;:{},&quot;f:containers&quot;:{&quot;k:{\&quot;name\&quot;:\&quot;reddwarf-postgresql\&quot;}&quot;:{&quot;.&quot;:{},&quot;f:env&quot;:{&quot;.&quot;:{},&quot;k:{\&quot;name\&quot;:\&quot;BITNAMI_DEBUG\&quot;}&quot;:{&quot;.&quot;:{},&quot;f:name&quot;:{},&quot;f:value&quot;:{}},&quot;k:{\&quot;name\&quot;:\&quot;PGDATA\&quot;}&quot;:{&quot;.&quot;:{},&quot;f:name&quot;:{},&quot;f:value&quot;:{}},&quot;k:{\&quot;name\&quot;:\&quot;POSTGRESQL_CLIENT_MIN_MESSAGES\&quot;}&quot;:{&quot;.&quot;:{},&quot;f:name&quot;:{},&quot;f:value&quot;:{}},&quot;k:{\&quot;name\&quot;:\&quot;POSTGRESQL_ENABLE_LDAP\&quot;}&quot;:{&quot;.&quot;:{},&quot;f:name&quot;:{},&quot;f:value&quot;:{}},&quot;k:{\&quot;name\&quot;:\&quot;POSTGRESQL_ENABLE_TLS\&quot;}&quot;:{&quot;.&quot;:{},&quot;f:name&quot;:{},&quot;f:value&quot;:{}},&quot;k:{\&quot;name\&quot;:\&quot;POSTGRESQL_LOG_CONNECTIONS\&quot;}&quot;:{&quot;.&quot;:{},&quot;f:name&quot;:{},&quot;f:value&quot;:{}},&quot;k:{\&quot;name\&quot;:\&quot;POSTGRESQL_LOG_DISCONNECTIONS\&quot;}&quot;:{&quot;.&quot;:{},&quot;f:name&quot;:{},&quot;f:value&quot;:{}},&quot;k:{\&quot;name\&quot;:\&quot;POSTGRESQL_LOG_HOSTNAME\&quot;}&quot;:{&quot;.&quot;:{},&quot;f:name&quot;:{},&quot;f:value&quot;:{}},&quot;k:{\&quot;name\&quot;:\&quot;POSTGRESQL_PGAUDIT_LOG_CATALOG\&quot;}&quot;:{&quot;.&quot;:{},&quot;f:name&quot;:{},&quot;f:value&quot;:{}},&quot;k:{\&quot;name\&quot;:\&quot;POSTGRESQL_PORT_NUMBER\&quot;}&quot;:{&quot;.&quot;:{},&quot;f:name&quot;:{},&quot;f:value&quot;:{}},&quot;k:{\&quot;name\&quot;:\&quot;POSTGRESQL_SHARED_PRELOAD_LIBRARIES\&quot;}&quot;:{&quot;.&quot;:{},&quot;f:name&quot;:{},&quot;f:value&quot;:{}},&quot;k:{\&quot;name\&quot;:\&quot;POSTGRESQL_VOLUME_DIR\&quot;}&quot;:{&quot;.&quot;:{},&quot;f:name&quot;:{},&quot;f:value&quot;:{}},&quot;k:{\&quot;name\&quot;:\&quot;POSTGRES_PASSWORD\&quot;}&quot;:{&quot;.&quot;:{},&quot;f:name&quot;:{},&quot;f:valueFrom&quot;:{&quot;.&quot;:{},&quot;f:secretKeyRef&quot;:{&quot;.&quot;:{},&quot;f:key&quot;:{},&quot;f:name&quot;:{}}}},&quot;k:{\&quot;name\&quot;:\&quot;POSTGRES_USER\&quot;}&quot;:{&quot;.&quot;:{},&quot;f:name&quot;:{},&quot;f:value&quot;:{}}},&quot;f:imagePullPolicy&quot;:{},&quot;f:livenessProbe&quot;:{&quot;.&quot;:{},&quot;f:exec&quot;:{&quot;.&quot;:{},&quot;f:command&quot;:{}},&quot;f:failureThreshold&quot;:{},&quot;f:initialDelaySeconds&quot;:{},&quot;f:periodSeconds&quot;:{},&quot;f:successThreshold&quot;:{},&quot;f:timeoutSeconds&quot;:{}},&quot;f:name&quot;:{},&quot;f:ports&quot;:{&quot;.&quot;:{},&quot;k:{\&quot;containerPort\&quot;:5432,\&quot;protocol\&quot;:\&quot;TCP\&quot;}&quot;:{&quot;.&quot;:{},&quot;f:containerPort&quot;:{},&quot;f:name&quot;:{},&quot;f:protocol&quot;:{}}},&quot;f:readinessProbe&quot;:{&quot;.&quot;:{},&quot;f:exec&quot;:{&quot;.&quot;:{},&quot;f:command&quot;:{}},&quot;f:failureThreshold&quot;:{},&quot;f:initialDelaySeconds&quot;:{},&quot;f:periodSeconds&quot;:{},&quot;f:successThreshold&quot;:{},&quot;f:timeoutSeconds&quot;:{}},&quot;f:resources&quot;:{&quot;.&quot;:{},&quot;f:requests&quot;:{&quot;.&quot;:{},&quot;f:cpu&quot;:{},&quot;f:memory&quot;:{}}},&quot;f:securityContext&quot;:{&quot;.&quot;:{},&quot;f:runAsUser&quot;:{}},&quot;f:terminationMessagePath&quot;:{},&quot;f:terminationMessagePolicy&quot;:{},&quot;f:volumeMounts&quot;:{&quot;.&quot;:{},&quot;k:{\&quot;mountPath\&quot;:\&quot;/bitnami/postgresql\&quot;}&quot;:{&quot;.&quot;:{},&quot;f:mountPath&quot;:{},&quot;f:name&quot;:{}},&quot;k:{\&quot;mountPath\&quot;:\&quot;/dev/shm\&quot;}&quot;:{&quot;.&quot;:{},&quot;f:mountPath&quot;:{},&quot;f:name&quot;:{}}}}},&quot;f:dnsPolicy&quot;:{},&quot;f:restartPolicy&quot;:{},&quot;f:schedulerName&quot;:{},&quot;f:securityContext&quot;:{&quot;.&quot;:{},&quot;f:fsGroup&quot;:{}},&quot;f:terminationGracePeriodSeconds&quot;:{},&quot;f:volumes&quot;:{&quot;.&quot;:{},&quot;k:{\&quot;name\&quot;:\&quot;dshm\&quot;}&quot;:{&quot;.&quot;:{},&quot;f:emptyDir&quot;:{&quot;.&quot;:{},&quot;f:medium&quot;:{}},&quot;f:name&quot;:{}}}}},&quot;f:updateStrategy&quot;:{&quot;f:type&quot;:{}},&quot;f:volumeClaimTemplates&quot;:{}}},&quot;manager&quot;:&quot;Go-http-client&quot;,&quot;operation&quot;:&quot;Update&quot;,&quot;time&quot;:&quot;2021-08-05T05:29:03Z&quot;},{&quot;apiVersion&quot;:&quot;apps/v1&quot;,&quot;fieldsType&quot;:&quot;FieldsV1&quot;,&quot;fieldsV1&quot;:{&quot;f:spec&quot;:{&quot;f:template&quot;:{&quot;f:spec&quot;:{&quot;f:containers&quot;:{&quot;k:{\&quot;name\&quot;:\&quot;reddwarf-postgresql\&quot;}&quot;:{&quot;f:image&quot;:{}}}}}}},&quot;manager&quot;:&quot;kubectl-client-side-apply&quot;,&quot;operation&quot;:&quot;Update&quot;,&quot;time&quot;:&quot;2021-08-10T16:50:45Z&quot;},{&quot;apiVersion&quot;:&quot;apps/v1&quot;,&quot;fieldsType&quot;:&quot;FieldsV1&quot;,&quot;fieldsV1&quot;:{&quot;f:metadata&quot;:{&quot;f:annotations&quot;:{&quot;f:kubectl.kubernetes.io/last-applied-configuration&quot;:{}}},&quot;f:spec&quot;:{&quot;f:template&quot;:{&quot;f:spec&quot;:{&quot;f:containers&quot;:{&quot;k:{\&quot;name\&quot;:\&quot;reddwarf-postgresql\&quot;}&quot;:{&quot;f:args&quot;:{}}}}}}},&quot;manager&quot;:&quot;kubectl&quot;,&quot;operation&quot;:&quot;Update&quot;,&quot;time&quot;:&quot;2021-08-11T01:46:21Z&quot;},{&quot;apiVersion&quot;:&quot;apps/v1&quot;,&quot;fieldsType&quot;:&quot;FieldsV1&quot;,&quot;fieldsV1&quot;:{&quot;f:status&quot;:{&quot;f:collisionCount&quot;:{},&quot;f:currentReplicas&quot;:{},&quot;f:currentRevision&quot;:{},&quot;f:observedGeneration&quot;:{},&quot;f:replicas&quot;:{},&quot;f:updateRevision&quot;:{},&quot;f:updatedReplicas&quot;:{}}},&quot;manager&quot;:&quot;kube-controller-manager&quot;,&quot;operation&quot;:&quot;Update&quot;,&quot;time&quot;:&quot;2021-08-11T02:24:07Z&quot;}],&quot;name&quot;:&quot;reddwarf-postgresql-postgresql&quot;,&quot;namespace&quot;:&quot;reddwarf-storage&quot;,&quot;selfLink&quot;:&quot;/apis/apps/v1/namespaces/reddwarf-storage/statefulsets/reddwarf-postgresql-postgresql&quot;,&quot;uid&quot;:&quot;787a18c8-f6fb-4deb-bb07-3c3d123cf6f9&quot;},&quot;spec&quot;:{&quot;podManagementPolicy&quot;:&quot;OrderedReady&quot;,&quot;replicas&quot;:1,&quot;revisionHistoryLimit&quot;:10,&quot;selector&quot;:{&quot;matchLabels&quot;:{&quot;app.kubernetes.io/instance&quot;:&quot;reddwarf-postgresql&quot;,&quot;app.kubernetes.io/name&quot;:&quot;postgresql&quot;,&quot;role&quot;:&quot;primary&quot;}},&quot;serviceName&quot;:&quot;reddwarf-postgresql-headless&quot;,&quot;template&quot;:{&quot;metadata&quot;:{&quot;creationTimestamp&quot;:null,&quot;labels&quot;:{&quot;app.kubernetes.io/component&quot;:&quot;primary&quot;,&quot;app.kubernetes.io/instance&quot;:&quot;reddwarf-postgresql&quot;,&quot;app.kubernetes.io/managed-by&quot;:&quot;Helm&quot;,&quot;app.kubernetes.io/name&quot;:&quot;postgresql&quot;,&quot;helm.sh/chart&quot;:&quot;postgresql-10.9.1&quot;,&quot;role&quot;:&quot;primary&quot;},&quot;name&quot;:&quot;reddwarf-postgresql&quot;},&quot;spec&quot;:{&quot;affinity&quot;:{&quot;podAntiAffinity&quot;:{&quot;preferredDuringSchedulingIgnoredDuringExecution&quot;:[{&quot;podAffinityTerm&quot;:{&quot;labelSelector&quot;:{&quot;matchLabels&quot;:{&quot;app.kubernetes.io/component&quot;:&quot;primary&quot;,&quot;app.kubernetes.io/instance&quot;:&quot;reddwarf-postgresql&quot;,&quot;app.kubernetes.io/name&quot;:&quot;postgresql&quot;}},&quot;namespaces&quot;:[&quot;reddwarf-storage&quot;],&quot;topologyKey&quot;:&quot;kubernetes.io/hostname&quot;},&quot;weight&quot;:1}]}},&quot;automountServiceAccountToken&quot;:false,&quot;containers&quot;:[{&quot;env&quot;:[{&quot;name&quot;:&quot;BITNAMI_DEBUG&quot;,&quot;value&quot;:&quot;false&quot;},{&quot;name&quot;:&quot;POSTGRESQL_PORT_NUMBER&quot;,&quot;value&quot;:&quot;5432&quot;},{&quot;name&quot;:&quot;POSTGRESQL_VOLUME_DIR&quot;,&quot;value&quot;:&quot;/bitnami/postgresql&quot;},{&quot;name&quot;:&quot;PGDATA&quot;,&quot;value&quot;:&quot;/bitnami/postgresql/data&quot;},{&quot;name&quot;:&quot;POSTGRES_USER&quot;,&quot;value&quot;:&quot;postgres&quot;},{&quot;name&quot;:&quot;POSTGRES_PASSWORD&quot;,&quot;valueFrom&quot;:{&quot;secretKeyRef&quot;:{&quot;key&quot;:&quot;postgresql-password&quot;,&quot;name&quot;:&quot;reddwarf-postgresql&quot;}}},{&quot;name&quot;:&quot;POSTGRESQL_ENABLE_LDAP&quot;,&quot;value&quot;:&quot;no&quot;},{&quot;name&quot;:&quot;POSTGRESQL_ENABLE_TLS&quot;,&quot;value&quot;:&quot;no&quot;},{&quot;name&quot;:&quot;POSTGRESQL_LOG_HOSTNAME&quot;,&quot;value&quot;:&quot;false&quot;},{&quot;name&quot;:&quot;POSTGRESQL_LOG_CONNECTIONS&quot;,&quot;value&quot;:&quot;false&quot;},{&quot;name&quot;:&quot;POSTGRESQL_LOG_DISCONNECTIONS&quot;,&quot;value&quot;:&quot;false&quot;},{&quot;name&quot;:&quot;POSTGRESQL_PGAUDIT_LOG_CATALOG&quot;,&quot;value&quot;:&quot;off&quot;},{&quot;name&quot;:&quot;POSTGRESQL_CLIENT_MIN_MESSAGES&quot;,&quot;value&quot;:&quot;error&quot;},{&quot;name&quot;:&quot;POSTGRESQL_SHARED_PRELOAD_LIBRARIES&quot;,&quot;value&quot;:&quot;pgaudit&quot;}],&quot;image&quot;:&quot;docker.io/bitnami/postgresql:13.3.0-debian-10-r75&quot;,&quot;imagePullPolicy&quot;:&quot;IfNotPresent&quot;,&quot;livenessProbe&quot;:{&quot;exec&quot;:{&quot;command&quot;:[&quot;/bin/sh&quot;,&quot;-c&quot;,&quot;exec
      pg_isready -U \&quot;postgres\&quot; -h 127.0.0.1 -p
      5432&quot;]},&quot;failureThreshold&quot;:6,&quot;initialDelaySeconds&quot;:30,&quot;periodSeconds&quot;:10,&quot;successThreshold&quot;:1,&quot;timeoutSeconds&quot;:5},&quot;name&quot;:&quot;reddwarf-postgresql&quot;,&quot;ports&quot;:[{&quot;containerPort&quot;:5432,&quot;name&quot;:&quot;tcp-postgresql&quot;,&quot;protocol&quot;:&quot;TCP&quot;}],&quot;readinessProbe&quot;:{&quot;exec&quot;:{&quot;command&quot;:[&quot;/bin/sh&quot;,&quot;-c&quot;,&quot;-e&quot;,&quot;exec
      pg_isready -U \&quot;postgres\&quot; -h 127.0.0.1 -p 5432\n[ -f
      /opt/bitnami/postgresql/tmp/.initialized ] || [ -f
      /bitnami/postgresql/.initialized
      ]\n&quot;]},&quot;failureThreshold&quot;:6,&quot;initialDelaySeconds&quot;:5,&quot;periodSeconds&quot;:10,&quot;successThreshold&quot;:1,&quot;timeoutSeconds&quot;:5},&quot;resources&quot;:{&quot;requests&quot;:{&quot;cpu&quot;:&quot;250m&quot;,&quot;memory&quot;:&quot;256Mi&quot;}},&quot;securityContext&quot;:{&quot;runAsUser&quot;:1001},&quot;terminationMessagePath&quot;:&quot;/dev/termination-log&quot;,&quot;terminationMessagePolicy&quot;:&quot;File&quot;,&quot;volumeMounts&quot;:[{&quot;mountPath&quot;:&quot;/dev/shm&quot;,&quot;name&quot;:&quot;dshm&quot;},{&quot;mountPath&quot;:&quot;/bitnami/postgresql&quot;,&quot;name&quot;:&quot;data&quot;}]}],&quot;dnsPolicy&quot;:&quot;ClusterFirst&quot;,&quot;restartPolicy&quot;:&quot;Always&quot;,&quot;schedulerName&quot;:&quot;default-scheduler&quot;,&quot;securityContext&quot;:{&quot;fsGroup&quot;:1001},&quot;terminationGracePeriodSeconds&quot;:30,&quot;volumes&quot;:[{&quot;emptyDir&quot;:{&quot;medium&quot;:&quot;Memory&quot;},&quot;name&quot;:&quot;dshm&quot;}]}},&quot;updateStrategy&quot;:{&quot;type&quot;:&quot;RollingUpdate&quot;},&quot;volumeClaimTemplates&quot;:[{&quot;apiVersion&quot;:&quot;v1&quot;,&quot;kind&quot;:&quot;PersistentVolumeClaim&quot;,&quot;metadata&quot;:{&quot;creationTimestamp&quot;:null,&quot;name&quot;:&quot;data&quot;},&quot;spec&quot;:{&quot;accessModes&quot;:[&quot;ReadWriteOnce&quot;],&quot;resources&quot;:{&quot;requests&quot;:{&quot;storage&quot;:&quot;8Gi&quot;}},&quot;volumeMode&quot;:&quot;Filesystem&quot;},&quot;status&quot;:{&quot;phase&quot;:&quot;Pending&quot;}}]}}
    meta.helm.sh/release-name: reddwarf-postgresql
    meta.helm.sh/release-namespace: reddwarf-storage
  managedFields:
    - manager: Go-http-client
      operation: Update
      apiVersion: apps/v1
      time: '2021-08-05T05:29:03Z'
      fieldsType: FieldsV1
      fieldsV1:
        'f:metadata':
          'f:annotations':
            .: {}
            'f:meta.helm.sh/release-name': {}
            'f:meta.helm.sh/release-namespace': {}
          'f:labels':
            .: {}
            'f:app.kubernetes.io/component': {}
            'f:app.kubernetes.io/instance': {}
            'f:app.kubernetes.io/managed-by': {}
            'f:app.kubernetes.io/name': {}
            'f:helm.sh/chart': {}
        'f:spec':
          'f:podManagementPolicy': {}
          'f:replicas': {}
          'f:revisionHistoryLimit': {}
          'f:selector': {}
          'f:serviceName': {}
          'f:template':
            'f:metadata':
              'f:labels':
                .: {}
                'f:app.kubernetes.io/component': {}
                'f:app.kubernetes.io/instance': {}
                'f:app.kubernetes.io/managed-by': {}
                'f:app.kubernetes.io/name': {}
                'f:helm.sh/chart': {}
                'f:role': {}
              'f:name': {}
            'f:spec':
              'f:affinity':
                .: {}
                'f:podAntiAffinity':
                  .: {}
                  'f:preferredDuringSchedulingIgnoredDuringExecution': {}
              'f:automountServiceAccountToken': {}
              'f:containers':
                'k:{&quot;name&quot;:&quot;reddwarf-postgresql&quot;}':
                  .: {}
                  'f:env':
                    .: {}
                    'k:{&quot;name&quot;:&quot;BITNAMI_DEBUG&quot;}':
                      .: {}
                      'f:name': {}
                      'f:value': {}
                    'k:{&quot;name&quot;:&quot;PGDATA&quot;}':
                      .: {}
                      'f:name': {}
                      'f:value': {}
                    'k:{&quot;name&quot;:&quot;POSTGRESQL_CLIENT_MIN_MESSAGES&quot;}':
                      .: {}
                      'f:name': {}
                      'f:value': {}
                    'k:{&quot;name&quot;:&quot;POSTGRESQL_ENABLE_LDAP&quot;}':
                      .: {}
                      'f:name': {}
                      'f:value': {}
                    'k:{&quot;name&quot;:&quot;POSTGRESQL_ENABLE_TLS&quot;}':
                      .: {}
                      'f:name': {}
                      'f:value': {}
                    'k:{&quot;name&quot;:&quot;POSTGRESQL_LOG_CONNECTIONS&quot;}':
                      .: {}
                      'f:name': {}
                      'f:value': {}
                    'k:{&quot;name&quot;:&quot;POSTGRESQL_LOG_DISCONNECTIONS&quot;}':
                      .: {}
                      'f:name': {}
                      'f:value': {}
                    'k:{&quot;name&quot;:&quot;POSTGRESQL_LOG_HOSTNAME&quot;}':
                      .: {}
                      'f:name': {}
                      'f:value': {}
                    'k:{&quot;name&quot;:&quot;POSTGRESQL_PGAUDIT_LOG_CATALOG&quot;}':
                      .: {}
                      'f:name': {}
                      'f:value': {}
                    'k:{&quot;name&quot;:&quot;POSTGRESQL_PORT_NUMBER&quot;}':
                      .: {}
                      'f:name': {}
                      'f:value': {}
                    'k:{&quot;name&quot;:&quot;POSTGRESQL_SHARED_PRELOAD_LIBRARIES&quot;}':
                      .: {}
                      'f:name': {}
                      'f:value': {}
                    'k:{&quot;name&quot;:&quot;POSTGRESQL_VOLUME_DIR&quot;}':
                      .: {}
                      'f:name': {}
                      'f:value': {}
                    'k:{&quot;name&quot;:&quot;POSTGRES_PASSWORD&quot;}':
                      .: {}
                      'f:name': {}
                      'f:valueFrom':
                        .: {}
                        'f:secretKeyRef':
                          .: {}
                          'f:key': {}
                          'f:name': {}
                    'k:{&quot;name&quot;:&quot;POSTGRES_USER&quot;}':
                      .: {}
                      'f:name': {}
                      'f:value': {}
                  'f:imagePullPolicy': {}
                  'f:livenessProbe':
                    .: {}
                    'f:exec':
                      .: {}
                      'f:command': {}
                    'f:failureThreshold': {}
                    'f:initialDelaySeconds': {}
                    'f:periodSeconds': {}
                    'f:successThreshold': {}
                    'f:timeoutSeconds': {}
                  'f:name': {}
                  'f:ports':
                    .: {}
                    'k:{&quot;containerPort&quot;:5432,&quot;protocol&quot;:&quot;TCP&quot;}':
                      .: {}
                      'f:containerPort': {}
                      'f:name': {}
                      'f:protocol': {}
                  'f:readinessProbe':
                    .: {}
                    'f:exec':
                      .: {}
                      'f:command': {}
                    'f:failureThreshold': {}
                    'f:initialDelaySeconds': {}
                    'f:periodSeconds': {}
                    'f:successThreshold': {}
                    'f:timeoutSeconds': {}
                  'f:resources':
                    .: {}
                    'f:requests':
                      .: {}
                      'f:cpu': {}
                      'f:memory': {}
                  'f:securityContext':
                    .: {}
                    'f:runAsUser': {}
                  'f:terminationMessagePath': {}
                  'f:terminationMessagePolicy': {}
                  'f:volumeMounts':
                    .: {}
                    'k:{&quot;mountPath&quot;:&quot;/bitnami/postgresql&quot;}':
                      .: {}
                      'f:mountPath': {}
                      'f:name': {}
                    'k:{&quot;mountPath&quot;:&quot;/dev/shm&quot;}':
                      .: {}
                      'f:mountPath': {}
                      'f:name': {}
              'f:dnsPolicy': {}
              'f:restartPolicy': {}
              'f:schedulerName': {}
              'f:securityContext':
                .: {}
                'f:fsGroup': {}
              'f:terminationGracePeriodSeconds': {}
              'f:volumes':
                .: {}
                'k:{&quot;name&quot;:&quot;dshm&quot;}':
                  .: {}
                  'f:emptyDir':
                    .: {}
                    'f:medium': {}
                  'f:name': {}
          'f:updateStrategy':
            'f:type': {}
          'f:volumeClaimTemplates': {}
    - manager: kubectl-client-side-apply
      operation: Update
      apiVersion: apps/v1
      time: '2021-08-10T16:50:45Z'
      fieldsType: FieldsV1
      fieldsV1:
        'f:spec':
          'f:template':
            'f:spec':
              'f:containers':
                'k:{&quot;name&quot;:&quot;reddwarf-postgresql&quot;}':
                  'f:image': {}
    - manager: kubectl
      operation: Update
      apiVersion: apps/v1
      time: '2021-08-11T02:29:20Z'
      fieldsType: FieldsV1
      fieldsV1:
        'f:metadata':
          'f:annotations':
            'f:kubectl.kubernetes.io/last-applied-configuration': {}
    - manager: kube-controller-manager
      operation: Update
      apiVersion: apps/v1
      time: '2021-11-27T03:07:58Z'
      fieldsType: FieldsV1
      fieldsV1:
        'f:status':
          'f:collisionCount': {}
          'f:currentRevision': {}
          'f:observedGeneration': {}
          'f:replicas': {}
          'f:updateRevision': {}
  selfLink: &gt;-
    /apis/apps/v1/namespaces/reddwarf-storage/statefulsets/reddwarf-postgresql-postgresql
status:
  observedGeneration: 30
  replicas: 0
  currentRevision: reddwarf-postgresql-postgresql-5695cb9676
  updateRevision: reddwarf-postgresql-postgresql-5695cb9676
  collisionCount: 0
spec:
  replicas: 0
  selector:
    matchLabels:
      app.kubernetes.io/instance: reddwarf-postgresql
      app.kubernetes.io/name: postgresql
      role: primary
  template:
    metadata:
      name: reddwarf-postgresql
      creationTimestamp: null
      labels:
        app.kubernetes.io/component: primary
        app.kubernetes.io/instance: reddwarf-postgresql
        app.kubernetes.io/managed-by: Helm
        app.kubernetes.io/name: postgresql
        helm.sh/chart: postgresql-10.9.1
        role: primary
    spec:
      volumes:
        - name: dshm
          emptyDir:
            medium: Memory
      containers:
        - name: reddwarf-postgresql
          image: 'docker.io/bitnami/postgresql:13.3.0-debian-10-r75'
          ports:
            - name: tcp-postgresql
              containerPort: 5432
              protocol: TCP
          env:
            - name: BITNAMI_DEBUG
              value: 'false'
            - name: POSTGRESQL_PORT_NUMBER
              value: '5432'
            - name: POSTGRESQL_VOLUME_DIR
              value: /bitnami/postgresql
            - name: PGDATA
              value: /bitnami/postgresql/data
            - name: POSTGRES_USER
              value: postgres
            - name: POSTGRES_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: reddwarf-postgresql
                  key: postgresql-password
            - name: POSTGRESQL_ENABLE_LDAP
              value: 'no'
            - name: POSTGRESQL_ENABLE_TLS
              value: 'no'
            - name: POSTGRESQL_LOG_HOSTNAME
              value: 'false'
            - name: POSTGRESQL_LOG_CONNECTIONS
              value: 'false'
            - name: POSTGRESQL_LOG_DISCONNECTIONS
              value: 'false'
            - name: POSTGRESQL_PGAUDIT_LOG_CATALOG
              value: 'off'
            - name: POSTGRESQL_CLIENT_MIN_MESSAGES
              value: error
            - name: POSTGRESQL_SHARED_PRELOAD_LIBRARIES
              value: pgaudit
          resources:
            requests:
              cpu: 250m
              memory: 256Mi
          volumeMounts:
            - name: dshm
              mountPath: /dev/shm
            - name: data
              mountPath: /bitnami/postgresql
          livenessProbe:
            exec:
              command:
                - /bin/sh
                - '-c'
                - exec pg_isready -U &quot;postgres&quot; -h 127.0.0.1 -p 5432
            initialDelaySeconds: 30
            timeoutSeconds: 5
            periodSeconds: 10
            successThreshold: 1
            failureThreshold: 6
          readinessProbe:
            exec:
              command:
                - /bin/sh
                - '-c'
                - '-e'
                - &gt;
                  exec pg_isready -U &quot;postgres&quot; -h 127.0.0.1 -p 5432

                  [ -f /opt/bitnami/postgresql/tmp/.initialized ] || [ -f
                  /bitnami/postgresql/.initialized ]
            initialDelaySeconds: 5
            timeoutSeconds: 5
            periodSeconds: 10
            successThreshold: 1
            failureThreshold: 6
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
          imagePullPolicy: IfNotPresent
          securityContext:
            runAsUser: 1001
      restartPolicy: Always
      terminationGracePeriodSeconds: 30
      dnsPolicy: ClusterFirst
      automountServiceAccountToken: false
      securityContext:
        fsGroup: 1001
      affinity:
        podAntiAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
            - weight: 1
              podAffinityTerm:
                labelSelector:
                  matchLabels:
                    app.kubernetes.io/component: primary
                    app.kubernetes.io/instance: reddwarf-postgresql
                    app.kubernetes.io/name: postgresql
                namespaces:
                  - reddwarf-storage
                topologyKey: kubernetes.io/hostname
      schedulerName: default-scheduler
  volumeClaimTemplates:
    - kind: PersistentVolumeClaim
      apiVersion: v1
      metadata:
        name: data
        creationTimestamp: null
      spec:
        accessModes:
          - ReadWriteOnce
        resources:
          requests:
            storage: 8Gi
        volumeMode: Filesystem
      status:
        phase: Pending
  serviceName: reddwarf-postgresql-headless
  podManagementPolicy: OrderedReady
  updateStrategy:
    type: RollingUpdate
  revisionHistoryLimit: 10
</code></pre>
<p>this statefulset bind the PVC named <code>data-reddwarf-postgresql-postgresql-0</code> right now, but I did not found the PVC define in this statefulset yaml. where is the PVC bind define? what should I do to change the PVC to bind to a new one? I install this PostgreSQL into kubernetes from helm chart.</p>

<p>pvc thats gets created as a part of statefulset will have a name which is an amalgamation of 3 components joined by <code>-</code> :</p>
<ol>
<li>Name defined in the <code>volumeClaimTemplates</code> section <code>data</code></li>
<li>Name of the <code>statefulset</code> in the metadata section which is <code>reddwarf-postgresql-postgresql</code></li>
<li>Its replica number , if it is first replica then it would be <code>0</code></li>
</ol>
<p>So finally the name of the pvc that gets created when you create this statefulset is
<code>data-reddwarf-postgresql-postgresql-0</code>.which is the pvc name that you also seeing in your setup.</p>
<p>please note when you delete the statefulset , pvc does not deleted automatically we need to pvc separately. When you recreate/scaleup the stateful set and if the pvc which matches above naming convention&amp; spec does not exists then it will create a pvc.</p>
<p><a href="https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#stable-network-id" rel="nofollow noreferrer">From kubernetes documentation</a></p>
