Questo contenuto non è disponibile nella lingua selezionata.
Chapter 19. Migrating a standalone Red Hat Quay deployment to a Red Hat Quay Operator deployment
The following procedures allow you to back up a standalone Red Hat Quay deployment and migrate it to the Red Hat Quay Operator on OpenShift Container Platform.
19.1. Backing up a standalone deployment of Red Hat Quay
Procedure
- Back up the - config.yamlof your standalone Red Hat Quay deployment:- mkdir /tmp/quay-backup cp /path/to/Quay/config/directory/config.yaml /tmp/quay-backup - $ mkdir /tmp/quay-backup $ cp /path/to/Quay/config/directory/config.yaml /tmp/quay-backup- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Create a backup of the database that your standalone Red Hat Quay deployment is using: - pg_dump -h DB_HOST -p 5432 -d QUAY_DATABASE_NAME -U QUAY_DATABASE_USER -W -O > /tmp/quay-backup/quay-database-backup.sql - $ pg_dump -h DB_HOST -p 5432 -d QUAY_DATABASE_NAME -U QUAY_DATABASE_USER -W -O > /tmp/quay-backup/quay-database-backup.sql- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Install the AWS CLI if you do not have it already.
- Create an - ~/.aws/directory:- mkdir ~/.aws/ - $ mkdir ~/.aws/- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Obtain the - access_keyand- secret_keyfrom the- config.yamlof your standalone deployment:- grep -i DISTRIBUTED_STORAGE_CONFIG -A10 /tmp/quay-backup/config.yaml - $ grep -i DISTRIBUTED_STORAGE_CONFIG -A10 /tmp/quay-backup/config.yaml- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - Example output: - Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Store the - access_keyand- secret_keyfrom the- config.yamlfile in your- ~/.awsdirectory:- touch ~/.aws/credentials - $ touch ~/.aws/credentials- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Optional: Check that your - access_keyand- secret_keyare stored:- cat > ~/.aws/credentials << EOF [default] aws_access_key_id = ACCESS_KEY_FROM_QUAY_CONFIG aws_secret_access_key = SECRET_KEY_FROM_QUAY_CONFIG EOF - $ cat > ~/.aws/credentials << EOF [default] aws_access_key_id = ACCESS_KEY_FROM_QUAY_CONFIG aws_secret_access_key = SECRET_KEY_FROM_QUAY_CONFIG EOF- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - Example output: - aws_access_key_id = ACCESS_KEY_FROM_QUAY_CONFIG aws_secret_access_key = SECRET_KEY_FROM_QUAY_CONFIG - aws_access_key_id = ACCESS_KEY_FROM_QUAY_CONFIG aws_secret_access_key = SECRET_KEY_FROM_QUAY_CONFIG- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow Note- If the - aws clidoes not automatically collect the- access_keyand- secret_keyfrom the- `~/.aws/credentials file, you can, you can configure these by running- aws configureand manually inputting the credentials.
- In your - quay-backupdirectory, create a- bucket_backupdirectory:- mkdir /tmp/quay-backup/bucket-backup - $ mkdir /tmp/quay-backup/bucket-backup- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Backup all blobs from the S3 storage: - aws s3 sync --no-verify-ssl --endpoint-url https://PUBLIC_S3_ENDPOINT:PORT s3://QUAY_BUCKET/ /tmp/quay-backup/bucket-backup/ - $ aws s3 sync --no-verify-ssl --endpoint-url https://PUBLIC_S3_ENDPOINT:PORT s3://QUAY_BUCKET/ /tmp/quay-backup/bucket-backup/- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow Note- The - PUBLIC_S3_ENDPOINTcan be read from the Red Hat Quay- config.yamlfile under- hostnamein the- DISTRIBUTED_STORAGE_CONFIG. If the endpoint is insecure, use- httpinstead of- httpsin the endpoint URL.
				Up to this point, you should have a complete backup of all Red Hat Quay data, blobs, the database, and the config.yaml file stored locally. In the following section, you will migrate the standalone deployment backup to Red Hat Quay on OpenShift Container Platform.
			
19.2. Using backed up standalone content to migrate to OpenShift Container Platform.
Prerequisites
- 
						Your standalone Red Hat Quay data, blobs, database, and config.yamlhave been backed up.
- Red Hat Quay is deployed on OpenShift Container Platform using the Red Hat Quay Operator.
- 
						A QuayRegistrywith all components set tomanaged.
					The procedure in this documents uses the following namespace: quay-enterprise.
				
- Scale down the Red Hat Quay Operator: - oc scale --replicas=0 deployment quay-operator.v3.6.2 -n openshift-operators - $ oc scale --replicas=0 deployment quay-operator.v3.6.2 -n openshift-operators- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Scale down the application and mirror deployments: - oc scale --replicas=0 deployment QUAY_MAIN_APP_DEPLOYMENT QUAY_MIRROR_DEPLOYMENT - $ oc scale --replicas=0 deployment QUAY_MAIN_APP_DEPLOYMENT QUAY_MIRROR_DEPLOYMENT- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Copy the database SQL backup to the - QuayPostgreSQL database instance:- oc cp /tmp/user/quay-backup/quay-database-backup.sql quay-enterprise/quayregistry-quay-database-54956cdd54-p7b2w:/var/lib/pgsql/data/userdata - $ oc cp /tmp/user/quay-backup/quay-database-backup.sql quay-enterprise/quayregistry-quay-database-54956cdd54-p7b2w:/var/lib/pgsql/data/userdata- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Obtain the database password from the Operator-created - config.yamlfile:- oc get deployment quay-quay-app -o json | jq '.spec.template.spec.volumes[].projected.sources' | grep -i config-secret - $ oc get deployment quay-quay-app -o json | jq '.spec.template.spec.volumes[].projected.sources' | grep -i config-secret- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - Example output: - "name": "QUAY_CONFIG_SECRET_NAME" - "name": "QUAY_CONFIG_SECRET_NAME"- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - oc get secret quay-quay-config-secret-9t77hb84tb -o json | jq '.data."config.yaml"' | cut -d '"' -f2 | base64 -d -w0 > /tmp/quay-backup/operator-quay-config-yaml-backup.yaml - $ oc get secret quay-quay-config-secret-9t77hb84tb -o json | jq '.data."config.yaml"' | cut -d '"' -f2 | base64 -d -w0 > /tmp/quay-backup/operator-quay-config-yaml-backup.yaml- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - cat /tmp/quay-backup/operator-quay-config-yaml-backup.yaml | grep -i DB_URI - cat /tmp/quay-backup/operator-quay-config-yaml-backup.yaml | grep -i DB_URI- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - Example output: - postgresql://QUAY_DATABASE_OWNER:PASSWORD@DATABASE_HOST/QUAY_DATABASE_NAME - postgresql://QUAY_DATABASE_OWNER:PASSWORD@DATABASE_HOST/QUAY_DATABASE_NAME- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Execute a shell inside of the database pod: - oc exec -it quay-postgresql-database-pod -- /bin/bash - # oc exec -it quay-postgresql-database-pod -- /bin/bash- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Enter psql: - bash-4.4$ psql - bash-4.4$ psql- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Drop the database: - postgres=# DROP DATABASE "example-restore-registry-quay-database"; - postgres=# DROP DATABASE "example-restore-registry-quay-database";- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - Example output: - DROP DATABASE - DROP DATABASE- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Create a new database and set the owner as the same name: - postgres=# CREATE DATABASE "example-restore-registry-quay-database" OWNER "example-restore-registry-quay-database"; - postgres=# CREATE DATABASE "example-restore-registry-quay-database" OWNER "example-restore-registry-quay-database";- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - Example output: - CREATE DATABASE - CREATE DATABASE- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Connect to the database: - postgres=# \c "example-restore-registry-quay-database"; - postgres=# \c "example-restore-registry-quay-database";- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - Example output: - You are now connected to database "example-restore-registry-quay-database" as user "postgres". - You are now connected to database "example-restore-registry-quay-database" as user "postgres".- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Create a - pg_trmgextension of your- Quaydatabase:- example-restore-registry-quay-database=# create extension pg_trgm ; - example-restore-registry-quay-database=# create extension pg_trgm ;- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - Example output: - CREATE EXTENSION - CREATE EXTENSION- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Exit the postgres CLI to re-enter bash-4.4: - \q - \q- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Set the password for your PostgreSQL deployment: - bash-4.4$ psql -h localhost -d "QUAY_DATABASE_NAME" -U QUAY_DATABASE_OWNER -W < /var/lib/pgsql/data/userdata/quay-database-backup.sql - bash-4.4$ psql -h localhost -d "QUAY_DATABASE_NAME" -U QUAY_DATABASE_OWNER -W < /var/lib/pgsql/data/userdata/quay-database-backup.sql- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - Example output: - SET SET SET SET SET - SET SET SET SET SET- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Exit bash mode: - bash-4.4$ exit - bash-4.4$ exit- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Create a new configuration bundle for the Red Hat Quay Operator. - touch config-bundle.yaml - $ touch config-bundle.yaml- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- In your new - config-bundle.yaml, include all of the information that the registry requires, such as LDAP configuration, keys, and other modifications that your old registry had. Run the following command to move the- secret_keyto your- config-bundle.yaml:- cat /tmp/quay-backup/config.yaml | grep SECRET_KEY > /tmp/quay-backup/config-bundle.yaml - $ cat /tmp/quay-backup/config.yaml | grep SECRET_KEY > /tmp/quay-backup/config-bundle.yaml- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow Note- You must manually copy all the LDAP, OIDC and other information and add it to the /tmp/quay-backup/config-bundle.yaml file. 
- Create a configuration bundle secret inside of your OpenShift cluster: - oc create secret generic new-custom-config-bundle --from-file=config.yaml=/tmp/quay-backup/config-bundle.yaml - $ oc create secret generic new-custom-config-bundle --from-file=config.yaml=/tmp/quay-backup/config-bundle.yaml- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Scale up the - Quaypods:- oc scale --replicas=1 deployment quayregistry-quay-app - $ oc scale --replicas=1 deployment quayregistry-quay-app deployment.apps/quayregistry-quay-app scaled- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Scale up the mirror pods: - oc scale --replicas=1 deployment quayregistry-quay-mirror - $ oc scale --replicas=1 deployment quayregistry-quay-mirror deployment.apps/quayregistry-quay-mirror scaled- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Patch the - QuayRegistryCRD so that it contains the reference to the new custom configuration bundle:- oc patch quayregistry QUAY_REGISTRY_NAME --type=merge -p '{"spec":{"configBundleSecret":"new-custom-config-bundle"}}'- $ oc patch quayregistry QUAY_REGISTRY_NAME --type=merge -p '{"spec":{"configBundleSecret":"new-custom-config-bundle"}}'- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow Note- If Red Hat Quay returns a - 500internal server error, you might have to update the- locationof your- DISTRIBUTED_STORAGE_CONFIGto- default.
- Create a new AWS - credentials.yamlin your- /.aws/directory and include the- access_keyand- secret_keyfrom the Operator-created- config.yamlfile:- touch credentials.yaml - $ touch credentials.yaml- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - grep -i DISTRIBUTED_STORAGE_CONFIG -A10 /tmp/quay-backup/operator-quay-config-yaml-backup.yaml - $ grep -i DISTRIBUTED_STORAGE_CONFIG -A10 /tmp/quay-backup/operator-quay-config-yaml-backup.yaml- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - cat > ~/.aws/credentials << EOF [default] aws_access_key_id = ACCESS_KEY_FROM_QUAY_CONFIG aws_secret_access_key = SECRET_KEY_FROM_QUAY_CONFIG EOF - $ cat > ~/.aws/credentials << EOF [default] aws_access_key_id = ACCESS_KEY_FROM_QUAY_CONFIG aws_secret_access_key = SECRET_KEY_FROM_QUAY_CONFIG EOF- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow Note- If the - aws clidoes not automatically collect the- access_keyand- secret_keyfrom the- `~/.aws/credentials file, you can configure these by running- aws configureand manually inputting the credentials.
- Record the NooBaa’s publicly available endpoint: - oc get route s3 -n openshift-storage -o yaml -o jsonpath="{.spec.host}{'\n'}"- $ oc get route s3 -n openshift-storage -o yaml -o jsonpath="{.spec.host}{'\n'}"- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Sync the backup data to the NooBaa backend storage: - aws s3 sync --no-verify-ssl --endpoint-url https://NOOBAA_PUBLIC_S3_ROUTE /tmp/quay-backup/bucket-backup/* s3://QUAY_DATASTORE_BUCKET_NAME - $ aws s3 sync --no-verify-ssl --endpoint-url https://NOOBAA_PUBLIC_S3_ROUTE /tmp/quay-backup/bucket-backup/* s3://QUAY_DATASTORE_BUCKET_NAME- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Scale the Operator back up to 1 pod: - oc scale –replicas=1 deployment quay-operator.v3.6.4 -n openshift-operators - $ oc scale –replicas=1 deployment quay-operator.v3.6.4 -n openshift-operators- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
The Operator uses the custom configuration bundle provided and reconciles all secrets and deployments. Your new Red Hat Quay deployment on OpenShift Container Platform should contain all of the information that the old deployment had. You should be able to pull all images.