Technotes

Technotes for future me

Check PVC usage

To check the usage of a PVC, you can use the following debug pod:

vi volume-size-debugger.yaml
---
kind: Pod
apiVersion: v1
metadata:
  name: volume-size-debugger
  namespace: kasten-io
spec:
  volumes:
  - name: debug-pv
    persistentVolumeClaim:
      claimName: catalog-pv-claim # <--- Change this to your PVC name
  containers:
  - name: debugger
    image: busybox
    command: ["sleep", "3600"]
    volumeMounts:
    - mountPath: "/data"
      name: debug-pv

Apply the pod:

kubectl apply -f volume-size-debugger.yaml

Check the usage:

kubectl exec -it -n kasten-io volume-size-debugger -- sh

df -ah /data

/ # df -ah /data
Filesystem                Size      Used Available Use% Mounted on
/dev/pxd/pxd142394256216632868
                         44.1G     16.9G     25.2G  40% /data
/ #

When you are done, you can delete the pod:

kubectl delete pod -n kasten-io volume-size-debugger

If you need to update the PVC size, you can use the following command:

kubectl edit pvc -n kasten-io catalog-pv-claim

If you get the error Only dynamically provisioned pvc can be resized and the storageclass that provisions the pvc must support resize, you need to update the storage class and add/set the following attribute:

allowVolumeExpansion: true

kubectl edit sc <storage_class_name>
---
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  annotations:
    storageclass.kubernetes.io/is-default-class: "true"
  name: portworx-sc
parameters:
  repl: "1"
provisioner: kubernetes.io/portworx-volume
reclaimPolicy: Delete
volumeBindingMode: Immediate
allowVolumeExpansion: true

Once the YAML file is modified, try to perform the resize of the PVC once again

Source:
https://kubernetes.io/docs/concepts/storage/persistent-volumes/#expanding-persistent-volumes-claims
https://kubernetes.io/docs/concepts/storage/storage-classes/

Last updated on 20 Oct 2023
Published on 16 Apr 2021
Edit on GitHub