If that post title isn't a mouthful...
I'm excited to be moving a few EKS clusters into real-world production use after a few months of preparation. Besides my Raspberry Pi Dramble project (which is pretty low-key), these are the only production-grade Kubernetes clusters I've dealt with—and I've learned a lot. Enough that I'm working on a new book.
Anyways, back to the main topic: As of Kubernetes 1.11, you can auto-expand PVs from most cloud providers, AWS included. And since EKS now runs Kubernetes 1.11.x, you can have your EBS PVs automatically expand by just increasing the PVC claim size in
spec.resources.requests.storage to a larger size (e.g.
To make sure this works, though, you need to make sure of a few things:
Make sure you have the proper setting on your StorageClass
You need to make sure the StorageClass you're using has the
allowVolumeExpansion setting enabled, e.g.:
Edit your PVC
Increase the storage request of your PVC (note that you cannot decrease the request... that's a lot weirder a use case and is not something trivial to do on most storage systems!) by editing the pvc:
$ kubectl edit pvc -n [namespace] [claim-name]
storage: 20Gi # increased from 10Gi
Save the edit, then wait, and monitor the PV associated with the PVC:
$ kubectl get pv pvc-d2adc816-d0c7-11e8-80aa-0ef7083fecf8 --watch
Once it's done, you're ready for the final step!
Delete/restart the Pod(s) which mount the PVC
This may seem unintuitive, but in order for Kubernetes to expand the actual volume on the disk to fill the newly-available free space, it has to detach the volume (so the running Pod has to be terminated), then it expands the PVC, then it attaches it to a new Pod:
$ kubectl delete pod -n [namespace] [pod identifier]
After a minute or two (or longer if the volume is huge), the new pod should be up with the now-larger PVC attached.
No need to use
fdisk or anything arcane like that... just make the claim request larger, wait for it to expand, then delete pods using it, and things come back with the new larger size. Nice!