I have created a StorageClass and PersistentVolume but when I try to create a PersistentVolumeClaim I get the following error, "The PersistentVolumeClaim "esp-pv" is invalid: spec: Forbidden: is immutable after creation except resources.requests for bound claims". I have tried to delete the StorageClass PersistentVolume, and PersistentVolumeClaim, as other posts have suggested, and then recreate the sc, pv and pvc but I get the same error.
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: manual
provisioner: kubernetes.io/no-provisioner
#volumeBindingMode: WaitForFirstConsumer
volumeBindingMode: Immediate
allowVolumeExpansion: true
apiVersion: v1
kind: PersistentVolume
metadata:
name: esp-pv-volume # name of the pv
namespace: espkube # namespace where the p vis applied
labels:
type: local
spec:
storageClassName: manual
accessModes:
- ReadWriteMany # esp, studio and streamviewer can all write to this space
hostPath:
path: "/mnt/data/"
capacity:
storage: 10Gi # volume size requested
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: esp-pv
namespace: espkube
spec:
storageClassName: manual
accessModes:
- ReadWriteMany # esp, studio and streamviewer can all write to this space
resources:
requests:
storage: 10Gi # volume size requested
You need to comment below in PVC or PV before deleting them, else they would remain in terminating state.
finalizers:
- kubernetes.io/pv-protection
to
#finalizers:
#- kubernetes.io/pv-protection
in order to delete pvc or pv
Solved in comments, deleting a namespaced object (which is most of them) requires specifying the namespace.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With