For Longhorn you can only increase the PVC size, not decrease.
in short, just update PVC spec.resources.requests.storage
This is how:
$ k get pvc
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
mysql-pv-claim Bound pvc-ce5dc81a-6fc7-4b9f-aa3d-0fcf89ff5432 5Gi RWO longhorn 20s$ k exec -it deploy/wordpress-mysql -- df -h /var/lib/mysql
Filesystem Size Used Avail Use% Mounted on
/dev/longhorn/pvc-ce5dc81a-6fc7-4b9f-aa3d-0fcf89ff5432 4.9G 136M 4.8G 3% /var/lib/mysql$ k scale --replicas=0 deploy/wordpress-mysql
deployment.apps/wordpress-mysql scaled$ k patch pvc mysql-pv-claim -p '{ "spec": { "resources": { "requests": { "storage": "7Gi" }}}}'
persistentvolumeclaim/mysql-pv-claim patched$ k describe pvc mysql-pv-claim |tail -10
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal ExternalProvisioning 4m12s (x2 over 4m12s) persistentvolume-controller waiting for a volume to be created, either by external provisioner "driver.longhorn.io" or manually created by system administrator
Normal Provisioning 4m12s driver.longhorn.io_csi-provisioner-6ccbfbf86f-mhrqg_2c7b1fd4-2801-4e4a-a694-dfe2407f3bb2 External provisioner is provisioning volume for claim "default/mysql-pv-claim"
Normal ProvisioningSucceeded 4m10s driver.longhorn.io_csi-provisioner-6ccbfbf86f-mhrqg_2c7b1fd4-2801-4e4a-a694-dfe2407f3bb2 Successfully provisioned volume pvc-ce5dc81a-6fc7-4b9f-aa3d-0fcf89ff5432
Warning ExternalExpanding 22s volume_expand Ignoring the PVC: didn't find a plugin capable of expanding the volume; waiting for an external controller to process this PVC.
Normal Resizing 22s external-resizer driver.longhorn.io External resizer is resizing volume pvc-ce5dc81a-6fc7-4b9f-aa3d-0fcf89ff5432
Normal VolumeResizeSuccessful 8s external-resizer driver.longhorn.io Resize volume succeeded$ k scale --replicas=1 deploy/wordpress-mysql
deployment.apps/wordpress-mysql scaled
$ k exec -it deploy/wordpress-mysql -- df -h /var/lib/mysql
Filesystem Size Used Avail Use% Mounted on
/dev/longhorn/pvc-ce5dc81a-6fc7-4b9f-aa3d-0fcf89ff5432 6.9G 139M 6.7G 2% /var/lib/mysql
This process will take some time, wait for message “Resize volume succeeded”
That is all