Persistent Volume Claim shared with other namespaces

Solution Verified - Updated -

Environment

  • OpenShift Dedicated/OSD
  • Red Hat OpenShift Service on AWS Online/ROSA
    • 4.x

Issue

  • Can Persistent Volume Claim share with other namespaces?
  • Would like to share PVCs across multiple namespaces.

Resolution

PVCs are specific to a project and are created and used by developers as a means to use a PV. PV resources on their own are not scoped to any single project; they can be shared across the entire OpenShift Container Platform cluster and claimed from any project. After a PV is bound to a PVC, that PV can not then be bound to additional PVCs. This has the effect of scoping a bound PV to a single namespace, that of the binding project Persistent storage overview

In conclusion , the approach of using PVCs (or PVs) across multiple namespaces is not supported.

Instead, you can try to configure the NFS volume at pod (or deployment) level as this example:

kind: Pod
apiVersion: v1
metadata:
  name: example-nfs
  namespace: example
spec:
  volumes:
    - name: nfs-volume
      nfs: 
        server: SERVER_IP
        path: /
  containers:
    - name: app
      image: alpine
      volumeMounts:
        - name: nfs-volume
          mountPath: /tmp/nfs

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments