Course contentsShow
← Cloud and Infrastructure
Lesson 1298 of 2,98926. Kubernetes StorageFree lesson

Mounting PVCs in Pods

Configuring Pod specs to use PVCs as volumes and mount them into container filesystems.

Mounting PVCs in Pods

What you'll learn: How to configure Pods to use PersistentVolumeClaims as volumes and mount them into container filesystems.


The Connection Point

You've created a PersistentVolumeClaim (PVC), and it's bound to a PersistentVolume (PV). Now you need to actually use that storage in your application. This is where Pod specs come in—you configure them to reference the PVC and specify where inside the container that storage should appear.

Think of it like reserving a storage locker (PVC) and then receiving a key. Mounting the PVC in a Pod is like using that key to actually access your locker and deciding which shelf to place your belongings on.

How It Works

In your Pod specification, you declare the PVC under the volumes section, giving it a name. Then, in each container's volumeMounts section, you reference that volume name and specify the mountPath—the directory inside the container where the storage will be accessible.

Basic structure:

apiVersion: v1
kind: Pod
metadata:
  name: my-app
spec:
  volumes:
  - name: my-storage
    persistentVolumeClaim:
      claimName: my-pvc
  containers:
  - name: app-container
    image: nginx
    volumeMounts:
    - name: my-storage
      mountPath: /usr/share/nginx/html

Here, the PVC my-pvc is mounted at /usr/share/nginx/html inside the container. Any data written there persists beyond the container's lifetime.

Why This Matters

Without mounting, your PVC is useless—it's reserved storage sitting idle. Mounting makes that storage part of your container's filesystem, enabling persistent data storage for databases, user uploads, configuration files, and more.

Key Takeaway: Mounting PVCs in Pods bridges the gap between storage provisioning and application usage—you reference the PVC name in the Pod's volumes section and specify the container path in volumeMounts.