The PersistentVolumeClaim is invalid Forbidden: spec is immutable after creation

21 views Asked by At

I am using EKS along with EFS as a storage but when i try to deploy PVC using any namespace than default namespace i get error "The PersistentVolumeClaim "ekart-volume" is invalid: spec: Forbidden: spec is immutable after creation except resources.requests and volumeAttributesClassName for bound claims" I can deploy PVC in default namespace but not any other a error occurs always. I am trying to provision EFS volume to my pods using dynamic provisioing. Any help?

Kubectl get storageclasses 
NAME     PROVISIONER       RECLAIMPOLICY   VOLUMEBINDINGMODE   ALLOWVOLUMEEXPANSION   AGE
efs-sc   efs.csi.aws.com   Delete          Immediate           false   

my PVC template as follows:---->

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: ekart-volume 
  namespace: test-ns 
  labels: 
    app: ekart-app
spec:
  resources:
    requests:
      storage: 10Gi
  volumeMode: Filesystem
  accessModes:
    - ReadWriteMany
  storageClassName: efs-sc

storage class template as follows which is by default provided by aws for dynamic provisioning.

kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: efs-sc
provisioner: efs.csi.aws.com
parameters:
  provisioningMode: efs-ap
  fileSystemId: fs-02787cc651d602587
  directoryPerms: "700"
  gidRangeStart: "1000" # optional
  gidRangeEnd: "2000" # optional
  basePath: "/dynamic_provisioning" # optional
  subPathPattern: "${.PVC.namespace}/${.PVC.name}" # optional
  ensureUniqueDirectory: "true" # optional
  reuseAccessPoint: "false" # optional

Now when i use below command i get error

kubectl apply -f ekart-PV-PVC.yaml

The PersistentVolumeClaim "ekart-volume" is invalid: spec: Forbidden: spec is immutable after creation except resources.requests and volumeAttributesClassName for bound claims
  core.PersistentVolumeClaimSpec{
        ... // 2 identical fields
        Resources:        {Requests: {s"storage": {i: {...}, s: "10Gi", Format: "BinarySI"}}},
        VolumeName:       "",
-       StorageClassName: &"gp2",
+       StorageClassName: &"efs-sc",
        VolumeMode:       &"Filesystem",
        DataSource:       nil,
        ... // 2 identical fields
  }
0

There are 0 answers