Increase persistent volumes in Kubernetes

12 July, 2022

Dominik Seidel
Dominik Seidel
Senior Systems Engineer

Dominik hat seine Ausbildung zum Fachinformatiker bei NETWAYS im Jahr 2021 abgeschlossen und arbeitet seitdem im Team "Web Services". Dort ist er mit der Betreuung und Weiterentwicklung der Plattform NETWAYS Web Services beschäftigt. In seiner Freizeit geht er gerne Wandern

by | Jul 12, 2022

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.

You need more features around volumes in Kubernetes?
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-documentroot

In 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: Bound

Further 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.

Our portfolio

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

How did you like our article?