[SHORT] Extending Kubernetes StatefulSet PVC Without Downtime
Kubernetes troubleshooting series
Problem
In Kubernetes, the size of a Persistent Volume Claim (PVC) cannot be directly updated for a Statefulset object. This limitation exists because the PVC is bound to a Persistent Volume (PV) that has a fixed capacity.
When you create a PVC for a StatefulSet, it requests a specific amount of storage capacity. This request is fulfilled by binding the PVC to an available PV that meets the capacity requirement. Once the PVC is bound to a PV, the capacity cannot be changed because it would require modifying the underlying storage resource.
Solution
To extend the size of a PVC in a StatefulSet, you generally need to follow these steps:
- Update the PVC object
Make sure that your StorageClass has ALLOWVOLUMEEXPANSION=true property
$ kubectl edit pvc# Change "storage" from both places
$ kubectl describe pvc# Now when you describe your PVC you should see the changes
2. Delete the StatefulSet object
$ kubectl delete sts --cascade=orphan# Use the flag --cascade=orphan to delete the StatefulSet and keep its pods running
3. Update the StatefulSet manifest and redeploy it
$ kubectl apply -f sts.yaml # Before applying you need to change the "storage" size as well in sts.yaml file
$ kubectl rollout restart sts# Restart the pods one at a time, the pod's PVC will be extended during the restart
Thanks for reading. I hope this short story was helpful. If you are interested, check out my other Medium articles.
👋 If you find this helpful, please click the clap 👏 button below a few times to show your support for the author 👇
🚀Join FAUN Developer Community & Get Similar Stories in your Inbox Each Week
[SHORT] Extending Kubernetes Statefulset Pvc was originally published in FAUN — Developer Community 🐾 on Medium, where people are continuing the conversation by highlighting and responding to this story.
This post first appeared on Top Digital Transformation Strategies For Business Development: How To Effectively Grow Your Business In The Digital Age, please read the originial post: here