Skip to content

Storage

Configure persistent storage for your applications using Persistent Volume Claims (PVCs) and Storage Classes.

Introduction

Persistent storage allows your applications to store data that survives pod restarts and rescheduling. OpenShift uses Persistent Volume Claims (PVCs) to request storage resources.

Storage Classes

Storage classes define the type of storage available in your cluster. Different storage classes can offer different performance characteristics, backup policies, or underlying storage technologies.

Your cluster comes with one storage class available out of the box:

# View available storage classes
oc get storageclass

# The default storage class
NAME                         PROVISIONER
kubevirt-csi-infra-default   csi.kubevirt.io

Complete Example: Redis with Storage

# pvc.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: redis-storage
  namespace: my-app
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 5Gi
  storageClassName: kubevirt-csi-infra-default
---
# deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: redis
  namespace: my-app
spec:
  replicas: 1
  selector:
    matchLabels:
      app: redis
  template:
    metadata:
      labels:
        app: redis
    spec:
      containers:
      - name: redis
        image: redis:7-alpine
        ports:
        - containerPort: 6379
        volumeMounts:
        - name: redis-data
          mountPath: /data
      volumes:
      - name: redis-data
        persistentVolumeClaim:
          claimName: redis-storage

Storage Persistence

Data stored in PVCs persists even when pods are deleted or rescheduled. Only deleting the PVC itself will remove the data.

Next Steps

Now that you understand storage:

  • Secrets - For sensitive configuration data
  • ConfigMaps - For application configuration