Chapter 8. Create Persistent Storage for the Registry

The registry that you created in the previous step stores images and metadata, and uses an ephemeral volume for any pod deployment if persistent storage is not configured. This ephemeral volume is destroyed when the pod exits, losing all data, including any images built or pushed into the registry.

To configure persistent storage for the registry:

  • provision a volume that points to a storage server on your network (we will just create it on the master)
  • create a volume claim.
  • manually add the claim to the registry service.

The following steps to configure persistent storage for the registry apply to storage for any image that requires persistent data and not just for the registry. The registry is just another image in the OpenShift environment.

8.1. Provision the Persistent Volume

  1. Create a registry volume file on your master, as shown here, and call it registry-volume.yaml;

    apiVersion: v1
    kind: PersistentVolume
      name: registry-volume
        storage: 3Gi
      - ReadWriteMany
        path: /root/storage

    The folder /root/storage must exist. Make sure to change the server entry to point to your master.

  2. Create the registry persistent volume in OpenShift:

    $ oc create -f registry-volume.yaml

8.2. Create the Persistent Volume Claim

Create a claim to bind the persistent volume created earlier. This claim is what ties the registry service to the persistent volume.

  1. Create another file called registry-volume-claim.yaml:

    apiVersion: v1
    kind: PersistentVolumeClaim
      name: registry-volume-claim
        - ReadWriteMany
          storage: 3Gi
  2. Create the claim:

    $ oc create -f registry-volume-claim.yaml

You have now created the Persistent Volume and the Persistent Volume Claim, and now need to add this claim to the registry.

8.3. Add the Claim to the Registry

$ oc volume dc/docker-registry --add --overwrite -t persistentVolumeClaim --claim-name=registry-volume-claim --name=registry-storage

The docker-registry will now use the 3 GB persistent volume created above for storing image and metadata.