OpenShift Container Storage is now OpenShift Data Foundation starting with version 4.9.
Dieser Inhalt ist in der von Ihnen ausgewählten Sprache nicht verfügbar.
Chapter 9. Updating the Registry with Red Hat Openshift Container Storage as the Storage Back-end
OpenShift Container Platform provides an integrated registry with storage using an NFS-backed persistent volume that is automatically setup. Red Hat Openshift Container Storage allows you to replace this with a Gluster persistent volume for registry storage. This provides increased reliability, scalability and failover.
For additional information about OpenShift Container Platform and the docker-registry, see https://access.redhat.com/documentation/en-us/openshift_container_platform/3.11/html/configuring_clusters/setting-up-the-registry.
9.1. Validating the Openshift Container Platform Registry Deployment Link kopierenLink in die Zwischenablage kopiert!
To verify that the registry is properly deployed, execute the following commands:
On the master or client, execute the following command to login as the cluster admin user:
oc login
# oc loginCopy to Clipboard Copied! Toggle word wrap Toggle overflow For example:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow If you are not automatically logged into project default, then switch to it by executing the following command:
oc project default
# oc project defaultCopy to Clipboard Copied! Toggle word wrap Toggle overflow To verify that the pod is created, execute the following command:
oc get pods
# oc get podsCopy to Clipboard Copied! Toggle word wrap Toggle overflow For example:
oc get pods
# oc get pods NAME READY STATUS RESTARTS AGE docker-registry-2-mbu0u 1/1 Running 4 6d docker-registry-2-spw0o 1/1 Running 3 6d registry-console-1-rblwo 1/1 Running 3 6dCopy to Clipboard Copied! Toggle word wrap Toggle overflow To verify that the endpoints are created, execute the following command:
oc get endpoints
# oc get endpointsCopy to Clipboard Copied! Toggle word wrap Toggle overflow For example:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow To verify that the persistent volume is created, execute the following command:
oc get pv
# oc get pv NAME CAPACITY ACCESSMODES RECLAIMPOLICY STATUS CLAIM REASON AGE registry-volume 5Gi RWX Retain Bound default/registry-claim 7dCopy to Clipboard Copied! Toggle word wrap Toggle overflow To obtain the details of the persistent volume that was created for the NFS registry, execute the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
9.2. Converting the Openshift Container Platform Registry with Red Hat Openshift Container Storage Link kopierenLink in die Zwischenablage kopiert!
This section provides the steps to create a Red Hat Gluster Storage volume and use it to provide storage for the integrated registry.
Setting up a Red Hat Gluster Storage Persistent Volume
Execute the following commands to create a Red Hat Gluster Storage volume to store the registry data and create a persistent volume.
The commands must be executed in the default project.
Login to the default project:
oc project default
# oc project defaultCopy to Clipboard Copied! Toggle word wrap Toggle overflow For example:
oc project default
# oc project default Now using project "default" on server "https://cns30.rh73:8443"Copy to Clipboard Copied! Toggle word wrap Toggle overflow Execute the following command to create the gluster-registry-endpoints.yaml file:
oc get endpoints <heketi-db-storage-endpoint-name> -o yaml --namespace=<project-name> > gluster-registry-endpoints.yaml
oc get endpoints <heketi-db-storage-endpoint-name> -o yaml --namespace=<project-name> > gluster-registry-endpoints.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow NoteYou must create an endpoint for each project from which you want to utilize the Red Hat Gluster Storage registry. Hence, you will have a service and an endpoint in both the default project and the new project (storage-project) created in earlier steps.
Edit the gluster-registry-endpoints.yaml file. Change the name to gluster-registry-endpoints and remove all the other metadata, leaving everything else the same.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Execute the following command to create the endpoint:
oc create -f gluster-registry-endpoints.yaml
# oc create -f gluster-registry-endpoints.yaml endpoints "gluster-registry-endpoints" createdCopy to Clipboard Copied! Toggle word wrap Toggle overflow To verify the creation of the endpoint, execute the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Execute the following command to create the gluster-registry-service.yaml file:
oc get services <heketi-storage-endpoint-name> -o yaml --namespace=<project-name> > gluster-registry-service.yaml
oc get services <heketi-storage-endpoint-name> -o yaml --namespace=<project-name> > gluster-registry-service.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Edit the gluster-registry-service.yaml file. Change the name to gluster-registry-service and remove all the other metadata. Also, remove the specific cluster IP addresses:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Execute the following command to create the service:
oc create -f gluster-registry-service.yaml
# oc create -f gluster-registry-service.yaml services "gluster-registry-service" createdCopy to Clipboard Copied! Toggle word wrap Toggle overflow Execute the following command to verify if the service are running:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Execute the following command to obtain the fsGroup GID of the existing docker-registry pods:
export GID=$(oc get po --selector="docker-registry=default" -o go-template --template='{{printf "%.0f" ((index .items 0).spec.securityContext.fsGroup)}}')# export GID=$(oc get po --selector="docker-registry=default" -o go-template --template='{{printf "%.0f" ((index .items 0).spec.securityContext.fsGroup)}}')Copy to Clipboard Copied! Toggle word wrap Toggle overflow Execute the following command to create a volume
heketi-cli volume create --size=5 --name=gluster-registry-volume --gid=${GID}# heketi-cli volume create --size=5 --name=gluster-registry-volume --gid=${GID}Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create the persistent volume file for the Red Hat Gluster Storage volume:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Execute the following command to create the persistent volume:
oc create -f gluster-registry-volume.yaml
# oc create -f gluster-registry-volume.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Execute the following command to verify and get the details of the created persistent volume:
oc get pv/gluster-registry-volume
# oc get pv/gluster-registry-volume NAME CAPACITY ACCESSMODES RECLAIMPOLICY STATUS CLAIM REASON AGE gluster-registry-volume 5Gi RWX Retain Available 21mCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create a new persistent volume claim. Following is a sample Persistent Volume Claim that will be used to replace the existing registry-storage volume claim.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create the persistent volume claim by executing the following command:
oc create -f gluster-registry-claim.yaml
# oc create -f gluster-registry-claim.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow For example:
oc create -f gluster-registry-claim.yaml
# oc create -f gluster-registry-claim.yaml persistentvolumeclaim "gluster-registry-claim" createdCopy to Clipboard Copied! Toggle word wrap Toggle overflow Execute the following command to verify if the claim is bound:
oc get pvc/gluster-registry-claim
# oc get pvc/gluster-registry-claimCopy to Clipboard Copied! Toggle word wrap Toggle overflow For example:
oc get pvc/gluster-registry-claim
# oc get pvc/gluster-registry-claim NAME STATUS VOLUME CAPACITY ACCESSMODES AGE gluster-registry-claim Bound gluster-registry-volume 5Gi RWX 22sCopy to Clipboard Copied! Toggle word wrap Toggle overflow Make the registry read-only by executing the following command:
oc set env -n default dc/docker-registry 'REGISTRY_STORAGE_MAINTENANCE_READONLY={"enabled":true}'# oc set env -n default dc/docker-registry 'REGISTRY_STORAGE_MAINTENANCE_READONLY={"enabled":true}'Copy to Clipboard Copied! Toggle word wrap Toggle overflow To confirm the value is set to readonly, execute the following command:
oc set env -n default dc/docker-registry --list
# oc set env -n default dc/docker-registry --listCopy to Clipboard Copied! Toggle word wrap Toggle overflow If you want to migrate the data from the old registry to the Red Hat Gluster Storage registry, then execute the following commands:
NoteThese steps are optional.
Add the Red Hat Gluster Storage registry to the old registry deployment configuration (dc) by executing the following command:
oc set volume dc/docker-registry --add --name=gluster-registry-storage -m /gluster-registry -t pvc --claim-name=gluster-registry-claim
# oc set volume dc/docker-registry --add --name=gluster-registry-storage -m /gluster-registry -t pvc --claim-name=gluster-registry-claimCopy to Clipboard Copied! Toggle word wrap Toggle overflow Save the Registry pod name by executing the following command:
export REGISTRY_POD=$(oc get po --selector="docker-registry=default" -o go-template --template='{{printf "%s" ((index .items 0).metadata.name)}}')# export REGISTRY_POD=$(oc get po --selector="docker-registry=default" -o go-template --template='{{printf "%s" ((index .items 0).metadata.name)}}')Copy to Clipboard Copied! Toggle word wrap Toggle overflow Copy the data from the old registry directory to the Red Hat Gluster Storage registry directory by executing the following command:
oc rsh -T $REGISTRY_POD cp -aTv /registry/ /gluster-registry/
# oc rsh -T $REGISTRY_POD cp -aTv /registry/ /gluster-registry/Copy to Clipboard Copied! Toggle word wrap Toggle overflow Remove the Red Hat Gluster Storage registry from the old dc registry by executing the following command:
oc volume dc/docker-registry --remove --name=gluster-registry-storage
# oc volume dc/docker-registry --remove --name=gluster-registry-storageCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Replace the existing registry-storage volume with the new gluster-registry-claim PVC:
oc set volume dc/docker-registry --add --name=registry-storage -t pvc --claim-name=gluster-registry-claim --overwrite
# oc set volume dc/docker-registry --add --name=registry-storage -t pvc --claim-name=gluster-registry-claim --overwriteCopy to Clipboard Copied! Toggle word wrap Toggle overflow Make the registry read write by executing the following command:
oc set env dc/docker-registry REGISTRY_STORAGE_MAINTENANCE_READONLY-
# oc set env dc/docker-registry REGISTRY_STORAGE_MAINTENANCE_READONLY-Copy to Clipboard Copied! Toggle word wrap Toggle overflow To validate if the setting is set to read write, execute the following command:
oc set env -n default dc/docker-registry --list
# oc set env -n default dc/docker-registry --listCopy to Clipboard Copied! Toggle word wrap Toggle overflow
For more information about accessing the registry, see https://access.redhat.com/documentation/en-us/openshift_container_platform/3.11/html/configuring_clusters/setting-up-the-registry#install-config-registry-accessing.