Chapter 17. Migrating a standalone Red Hat Quay deployment to a Red Hat Quay Operator deployment
You can back up a standalone Red Hat Quay deployment and migrate it to a Red Hat Quay Operator deployment on OpenShift Container Platform.
17.1. Backing up a standalone deployment of Red Hat Quay Copy linkLink copied to clipboard!
To back up a standalone Red Hat Quay deployment before Operator migration, you can copy config.yaml, dump the database, and sync object storage blobs.
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-backupCreate 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- Install the AWS CLI if you do not have it already.
Create an
~/.aws/directory:$ mkdir ~/.aws/Obtain the
access_keyandsecret_keyfrom theconfig.yamlof your standalone deployment:$ grep -i DISTRIBUTED_STORAGE_CONFIG -A10 /tmp/quay-backup/config.yamlExample output:
DISTRIBUTED_STORAGE_CONFIG: minio-1: - RadosGWStorage - access_key: ########## bucket_name: quay hostname: 172.24.10.50 is_secure: false port: "9000" secret_key: ########## storage_path: /datastorage/registryStore the
access_keyandsecret_keyfrom theconfig.yamlfile in your~/.awsdirectory:$ touch ~/.aws/credentialsOptional: Check that your
access_keyandsecret_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 EOFExample output:
aws_access_key_id = ACCESS_KEY_FROM_QUAY_CONFIG aws_secret_access_key = SECRET_KEY_FROM_QUAY_CONFIGNoteIf the AWS CLI does not automatically collect the
access_keyandsecret_keyfrom the~/.aws/credentialsfile, you can configure these by runningaws configureand manually entering the credentials.In your
quay-backupdirectory, create abucket_backupdirectory:$ mkdir /tmp/quay-backup/bucket-backupBack up 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/NoteThe
PUBLIC_S3_ENDPOINTcan be read from the Red Hat Quayconfig.yamlfile underhostnamein theDISTRIBUTED_STORAGE_CONFIG. If the endpoint is insecure, usehttpinstead ofhttpsin the endpoint URL.
17.2. Using backed up standalone content to migrate to OpenShift Container Platform Copy linkLink copied to clipboard!
To migrate backed-up standalone Red Hat Quay content to OpenShift Container Platform, you can restore the database, apply a custom configuration bundle, and sync blobs to Object Bucket storage.
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 document uses the following namespace: quay-enterprise.
Procedure
Scale down the Red Hat Quay Operator:
$ oc scale --replicas=0 deployment quay-operator.v3.6.2 -n openshift-operatorsScale down the application and mirror deployments:
$ oc scale --replicas=0 deployment QUAY_MAIN_APP_DEPLOYMENT QUAY_MIRROR_DEPLOYMENTCopy 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/userdataObtain 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-secretExample output:
"name": "QUAY_CONFIG_SECRET_NAME"$ 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$ cat /tmp/quay-backup/operator-quay-config-yaml-backup.yaml | grep -i DB_URIExample output:
postgresql://QUAY_DATABASE_OWNER:PASSWORD@DATABASE_HOST/QUAY_DATABASE_NAMEExecute a shell inside of the database pod:
# oc exec -it quay-postgresql-database-pod -- /bin/bashEnter psql:
bash-4.4$ psqlDrop the database:
postgres=# DROP DATABASE "example-restore-registry-quay-database";Example output:
DROP DATABASECreate 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";Example output:
CREATE DATABASEConnect to the database:
postgres=# \c "example-restore-registry-quay-database";Example output:
You are now connected to database "example-restore-registry-quay-database" as user "postgres".Create a
pg_trgmextension of yourQuaydatabase:example-restore-registry-quay-database=# CREATE EXTENSION IF NOT EXISTS pg_trgm ;Example output:
CREATE EXTENSIONExit the postgres CLI to re-enter bash-4.4:
\qSet 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.sqlExample output:
SET SET SET SET SETExit bash mode:
bash-4.4$ exitCreate a new configuration bundle for the Red Hat Quay Operator.
$ touch config-bundle.yamlIn 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 thesecret_keyto yourconfig-bundle.yaml:$ cat /tmp/quay-backup/config.yaml | grep SECRET_KEY > /tmp/quay-backup/config-bundle.yamlNoteYou must manually copy all the LDAP, OIDC, and other information and add it to the
/tmp/quay-backup/config-bundle.yamlfile.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.yamlScale up the
Quaypods:$ oc scale --replicas=1 deployment quayregistry-quay-appExample output:
deployment.apps/quayregistry-quay-app scaledScale up the mirror pods:
$ oc scale --replicas=1 deployment quayregistry-quay-mirrorExample output:
deployment.apps/quayregistry-quay-mirror scaledPatch 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"}}'NoteIf Red Hat Quay returns a
500internal server error, you might have to update thelocationof yourDISTRIBUTED_STORAGE_CONFIGtodefault.Create a new AWS
credentials.yamlin your/.aws/directory and include theaccess_keyandsecret_keyfrom the Operator-createdconfig.yamlfile:$ touch credentials.yaml$ grep -i DISTRIBUTED_STORAGE_CONFIG -A10 /tmp/quay-backup/operator-quay-config-yaml-backup.yaml$ cat > ~/.aws/credentials << EOF [default] aws_access_key_id = ACCESS_KEY_FROM_QUAY_CONFIG aws_secret_access_key = SECRET_KEY_FROM_QUAY_CONFIG EOFNoteIf the AWS CLI does not automatically collect the
access_keyandsecret_keyfrom the~/.aws/credentialsfile, you can configure these by runningaws configureand manually entering the credentials.Record the NooBaa’s publicly available endpoint:
$ oc get route s3 -n openshift-storage -o yaml -o jsonpath="{.spec.host}{'\n'}"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_NAMEScale the Operator back up to 1 pod:
$ oc scale --replicas=1 deployment quay-operator.v3.6.4 -n openshift-operatorsThe Operator uses the custom configuration bundle provided and reconciles all secrets and deployments. Your new Red Hat Quay deployment on OpenShift Container Platform contains all of the information that the old deployment had. You can pull all images.