Persistent volumes

Warning-label

This version of Rahti is deprecated. The projects need to be migrated from Rahti 1 platform to the new Rahti 2 production platform by June 2024. Please consult the migration guide for more information.

Persistent volumes are storage which persist during & after pod's lifetime.

Persistent volumes in Rahti 1 are stored in a resilient storage such as CEPH, NFS or GlusterFS. They are claimed by a pod using a PersistentVolumeClaim. When a new claim is made, this can mean that either an existing volume is claimed or a new one is created dynamically and given to the pod to use.

There are two storage classes available in Rahti 1:

  • glusterfs-storage. This kind of volume is a "Read Write Many" (RWX) type storage, this means multiple nodes can mount it in read and write mode. This is the default class. It is the most flexible class, as allows any pod anywhere in the cluster to read and write files. The downside is a lower performance than the next class.
  • standard-rwo. This kind is a "Read Write Once" (RWO), meaning that only one node can mount the volume (in read-write mode). It is faster than glusterfs, but it is limited to a single node.

PersistentVolumeClaim

Persistent storage is requested in the cluster using PersistentVolumeClaim objects:

pvc.yaml

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: testing-pvc
spec:
  accessModes:
  - ReadWriteMany
  resources:
    requests:
      storage: 1Gi

Above will request a 1 GiB persistent storage that can be mounted in read-write mode by multiple nodes. Other access modes are ReadWriteOnce (Only one pod can mount it read-write) and ReadOnlyMany (Multiple pods can mount read-only).

Persistent storage can be requested also via the web console.

Warning

When a volume contains a high amount of files (>15 000), the time it takes to mount and be available can be higher than 5 minutes. The more files, the more time it takes to be available.

The persistent volume can be used in a pod by specifying spec.volumes (defines the volumes to attach) and spec.containers.volumeMounts (defines where to mount the attached volumes in the container's filesystem):

pvc-pod.yaml:

apiVersion: v1
kind: Pod
metadata:
  name: mypod-vol
  labels:
    app: serveapp-vol
    pool: servepod-vol
spec:
  containers:
  - name: serve-cont
    image: "docker-registry.default.svc:5000/openshift/httpd"
    volumeMounts:
    - mountPath: /mountdata
      name: smalldisk-vol
  volumes:
  - name: smalldisk-vol
    persistentVolumeClaim:
      claimName: testing-pvc

Warning

When a Persistent Volume is deleted, the corresponding data is deleted permanently. It is highly recommended to make regular and versioned copies of the data to an independent storage system like Allas.


Last update: December 11, 2023