This documentation is for a release that is no longer maintained
See documentation for the latest supported version 3 or the latest supported version 4.Questo contenuto non è disponibile nella lingua selezionata.
6.2. Converting the Openshift Container Platform Registry with Container-Native Storage
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.
Note
The commands must be executed in the
default
project.
- Login to the
default
project:oc project default
# oc project default
Copy 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-storage-endpoints -o yaml --namespace=storage-project > gluster-registry-endpoints.yaml
# oc get endpoints heketi-storage-endpoints -o yaml --namespace=storage-project > gluster-registry-endpoints.yaml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Note
You 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 thedefault
project and the new project (storage-project
) created in earlier steps. - Edit the
gluster-registry-endpoints.yaml
file. Remove all the metadata except forname
, 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" created
Copy 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-endpoints -o yaml --namespace=storage-project > gluster-registry-service.yaml
# oc get services heketi-storage-endpoints -o yaml --namespace=storage-project > gluster-registry-service.yaml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Edit the
gluster-registry-service.yaml
file. Remove all the metadata except for name. 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" created
Copy 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.yaml
Copy 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 21m
Copy 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.yaml
Copy 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" created
Copy 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-claim
Copy 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 22s
Copy 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:
Note
These steps are optional.- Make the old registry readonly by executing the following command:
oc set env dc/docker-registry REGISTRY_STORAGE_MAINTENANCE_READONLY_ENABLED=true
# oc set env dc/docker-registry REGISTRY_STORAGE_MAINTENANCE_READONLY_ENABLED=true
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Add the Red Hat Gluster Storage registry to the old registry deployment configuration (dc) by executing the following command:
oc volume dc/docker-registry --add --name=gluster-registry-storage -m /gluster-registry -t pvc --claim-name=gluster-registry-claim
# oc volume dc/docker-registry --add --name=gluster-registry-storage -m /gluster-registry -t pvc --claim-name=gluster-registry-claim
Copy 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 - Run rsync of data from old registry to the Red Hat Gluster Storage registry by executing the following command:
oc rsync $REGISTRY_POD:/registry/ $REGISTRY_POD:/gluster-registry/
# oc rsync $REGISTRY_POD:/registry/ $REGISTRY_POD:/gluster-registry/
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Remove the Red Hat Gluster Storage registry form 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-storage
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Swap the existing registry storage volume for the new Red Hat Gluster Storage volume by executing the following command:
oc volume dc/docker-registry --add --name=registry-storage -t pvc --claim-name=gluster-registry-claim --overwrite
# oc volume dc/docker-registry --add --name=registry-storage -t pvc --claim-name=gluster-registry-claim --overwrite
Copy 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_ENABLED-
# oc set env dc/docker-registry REGISTRY_STORAGE_MAINTENANCE_READONLY_ENABLED-
Copy 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.5/html-single/installation_and_configuration/#install-config-registry-accessing.