how to use nfs storage in crunchydata postgres operator

1.2k views Asked by At

I am trying out the CrunchyData postgres-operator(Helm) with the NFS Helm chart. And I am unable to create the Cluster with NFS. The following configuration is performed:

Installed NFS helm chart Repo

helm install nfs-abc stable/nfs-server-provisioner

Set the postgres storage values Doc

backrest_storage: 'nfsstorage'
backup_storage: 'nfsstorage'
primary_storage: 'nfsstorage'
replica_storage: 'nfsstorage'

Set the storage configuration Doc

export CCP_SECURITY_CONTEXT='"supplementalGroups": [65534]'
export CCP_STORAGE_PATH=/nfsfileshare
export CCP_NFS_IP=data-nfs-dravoka-nfs-server-provisioner-0.default.svc.cluster.local
export CCP_STORAGE_MODE=ReadWriteMany
export CCP_STORAGE_CAPACITY=400M

Created PGO cluster

pgo create cluster -n pgo dravoka --storage-config='nfsstorage' --pgbackrest-storage-config='nfsstorage' --pvc-size='2Gi'

PVC describe:

kubectl describe -n pgo pvc dravoka
Name:          dravoka
Namespace:     pgo
StorageClass:  standard
Status:        Pending
Volume:
Labels:        pg-cluster=dravoka
               pgremove=true
               vendor=crunchydata
Annotations:   volume.beta.kubernetes.io/storage-provisioner: kubernetes.io/gce-pd
Finalizers:    [kubernetes.io/pvc-protection]
Capacity:
Access Modes:
VolumeMode:    Filesystem
Mounted By:    <none>
Events:
  Type     Reason              Age                    From                         Message
  ----     ------              ----                   ----                         -------
  Warning  ProvisioningFailed  112s (x10 over 7m45s)  persistentvolume-controller  Failed to provision volume with StorageClass "standard": invalid AccessModes [ReadWriteMany]: only AccessModes [ReadWriteOnce ReadOnlyMany] are supported

Pod Describe:

kubectl describe -n pgo pod dravoka-backrest-shared-repo-9fdd77886-j2mjv
Name:           dravoka-backrest-shared-repo-9fdd77886-j2mjv
Namespace:      pgo
Priority:       0
Node:           <none>
Labels:         name=dravoka-backrest-shared-repo
                pg-cluster=dravoka
                pg-pod-anti-affinity=preferred
                pgo-backrest-repo=true
                pod-template-hash=9fdd77886
                service-name=dravoka-backrest-shared-repo
                vendor=crunchydata
Annotations:    <none>
Status:         Pending
IP:
IPs:            <none>
Controlled By:  ReplicaSet/dravoka-backrest-shared-repo-9fdd77886
Containers:
  database:
    Image:      registry.developers.crunchydata.com/crunchydata/pgo-backrest-repo:centos7-4.4.1
    Port:       2022/TCP
    Host Port:  0/TCP
    Requests:
      memory:  48Mi
    Environment:
      PGBACKREST_STANZA:           db
      SSHD_PORT:                   2022
      PGBACKREST_DB_PATH:          /pgdata/dravoka
      PGBACKREST_REPO_PATH:        /backrestrepo/dravoka-backrest-shared-repo
      PGBACKREST_PG1_PORT:         5432
      PGBACKREST_LOG_PATH:         /tmp
      PGBACKREST_PG1_SOCKET_PATH:  /tmp
      PGBACKREST_DB_HOST:          dravoka
    Mounts:
      /backrestrepo from backrestrepo (rw)
      /sshd from sshd (ro)
Conditions:
  Type           Status
  PodScheduled   False
Volumes:
  sshd:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  dravoka-backrest-repo-config
    Optional:    false
  backrestrepo:
    Type:        PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
    ClaimName:   dravoka-pgbr-repo
    ReadOnly:    false
QoS Class:       Burstable
Node-Selectors:  <none>
Tolerations:     node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
                 node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:
  Type     Reason            Age                  From               Message
  ----     ------            ----                 ----               -------
  Warning  FailedScheduling  76s (x7 over 9m58s)  default-scheduler  pod has unbound immediate PersistentVolumeClaims (repeated 2 times)

Am I missing something that too is configured or doing something wrong? my purpose is to use NFS as postgres storage. Any help will be appreciated.

1

There are 1 answers

4
Nguyen Lam Phuc On

Failed to provision volume with StorageClass "standard": invalid AccessModes [ReadWriteMany]: only AccessModes [ReadWriteOnce ReadOnlyMany] are supported

So here is the root cause of the problem. You are provisioning the pvc using storage class that does not support the AccessModes that you want i.e. ReadWriteMany

Looking at the doc, seems like you have having this configuration

storage3_name: 'nfsstorage'
storage3_access_mode: 'ReadWriteMany'
storage3_size: '1G'
storage3_type: 'create'
storage3_supplemental_groups: 65534

Where the storage3_access_mode is saying that the access_mode is ReadWriteMany but this is not supported.

Please try to change it to ReadWriteOnce


Anw, Postgres requires block storage to work so even when you get the NFS setup right, your Postgres cluster will not run anyway. More explanation here