0
0
Kubernetesdevops~15 mins

PersistentVolume (PV) definition in Kubernetes - Mini Project: Build & Apply

Choose your learning style9 modes available
PersistentVolume (PV) definition
📖 Scenario: You are setting up storage for a Kubernetes cluster. You need to create a PersistentVolume (PV) that pods can use to store data persistently, even if the pod restarts or moves.
🎯 Goal: Create a Kubernetes PersistentVolume (PV) YAML definition with specific storage capacity and access mode.
📋 What You'll Learn
Create a PersistentVolume named pv-demo
Set the storage capacity to 5Gi
Use the access mode ReadWriteOnce
Use hostPath as the storage backend with path /mnt/data
💡 Why This Matters
🌍 Real World
PersistentVolumes provide stable storage for applications running in Kubernetes, so data is not lost when pods restart or move.
💼 Career
Understanding PersistentVolumes is essential for Kubernetes administrators and DevOps engineers managing stateful applications.
Progress0 / 4 steps
1
Create the PersistentVolume skeleton
Create a YAML file with apiVersion set to v1, kind set to PersistentVolume, and metadata.name set to pv-demo.
Kubernetes
Need a hint?

Start by defining the basic structure of a PersistentVolume YAML.

2
Add storage capacity and access mode
Add a spec section with capacity.storage set to 5Gi and accessModes set to ReadWriteOnce.
Kubernetes
Need a hint?

Use spec.capacity.storage and spec.accessModes fields.

3
Add hostPath volume source
Inside spec, add hostPath with path set to /mnt/data.
Kubernetes
Need a hint?

The hostPath field defines the directory on the node to use for storage.

4
Display the complete PersistentVolume YAML
Print the complete YAML content of the PersistentVolume named pv-demo.
Kubernetes
Need a hint?

Review the full YAML to confirm all parts are included.