How to resize a gcePersistentDisk on GKE
If you’re like me and you defined your Google Persistent disk on GKE like this:
volumes:
- name: your-volume-name
gcePersistentDisk:
pdName: your-disk
fsType: ext4
Then, like me, you won’t have a partition table on this disk. Apparently it is possible to simply write to a disk without having a partition table.
To increase a persistent disk defined in this way, start by going to your Disks and increase its size:
Next, hit Save and click the link In use by. This will take you to the VM where the disk is attached to.
Next, click the SSH button to start an SSH session with the virtual machine:
On the VM, you should be able to see your attached disk with:
$ sudo df -h | grep /dev/sdb
/dev/sdb 40G 27G 13G 69% /var/lib/kubelet/plugins/kubernetes.io/gce-pd/mounts/your-disk
As you can see, it is still 40GB instead of the resized 80GB.
Next, resize it with
$ sudo resize2fs /dev/sdb
Verify its size:
$ sudo df -h | grep /dev/sdb
/dev/sdb 79G 27G 52G 35% /var/lib/kubelet/plugins/kubernetes.io/gce-pd/mounts/your-disk
That’s it! Your Kubernetes cluster should now be able to use the extra disk space.