Configuring the registry for bare metal
Configure image registry storage for bare-metal clusters after installation. Because bare-metal installations do not automatically provision storage, you must change the registry management state from Removed to Managed and configure persistent storage or use Red Hat OpenShift Data Foundation before the registry can store container images.
Image registry removed during installation
On platforms that do not provide shareable object storage, the OpenShift Image Registry Operator bootstraps itself as Removed. This allows openshift-installer to complete installations on these platform types.
After installation, you must edit the Image Registry Operator configuration to switch the managementState from Removed to Managed. When this has completed, you must configure storage.
Changing the image registry’s management state
To start the image registry, you must change the Image Registry Operator configuration’s managementState from Removed to Managed.
-
Change
managementStateImage Registry Operator configuration fromRemovedtoManaged. For example:$ oc patch configs.imageregistry.operator.openshift.io cluster --type merge --patch '{"spec":{"managementState":"Managed"}}'
Image registry storage configuration
The Image Registry Operator is not initially available for platforms that do not provide default storage. After installation, you must configure your registry to use storage so that the Registry Operator is made available.
Configure a persistent volume, which is required for production clusters. Where applicable, you can configure an empty directory as the storage location for non-production clusters.
You can also allow the image registry to use block storage types by using the Recreate rollout strategy during upgrades.
Configuring registry storage for bare metal and other manual installations
To ensure the registry is fully operational, configure the registry to use storage immediately after the cluster installation. This configuration is a mandatory step to enable the registry to store data.
-
You have access to the cluster as a user with the
cluster-adminrole. -
You have a cluster that uses manually-provisioned Red Hat Enterprise Linux CoreOS (RHCOS) nodes, such as bare metal.
-
You have provisioned persistent storage for your cluster, such as Red Hat OpenShift Data Foundation.
Important
OpenShift Container Platform supports
ReadWriteOnceaccess for image registry storage when you have only one replica.ReadWriteOnceaccess also requires that the registry uses theRecreaterollout strategy. To deploy an image registry that supports high availability with two or more replicas,ReadWriteManyaccess is required. -
You must have a system with at least 100Gi capacity.
-
To configure your registry to use storage, change the
spec.storage.pvcin theconfigs.imageregistry/clusterresource.Note
When you use shared storage, review your security settings to prevent outside access.
-
Verify that you do not have a registry pod:
$ oc get pod -n openshift-image-registry -l docker-registry=defaultExample outputNo resources found in openshift-image-registry namespaceNote
If you do have a registry pod in your output, you do not need to continue with this procedure.
-
Check the registry configuration:
$ oc edit configs.imageregistry.operator.openshift.ioExample outputstorage: pvc: claim:Leave the
claimfield blank to allow the automatic creation of animage-registry-storagePVC. -
Check the
clusteroperatorstatus:$ oc get clusteroperator image-registryExample outputNAME VERSION AVAILABLE PROGRESSING DEGRADED SINCE MESSAGE image-registry 4.19 True False False 6h50m -
Ensure that your registry is set to managed to enable building and pushing of images.
-
Run:
$ oc edit configs.imageregistry/cluster
Then, change the line
managementState: Removed
to
managementState: Managed
-
Configuring storage for the image registry in non-production clusters
You must configure storage for the Image Registry Operator. For non-production clusters, you can set the image registry to an empty directory. If you do so, all images are lost if you restart the registry.
-
To set the image registry storage to an empty directory:
$ oc patch configs.imageregistry.operator.openshift.io cluster --type merge --patch '{"spec":{"storage":{"emptyDir":{}}}}'Warning
Configure this option only for non-production clusters.
If you run this command before the Image Registry Operator initializes its components, the
oc patchcommand fails with the following error:Error from server (NotFound): configs.imageregistry.operator.openshift.io "cluster" not foundWait a few minutes and run the command again.
Configuring block registry storage for bare metal
To allow the image registry to use block storage types during upgrades as a cluster administrator, you can use the Recreate rollout strategy.
Important
Block storage volumes, or block persistent volumes, are supported but not recommended for use with the image registry on production clusters. An installation where the registry is configured on block storage is not highly available because the registry cannot have more than one replica.
If you choose to use a block storage volume with the image registry, you must use a filesystem persistent volume claim (PVC).
-
Enter the following command to set the image registry storage as a block storage type, patch the registry so that it uses the
Recreaterollout strategy, and runs with only one (1) replica:$ oc patch config.imageregistry.operator.openshift.io/cluster --type=merge -p '{"spec":{"rolloutStrategy":"Recreate","replicas":1}}' -
Provision the PV for the block storage device, and create a PVC for that volume. The requested block volume uses the ReadWriteOnce (RWO) access mode.
-
Create a
pvc.yamlfile with the following contents to define a VMware vSpherePersistentVolumeClaimobject:kind: PersistentVolumeClaim apiVersion: v1 metadata: name: image-registry-storage namespace: openshift-image-registry spec: accessModes: - ReadWriteOnce resources: requests: storage: 100Giwhere:
name-
Specifies a unique name that represents the
PersistentVolumeClaimobject. namespace-
Specifies the
namespacefor thePersistentVolumeClaimobject, which isopenshift-image-registry. accessModes-
Specifies the access mode of the persistent volume claim. With
ReadWriteOnce, the volume can be mounted with read and write permissions by a single node. storage-
The size of the persistent volume claim.
-
Enter the following command to create the
PersistentVolumeClaimobject from the file:$ oc create -f pvc.yaml -n openshift-image-registry
-
-
Enter the following command to edit the registry configuration so that it references the correct PVC:
$ oc edit config.imageregistry.operator.openshift.io -o yamlExample outputstorage: pvc: claim:By creating a custom PVC, you can leave the
claimfield blank for the default automatic creation of animage-registry-storagePVC.
Configuring the Image Registry Operator to use Ceph RGW storage with Red Hat OpenShift Data Foundation
Red Hat OpenShift Data Foundation integrates multiple storage types that you can use with the OpenShift image registry:
-
Ceph, a shared and distributed file system and on-premise object storage
-
NooBaa, providing a Multicloud Object Gateway
Use the following, procedure to configure the image registry to use Ceph RGW storage.
-
You have access to the cluster as a user with the
cluster-adminrole. -
You have access to the OpenShift Container Platform web console.
-
You installed the
ocCLI. -
You installed the OpenShift Data Foundation Operator to provide object storage and Ceph RGW object storage.
-
Create the object bucket claim using the
ocs-storagecluster-ceph-rgwstorage class. For example:cat <<EOF | oc apply -f - apiVersion: objectbucket.io/v1alpha1 kind: ObjectBucketClaim metadata: name: rgwbucket namespace: openshift-storage spec: storageClassName: ocs-storagecluster-ceph-rgw generateBucketName: rgwbucket EOFAlternatively, you can use the
openshift-image-registryfor thenamespacevalue. -
Get the bucket name by entering the following command:
$ bucket_name=$(oc get obc -n openshift-storage rgwbucket -o jsonpath='{.spec.bucketName}') -
Get the AWS credentials by entering the following commands:
$ AWS_ACCESS_KEY_ID=$(oc get secret -n openshift-storage rgwbucket -o jsonpath='{.data.AWS_ACCESS_KEY_ID}' | base64 --decode)$ AWS_SECRET_ACCESS_KEY=$(oc get secret -n openshift-storage rgwbucket -o jsonpath='{.data.AWS_SECRET_ACCESS_KEY}' | base64 --decode) -
Create the secret
image-registry-private-configuration-userwith the AWS credentials for the new bucket underopenshift-image-registry projectby entering the following command:$ oc create secret generic image-registry-private-configuration-user --from-literal=REGISTRY_STORAGE_S3_ACCESSKEY=${AWS_ACCESS_KEY_ID} --from-literal=REGISTRY_STORAGE_S3_SECRETKEY=${AWS_SECRET_ACCESS_KEY} --namespace openshift-image-registry -
Get the
routehost by entering the following command:$ route_host=$(oc get route ocs-storagecluster-cephobjectstore -n openshift-storage --template='{{ .spec.host }}') -
Create a config map that uses an ingress certificate by entering the following commands:
$ oc extract secret/$(oc get ingresscontroller -n openshift-ingress-operator default -o json | jq '.spec.defaultCertificate.name // "router-certs-default"' -r) -n openshift-ingress --confirm$ oc create configmap image-registry-s3-bundle --from-file=ca-bundle.crt=./tls.crt -n openshift-config -
Configure the image registry to use the Ceph RGW object storage by entering the following command:
$ oc patch config.image/cluster -p '{"spec":{"managementState":"Managed","replicas":2,"storage":{"managementState":"Unmanaged","s3":{"bucket":'\"${bucket_name}\"',"region":"us-east-1","regionEndpoint":'\"https://${route_host}\"',"virtualHostedStyle":false,"encrypt":false,"trustedCA":{"name":"image-registry-s3-bundle"}}}}}' --type=merge
Configuring the Image Registry Operator to use Noobaa storage with Red Hat OpenShift Data Foundation
Red Hat OpenShift Data Foundation integrates multiple storage types that you can use with the OpenShift image registry:
-
Ceph, a shared and distributed file system and on-premise object storage
-
NooBaa, providing a Multicloud Object Gateway
Use the following the procedure to configure the image registry to use Noobaa storage.
-
You have access to the cluster as a user with the
cluster-adminrole. -
You have access to the OpenShift Container Platform web console.
-
You installed the
ocCLI. -
You installed the OpenShift Data Foundation Operator to provide object storage and Noobaa object storage.
-
Create the object bucket claim using the
openshift-storage.noobaa.iostorage class. For example:cat <<EOF | oc apply -f - apiVersion: objectbucket.io/v1alpha1 kind: ObjectBucketClaim metadata: name: noobaatest namespace: openshift-storage spec: storageClassName: openshift-storage.noobaa.io generateBucketName: noobaatest EOFAlternatively, you can use the
openshift-image-registryfor thenamespacevalue. -
Get the bucket name by entering the following command:
$ bucket_name=$(oc get obc -n openshift-storage noobaatest -o jsonpath='{.spec.bucketName}') -
Get the AWS credentials by entering the following commands:
$ AWS_ACCESS_KEY_ID=$(oc get secret -n openshift-storage noobaatest -o yaml | grep -w "AWS_ACCESS_KEY_ID:" | head -n1 | awk '{print $2}' | base64 --decode)$ AWS_SECRET_ACCESS_KEY=$(oc get secret -n openshift-storage noobaatest -o yaml | grep -w "AWS_SECRET_ACCESS_KEY:" | head -n1 | awk '{print $2}' | base64 --decode) -
Create the secret
image-registry-private-configuration-userwith the AWS credentials for the new bucket underopenshift-image-registry projectby entering the following command:$ oc create secret generic image-registry-private-configuration-user --from-literal=REGISTRY_STORAGE_S3_ACCESSKEY=${AWS_ACCESS_KEY_ID} --from-literal=REGISTRY_STORAGE_S3_SECRETKEY=${AWS_SECRET_ACCESS_KEY} --namespace openshift-image-registry -
Get the route host by entering the following command:
$ route_host=$(oc get route s3 -n openshift-storage -o=jsonpath='{.spec.host}') -
Create a config map that uses an ingress certificate by entering the following commands:
$ oc extract secret/$(oc get ingresscontroller -n openshift-ingress-operator default -o json | jq '.spec.defaultCertificate.name // "router-certs-default"' -r) -n openshift-ingress --confirm$ oc create configmap image-registry-s3-bundle --from-file=ca-bundle.crt=./tls.crt -n openshift-config -
Configure the image registry to use the Nooba object storage by entering the following command:
$ oc patch config.image/cluster -p '{"spec":{"managementState":"Managed","replicas":2,"storage":{"managementState":"Unmanaged","s3":{"bucket":'\"${bucket_name}\"',"region":"us-east-1","regionEndpoint":'\"https://${route_host}\"',"virtualHostedStyle":false,"encrypt":false,"trustedCA":{"name":"image-registry-s3-bundle"}}}}}' --type=merge
Configuring the Image Registry Operator to use CephFS storage with Red Hat OpenShift Data Foundation
Red Hat OpenShift Data Foundation integrates multiple storage types that you can use with the OpenShift image registry:
-
Ceph, a shared and distributed file system and on-premise object storage
-
NooBaa, providing a Multicloud Object Gateway
Use the following procedure to configure the image registry to use CephFS storage.
Note
CephFS uses persistent volume claim (PVC) storage. It is not recommended to use PVCs for image registry storage if there are other options are available, such as Ceph RGW or Noobaa.
-
You have access to the cluster as a user with the
cluster-adminrole. -
You have access to the OpenShift Container Platform web console.
-
You installed the
ocCLI. -
You installed the OpenShift Data Foundation Operator to provide object storage and CephFS file storage.
-
Create a PVC to use the
cephfsstorage class. For example:cat <<EOF | oc apply -f - apiVersion: v1 kind: PersistentVolumeClaim metadata: name: registry-storage-pvc namespace: openshift-image-registry spec: accessModes: - ReadWriteMany resources: requests: storage: 100Gi storageClassName: ocs-storagecluster-cephfs EOF -
Configure the image registry to use the CephFS file system storage by entering the following command:
$ oc patch config.image/cluster -p '{"spec":{"managementState":"Managed","replicas":2,"storage":{"managementState":"Unmanaged","pvc":{"claim":"registry-storage-pvc"}}}}' --type=merge