The most confusing aspect of using Kubernetes for me is storage. I mean, they seem so simple, but take a look at this:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: mysql-nc-pv-claim
  labels:
    app: nextcloud
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 5Gi

Here’s some questions that jump to my mind:

  • How is a Persistent Volume Claim (PVC) different than a Persistent Volume (PV)? Why do I only need a PVC sometimes?
  • What if I eventually need more than 5 gigs of storage? Can I auto resize the partition?
  • What if I wanted to browse this volume using a tool like Windows Explorer? Can I get shell access?

All of these beg the following fundamental question:

Where and on What Are My Files Stored?

Let’s assume that you applied the following PVC above and now you want to know where the heck your volume is. Your first tool is the kubectl get pvc command. Here’s some sample output from my Digital Ocean Kubernetes cluster:

~ (k8s: main) $ kubectl get pvc
NAME                 STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS       AGE
mysql-nc-pv-claim    Bound    pvc-c398aba2-cb57-48ee-a370-8f04107be38a1  5Gi        RWO            do-block-storage   3d20h

Take a look at the STORAGECLASS column. Hmm, I wonder what do-block-storage means? I guess I’ll look at the official Kubernetes docs on storage class types. That should explain everything, right?

Uhh, ok. Well, let’s see what Google tells us:

Ahh, thank goodness Digital Ocean wrote up a nice tutorial on this. That explains this specific storage class very well.

Good luck!