Do you want to enlarge a PersistentVolume (PV) in Kubernetes? This tutorial will show you how to do this. What PVs are and how to create them is explained in the tutorial Creating persistent volumes in Kubernetes, on which this tutorial is based.
NETWAYS Managed Kubernetes offers you encryption, automated backups and snapshots, as well as different storage classes, suitable for your application.
Enlarge PV in K8s: Let’s go
Scaling up a PV in Kubernetes is not a difficult exercise. It is important to note that the PersistentVolumeClaim– and not the PersistentVolume object must be edited. The PVC object can be adapted using the command kubectl edit, for example. If you have completed the tutorial mentioned above, a PVC object with the name nginx-documentroot should exist in your cluster. We want to increase this from 1 GiB to 5 GiB.
kubectl edit pvc nginx-documentrootIn the editor that is now open, you can edit the Yaml manifest of the PVC object. To enlarge it, adjust the value at .spec.resources.requests.storage.
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
storageClassName: standard
volumeMode: Filesystem
volumeName: pvc-5b279e33-1f05-4e04-93a6-4bda24e69eb1
status:
accessModes:
- ReadWriteOnce
capacity:
storage: 5Gi
phase: BoundFurther helpful information
You have now seen how an existing PV can be expanded. To ensure that you always have an overview of the fill level of the volumes in your cluster, it is worth using the Kube Prometheus stack for monitoring purposes. If you want to be notified when a volume reaches a critical storage allocation, the Kubernetes Alerting with Prometheus tutorial may be of interest to you.





0 Comments