Kahibaro
Discord Login Register

9.2 Persistent Volumes

Concept and Role of Persistent Volumes

In OpenShift, a PersistentVolume (PV) is a cluster-scoped storage resource that represents a piece of storage in the cluster. It is:

Conceptually, a PV is to storage what a Node is to compute: a resource that can be consumed but is not owned by a specific application.

Key properties of PVs:

PersistentVolume Object Structure

A PersistentVolume is defined as a Kubernetes resource with apiVersion, kind, metadata, spec, and status. The most important fields in spec are:

Example (static NFS-backed PV):

apiVersion: v1
kind: PersistentVolume
metadata:
  name: pv-nfs-example
spec:
  capacity:
    storage: 20Gi
  accessModes:
  - ReadWriteMany
  persistentVolumeReclaimPolicy: Retain
  storageClassName: nfs-manual
  nfs:
    server: nfs-server.example.com
    path: /exports/data

This illustrates that:

Access Modes

Access modes describe how a PV can be mounted by Pods. Common modes you’ll see in OpenShift:

Which modes are available depends on the storage backend and driver. For example, many cloud block volumes only support ReadWriteOnce, whereas shared file systems or file-based CSI drivers may support ReadWriteMany.

Volume Modes: Filesystem vs Block

PVs can expose storage to Pods in two main modes:

Example snippet:

volumeMode: Block
accessModes:
- ReadWriteOnce
capacity:
  storage: 100Gi

In OpenShift, not every storage backend supports Block mode. You must ensure that the underlying storage and CSI driver support it.

Static vs Dynamic PV Provisioning

OpenShift clusters can expose PVs using two patterns:

Static Provisioning

With static provisioning, administrators pre-create PersistentVolumes that refer to existing storage.

Characteristics:

Static provisioning is useful when:

Dynamic Provisioning (via StorageClasses)

Dynamic provisioning is usually preferred in OpenShift:

In dynamic provisioning:

From the PV perspective, dynamic provisioning means:

Binding: Matching PVs and PVCs

PersistentVolumes are not used directly by Pods. Instead, Pods use PVCs, which the cluster matches to PVs. The binding is based on:

Binding behavior:

Administrators should ensure there is a reasonable pool or mechanism (dynamic provisioning) so legitimate PVCs find matching PVs.

Reclaim Policies

The persistentVolumeReclaimPolicy determines what happens to the underlying storage when the PVC is deleted. Common policies:

Choosing a policy:

Lifecycle States of a PersistentVolume

PVs move through several phases:

Understanding these phases helps operators track storage usage and cleanup needs in an OpenShift cluster.

Common PersistentVolume Backends in OpenShift

While the exact options depend on your environment and installed Operators/CSI drivers, typical PV backends include:

From the PV perspective, each backend is configured in a backend-specific stanza (nfs, csi, etc.), but all appear as PersistentVolume objects to users and workloads.

Security and Access Control Considerations

While detailed security topics are covered elsewhere, a few PV-specific concerns matter in OpenShift:

Administrators should verify that PV configuration matches both security policies and workload requirements.

Operational Practices for Persistent Volumes

From an OpenShift operations perspective, some recurring tasks around PVs include:

By treating PVs as managed infrastructure resources rather than ad hoc directories or disks, OpenShift provides a predictable and auditable storage layer for stateful applications.

Summary

PersistentVolumes in OpenShift:

Subsequent chapters will focus on how applications request these PVs using PersistentVolumeClaims and how StorageClasses and dynamic provisioning simplify day-to-day usage.

Views: 58

Comments

Please login to add a comment.

Don't have an account? Register now!