Home > front end >  sharing a storage class across namespaces
sharing a storage class across namespaces

Time:09-30

I've been reading through docs and can't find a clear answer on how to do this.

I have an AWS EFS claim and a storage class which i have applied. I have a PV and PVC that are in a namespace and can see the storage class, which i assume is cluster wide.

If i try to apply the same PV and PVC manifests to a different namespace i get an error that the storage class is not found.

If i then delete these i get the following warning:

warning: deleting cluster-scoped resources, not scoped to the provided namespace
persistentvolume "efs-pv" deleted

This is really confusing.

How would i share this efs storage between different namespaces? do i need to make changes to the PV and PVC (at the moment i already have persistentVolumeReclaimPolicy: Retain), and what do i apply to which namespace? what is cluster wide and what is namespace scoped?

CodePudding user response:

PV‘s are non namespaced and PVC‘s are namespaced. So you can not easy use the same PV (where the data is) in two different namespaces, because it‘s not possible to have to claims for one PV.

CodePudding user response:

Presumed you can do aws efs describe-file-systems to see your EFS is correctly configured and you have the FileSystemId ready for mount.

You have also installed the AWS EFS CSI driver and all driver pods are running with no issue.

For StorageClass you only create once for each type.

For PersistentVolume you only create once for each mount point (static).

In case of simultaneous access from different namespaces, you create one PersistentVolumeClaim in each namespace that referred the same StorageClass.

...
kind: StorageClass
metadata:
  name: my-efs-sc    <--- This name MUST be referred across PVC/PC
provisioner: efs.csi.aws.com    <--- MUST have EFS CSI driver installed

...
kind: PersistentVolume
spec:
  storageClassName: my-efs-sc    <--- Have you verify the name?
  ...
  accessModes:
  - ReadWriteMany    <--- MUST use this mode
  ...

kind: PersistentVolumeClaim
metadata:
  ...
  namespace: my-namespace-A    <--- namespace scope
spec:
  storageClassName: my-efs-sc    <--- Have you verify the name?
  accessModes:
    - ReadWriteMany    <--- MUST use this mode
  ...

kind: PersistentVolumeClaim
metadata:
  ...
  namespace: my-namespace-B    <--- namespace scope
spec:
  storageClassName: my-efs-sc    <--- Have you verify the name?
  accessModes:
    - ReadWriteMany    <--- MUST use this mode
  ...

Check the PVC/PV status with kubectl to ensure all are bound correctly.

  • Related