<p>I want to resize Kubernetes Persistent Volume. So I tried by editing</p>
<pre><code>kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: postgres-pvc
  labels:
    app: postgres
spec:
  storageClassName: aws-gp2
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 50Gi
</code></pre>
<p>But I got error following error</p>
<pre><code>error: persistentvolumeclaims &quot;postgres-pvc&quot; could not be patched: persistentvolumeclaims &quot;postgres-pvc&quot; is forbidden: only dynamically provisioned pvc can be resized and the storageclass that provisions the pvc must support resize
</code></pre>
<p>Then I went to AWS console and resized the PVC to 50GB. Now I see volume size to 50GB</p>
<pre><code>root@postgres-8654848bb4-6897j:/# lsblk
NAME          MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
nvme0n1       259:0    0  100G  0 disk
├─nvme0n1p1   259:1    0  100G  0 part /etc/hosts
└─nvme0n1p128 259:2    0    1M  0 part
nvme1n1       259:3    0    5G  0 disk
nvme2n1       259:4    0    5G  0 disk
nvme3n1       259:5    0    5G  0 disk
nvme4n1       259:6    0    1G  0 disk
nvme5n1       259:7    0    5G  0 disk
nvme6n1       259:8    0   50G  0 disk /var/lib/postgresql/data
nvme7n1       259:9    0    1G  0 disk
nvme8n1       259:10   0    1G  0 disk
nvme9n1       259:11   0  200G  0 disk
</code></pre>
<p>But its not reflecting in <code>df -h</code></p>
<pre><code>root@postgres-8654848bb4-6897j:/# df -h
Filesystem      Size  Used Avail Use% Mounted on
overlay         100G   30G   71G  30% /
tmpfs            64M     0   64M   0% /dev
tmpfs           3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/nvme0n1p1  100G   30G   71G  30% /etc/hosts
shm              64M  236K   64M   1% /dev/shm
/dev/nvme6n1    9.7G  8.8G  930M  91% /var/lib/postgresql/data
tmpfs           7.0G   12K  7.0G   1% /run/secrets/kubernetes.io/serviceaccount
tmpfs           3.9G     0  3.9G   0% /proc/acpi
tmpfs           3.9G     0  3.9G   0% /sys/firmware
</code></pre>
<p>Then I tried <code>resize2fs</code> command but got following error</p>
<pre><code>root@postgres-8654848bb4-6897j:/# resize2fs /dev/nvme6n1
resize2fs 1.46.2 (28-Feb-2021)
open: No such file or directory while opening /dev/nvme6n1

root@postgres-8654848bb4-6897j:/# resize2fs /var/lib/postgresql/data
resize2fs 1.46.2 (28-Feb-2021)
open: Is a directory while opening /var/lib/postgresql/data
</code></pre>
<p>Any help with this here ?</p>

roy
<p>Easiest way you can use the <strong>allowVolumeExpansion</strong> in <strong>StorageClass</strong> , i did for <strong>Elasticsearch</strong> Database</p>
<p>Checkout my article on that : <a href="https://medium.com/@harsh.manvar111/resizing-pvc-disk-in-gke-c5b882c90f7b" rel="nofollow noreferrer">https://medium.com/@harsh.manvar111/resizing-pvc-disk-in-gke-c5b882c90f7b</a></p>
<p><strong>strogeclasss</strong></p>
<pre><code>apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
 …
provisioner: kubernetes.io/gce-pd
allowVolumeExpansion: true
</code></pre>
<p>Update <strong>PVC</strong> after this with the <strong>desired size</strong> you are looking forward to keep and <strong>restart</strong> the <strong>POD</strong>.</p>
