By default OpenShift creates an internal registry with emptyDir as a volume which means that if a registry pod goes down you will loose all the data for that pod. In this article we are going to change default configuration and set PVs for images instead of the emptyDir. These steps are for my demo on-premise cloud based on VmWare.

Switch to the project openshift-image-registry
oc project openshift-image-registry

Change ManagementState Image Registry Operator configuration from Removed to Managed
oc patch configs.imageregistry.operator.openshift.io cluster --type merge --patch '{"spec":{"managementState":"Managed"}}'

Verify you do not have a registry Pod.
oc get pod -n openshift-image-registry

Create a PV

apiVersion: v1
kind: PersistentVolume
metadata:
  name: image-registry-pv
spec:
  accessModes:
    - ReadWriteMany
  capacity:
    storage: 100Gi
  nfs:
    path: /root/images
    server: 192.168.28.59
  persistentVolumeReclaimPolicy: Retain
  storageClassName: nfs01

Create a PVC

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: image-registry-pvc
spec:
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 100Gi
  storageClassName: nfs01
  volumeMode: Filesystem

Check that the PV and PVC was created
oc get pvc -n openshift-image-registry
oc get pv -n openshift-image-registry

Change imageregistry operator to use your PVC.
Open its configuration file for editing
oc edit configs.imageregistry.operator.openshift.io
find spec.storage there and set it to be like

storage:
  pvc:
    claim: image-registry-pvc

Check that a correct PVC is set
oc get configs.imageregistry.operator.openshift.io -o yaml

Check the clusteroperator status
oc get clusteroperator image-registry