Kubectl edit or kubectl patch expand the PersistentVolumeClaim to a capacity of . . .

Lokesh Rudra:
kubectl edit or kubectl patch expand the PersistentVolumeClaim to a capacity of 70Mi and record that change ?
After editing the PVC to capacity 70 Mi,
How to record the change and verify the recorded change

Munish Kumar Anand:
You need to pass --record=true argument at the end of your patch command

Rahul Tiwari:
@Munish Kumar Anand am unable to do that, please have a look

Rahul Tiwari:
@Tej_Singh_Rana @Mumshad Mannambeth @Mohamed Ayman please help

Munish Kumar Anand:
you patch command is wrong. use k8s documentation to look at patch command

Tej_Singh_Rana:
One of the member has described well, please have a look.
https://www.runlevl4.com/kubernetes/patching-kubernetes-resources

Tej_Singh_Rana:
Please check the option it’s available or not,

kubectl patch --help

Tej_Singh_Rana:
Reference:
https://kubernetes.io/docs/tasks/manage-kubernetes-objects/update-api-object-kubectl-patch/

Rahul Tiwari:
@Tej_Singh_Rana Thank you very much for the solution it is working for me.

Rahul Tiwari:
Also please note only dynamically provisioned pvc can be resized and the storageclass that provisions the pvc must support resize

Vishwa Seneviratne:
Do we need to know how to patch things for the exam?

Mohamed Ayman:
To resize a PVC you can use kubectl patch command so check It.

Lokesh Rudra:
@Rahul Tiwari Hey… Can you please share command

Rahul Tiwari:

kubectl patch pvc dynamic-pvc -p '{"spec":{"resources":{"requests":{"storage":"70Mi"}}}}' --record

Vishwa Seneviratne:
@Mohamed Ayman what would happen if I recreate the PVC instead of patching?
I like to theoretically compare them and understand the effect.

Mohamed Ayman:
It’s only will need to delete the PVC then resize It and create It again.

Mohamed Ayman:
Also, you can try with kubectl edit pvc pvc-name --record but only dynamically provisioned PVC can be resized and the storageclass that provisions the PVC must support resize.

I believe the pod needs to be re-created again for the changes to take place: Resizing Persistent Volumes using Kubernetes | Kubernetes

  • Once the PVC has the condition FileSystemResizePending then pod that uses the PVC can be restarted to finish file system resizing on the node. Restart can be achieved by deleting and recreating the pod or by scaling down the deployment and then scaling it up again.
  • Once file system resizing is done, the PVC will automatically be updated to reflect new size.