Chapter 2. Getting started with Red Hat Quay

The Red Hat Quay registry can be deployed for non-production purposes on a single machine, either physical or virtual.

2.1. Prerequisites

  • Red Hat Enterprise Linux (RHEL) 8

  • An active subscription to Red Hat
  • Two or more virtual CPUs
  • 4 GB or more of RAM
  • Approximately 30 GB of disk space on your test system, which can be broken down as follows:

    • Approximately 10 GB of disk space for the Red Hat Enterprise Linux (RHEL) operating system.
    • Approximately 10 GB of disk space for Docker storage for running three containers.
    • Approximately 10 GB of disk space for Red Hat Quay local storage.

      Note

      CEPH or other local storage might require more memory.

      More information on sizing can be found at Quay 3.x Sizing Guidlines.

Note

Red Hat Enterprise Linux (RHEL) 8 is recommended for highly available, production quality deployments of Red Hat Quay 3.8. RHEL 7 has not been tested with Red Hat Quay 3.8, and will be deprecated in a future release.

2.1.1. Using Podman

This document uses Podman for creating and deploying containers. For more information on Podman and related technologies, see Building, running, and managing Linux containers on Red Hat Enterprise Linux 8.

Important

If you do not have Podman installed on your system, the use of equivalent Docker commands might be possible, however this is not recommended. Docker has not been tested with Red Hat Quay 3.8, and will be deprecated in a future release. Podman is recommended for highly available, production quality deployments of Red Hat Quay 3.8.

2.2. Preparing Red Hat Enterprise Linux for a Red Hat Quay proof of concept deployment

Use the following procedures to configure Red Hat Enterprise Linux (RHEL) for a Red Hat Quay proof of concept deployment.

2.2.1. Install and register the RHEL server

Use the following procedure to configure the Red Hat Enterprise Linux (RHEL) server for a Red Hat Quay proof of concept deployment.

Procedure

  1. Install the latest RHEL 8 server. You can do a minimal, shell-access only install, or Server plus GUI if you want a desktop.
  2. Register and subscribe your RHEL server system as described in How to register and subscribe a RHEL system to the Red Hat Customer Portal using Red Hat Subscription-Manager
  3. Enter the following commands to register your system and list available subscriptions. Choose an available RHEL server subscription, attach to its pool ID, and upgrade to the latest software:

    # subscription-manager register --username=<user_name> --password=<password>
    # subscription-manager refresh
    # subscription-manager list --available
    # subscription-manager attach --pool=<pool_id>
    # yum update -y

2.2.2. Installing Podman

Use the following procedure to install Podman.

Procedure

  • Enter the following command to install Podman:

    $ sudo yum install -y podman
  • Alternatively, you can install the container-tools module, which pulls in the full set of container software packages:

    $ sudo yum module install -y container-tools

2.2.3. Registry authentication

Use the following procedure to authenticate your registry for a Red Hat Quay proof of concept.

Procedure

  1. Set up authentication to registry.redhat.io by following the Red Hat Container Registry Authentication procedure. Setting up authentication allows you to pull the Quay container.

    Note

    This differs from earlier versions of Red Hat Quay, when the images were hosted on Quay.io.

  2. Enter the following command to log in to the registry:

    $ sudo podman login registry.redhat.io

    You are prompted to enter your username and password.

2.2.4. Firewall configuration

If you have a firewall running on your system, you might have to add rules that allow access to Red Hat Quay. Use the following procedure to configure your firewall for a proof of concept deployment.

Procedure

  • The commands required depend on the ports that you have mapped on your system, for example:

    $ firewall-cmd --permanent --add-port=80/tcp
    $ firewall-cmd --permanent --add-port=443/tcp
    $ firewall-cmd --permanent --add-port=5432/tcp
    $ firewall-cmd --permanent --add-port=5433/tcp
    $ firewall-cmd --permanent --add-port=6379/tcp
    $ firewall-cmd --reload

2.2.5. IP addressing and naming services

There are several ways to configure the component containers in Red Hat Quay so that they can communicate with each other, for example:

  • Using the IP addresses for the containers. You can determine the IP address for containers with podman inspect and then use the values in the configuration tool when specifying the connection strings, for example:

    $ sudo podman inspect -f "{{.NetworkSettings.IPAddress}}" postgresql-quay

    This approach is susceptible to host restarts, as the IP addresses for the containers will change after a reboot.

  • Using a naming service. If you want your deployment to survive container restarts, which typically result in changed IP addresses, you can implement a naming service. For example, the dnsname plugin is used to allow containers to resolve each other by name.
  • Using the host network. You can use the podman run command with the --net=host option and then use container ports on the host when specifying the addresses in the configuration. This option is susceptible to port conflicts when two containers want to use the same port. This method is not recommended.
  • Configuring port mapping. You can use port mappings to expose ports on the host and then use these ports in combination with the host IP address or host name.

This document uses port mapping and assumes a static IP address for your host system. Throughout the deployment, quay-sever.example.com is used with the 192.168.1.112 IP address. This information is established in the /etc/hosts file, for example:

$ cat /etc/hosts

Example output:

192.168.1.112   quay-server.example.com

Table 2.1. Sample proof of concept port mapping

ComponentPort mappingAddress

Quay

-p 80:8080 -p 443:8443

http://quay-server.example.com

Postgres for Quay

-p 5432:5432

quay-server.example.com:5432

Redis

-p 6379:6379

quay-server.example.com:6379

Postgres for Clair V4

-p 5433:5432

quay-server.example.com:5433

Clair V4

-p 8081:8080

http://quay-server.example.com:8081

2.3. Configuring the database

Red Hat Quay requires a database for storing metadata. Postgres is used throughout this document and is recommended for highly available configurations. Alternatively, you can use MySQL with a similar approach to configuration as described below.

2.3.1. Setting up Postgres

For the Red Hat Quay proof of concept, a directory on the local file system to persist database data is used.

Procedure

  1. In the installation folder, denoted here by the $QUAY variable, create a directory for the database data by entering the following command:

    $ mkdir -p $QUAY/postgres-quay
  2. Set the appropriate permissions by entering the following command:

    $ setfacl -m u:26:-wx $QUAY/postgres-quay
  3. Start the Postgres container, specifying the username, password, and database name and port, with the volume definition for database data:

    $ sudo podman run -d --rm --name postgresql-quay \
      -e POSTGRESQL_USER=quayuser \
      -e POSTGRESQL_PASSWORD=quaypass \
      -e POSTGRESQL_DATABASE=quay \
      -e POSTGRESQL_ADMIN_PASSWORD=adminpass \
      -p 5432:5432 \
      -v $QUAY/postgres-quay:/var/lib/pgsql/data:Z \
      registry.redhat.io/rhel8/postgresql-10
  4. Ensure that the Postgres pg_trgm module is installed by running the following command:

    $ sudo podman exec -it postgresql-quay /bin/bash -c 'echo "CREATE EXTENSION IF NOT EXISTS pg_trgm" | psql -d quay -U postgres'
    Note

    The pg_trgm module is required for the Quay container.

2.4. Configuring Redis

Redis ia a key-value store that is used by Red Hat Quay for live builder logs and the Red Hat Quay tutorial.

2.4.1. Setting up Redis

Use the following procedure to deploy the Redis container for the Red Hat Quay proof of concept.

Procedure

  • Start the Redis container, specifying the port and password, by entering the following command:

    $ sudo podman run -d --rm --name redis \
      -p 6379:6379 \
      -e REDIS_PASSWORD=strongpassword \
      registry.redhat.io/rhel8/redis-6

2.5. Configuring Red Hat Quay

Use the following procedure to generate a configuration file that details all components, including registry settings, the database, and Redis connection parameters.

Procedure

  1. To generate a configuration file, enter the following command to run the Quay container in config mode. You must specify a password, for example, the string secret:

    $ sudo podman run --rm -it --name quay_config -p 80:8080 -p 443:8443 registry.redhat.io/quay/quay-rhel8:v3.8.15 config secret
  2. Use your browser to access the user interface for the configuration tool at http://quay-server.example.com.

    Note

    This documentation assumes that you have configured the quay-server.example.com hostname in your /etc/hosts file.

  3. Log in with username and password specified
  4. Log in with the username and password you set in Step 1 of Configuring Red Hat Quay.

    Note

    If you followed this procedure, the username is quayconfig and the password is secret.

2.5.1. Red Hat Quay setup

In the Red Hat Quay configuration editor, you must enter the following credentials:

  • Basic configuration
  • Server configuration
  • Database
  • Redis

2.5.1.1. Basic configuration

Under Basic Configuration, populate the Registry Title and Registry Title Short fields. The default values can be used if they are populated.

2.5.1.2. Server configuration

Under Server Hostname, specify the HTTP host and port for the location where the registry will be accessible on the network.

If you followed the instructions in this documenter, enter quay-server.example.com.

2.5.1.3. Database

In the Database section, specify the connection details for the database that Red Hat Quay uses to store metadata.

If you followed the instructions in this document for deploying a proof of concept system, enter the following values:

  • Database Type: Postgres
  • Database Server: quay-server.example.com:5432
  • Username: quayuser
  • Password: quaypass
  • Database Name: quay

2.5.1.4. Redis

The Redis key-value store is used to store real-time events and build logs.

If you followed the instructions in this document for deploying a proof-of-concept system, enter the following credentials under the Redis section:

  • Redis Hostname: quay-server.example.com
  • Redis port: 6379 (default)
  • Redis password: strongpassword

2.5.2. Validate and download configuration

After all required fields have been set, validate your settings by clicking Validate Configuration Changes. If any errors are reported, continue editing your configuration until the settings are valid and Red Hat Quay can connect to your database and Redis servers.

After validation, download the Configuration file. Stop the Quay container that is running the configuration editor.

2.6. Deploying Red Hat Quay

2.6.1. Prerequisites

  • The Red Hat Quay database is running.
  • The Redis server is running.
  • You have generated a valid configuration file.
  • You have stopped the Quay container that was running the configuration editor.

2.6.2. Preparing the configuration folder

Use the following procedure to prepare your Red Hat Quay configuration folder.

Procedure

  1. Create a directory to copy the Red Hat Quay configuration bundle to:

    $ mkdir $QUAY/config
  2. Copy the generated Red Hat Quay configuration bundle to the directory:

    $ cp ~/Downloads/quay-config.tar.gz ~/config
  3. Change into the the directory:

    $ cd $QUAY/config
  4. Unpack the Red Hat Quay configuration bundle:

    $ tar xvf quay-config.tar.gz

2.6.3. Prepare local storage for image data

Use the following procedure to set your local file system to store registry images.

Procedure

  1. Create a local directory that will store registry images by entering the following command:

    $ mkdir $QUAY/storage
  2. Set the directory to store registry images:

    $ setfacl -m u:1001:-wx $QUAY/storage

2.6.4. Deploy the Red Hat Quay registry

  1. Use the following procedure to deploy the Quay registry container.
  2. Enter the following command to start the Quay registry container, specifying the appropriate volumes for configuration data and local storage for image data:

    $ sudo podman run -d --rm -p 80:8080 -p 443:8443  \
       --name=quay \
       -v $QUAY/config:/conf/stack:Z \
       -v $QUAY/storage:/datastorage:Z \
       registry.redhat.io/quay/quay-rhel8:v3.8.15

2.7. Using Red Hat Quay

The following steps allow you to use the interface and create new organizations and repositories , and to search and browse existing repositories. Following step 3, you can use the command line interface to interact with the registry, and to push and pull images.

  1. Use your browser to access the user interface for the Red Hat Quay registry at http://quay-server.example.com, assuming you have configured quay-server.example.com as your hostname in your /etc/hosts file.
  2. Click Create Account and add a user, for example, quayadmin with a password password.
  3. From the command line, log in to the registry:

    $ sudo podman login --tls-verify=false quay-server.example.com
    Username: quayadmin
    Password: password
    Login Succeeded!

2.7.1. Push and pull images

  1. To test pushing and pulling images from the Red Hat Quay registry, first pull a sample image from an external registry:

    $ sudo podman pull busybox
    Trying to pull docker.io/library/busybox...
    Getting image source signatures
    Copying blob 4c892f00285e done
    Copying config 22667f5368 done
    Writing manifest to image destination
    Storing signatures
    22667f53682a2920948d19c7133ab1c9c3f745805c14125859d20cede07f11f9
  2. Use the podman images command to see the local copy:

    $ sudo podman images
    REPOSITORY                          TAG      IMAGE ID       CREATED         SIZE
    docker.io/library/busybox           latest   22667f53682a   14 hours ago    1.45 MB
    ...
  3. Tag this image, in preparation for pushing it to the Red Hat Quay registry:

    $ sudo podman tag docker.io/library/busybox quay-server.example.com/quayadmin/busybox:test
  4. Next, push the image to the Red Hat Quay registry. Following this step, you can use your browser to see the tagged image in your repository.

    $ sudo podman push --tls-verify=false quay-server.example.com/quayadmin/busybox:test
    Getting image source signatures
    Copying blob 6b245f040973 done
    Copying config 22667f5368 done
    Writing manifest to image destination
    Storing signatures
  5. To test access to the image from the command line, first delete the local copy of the image:

    $ sudo podman rmi quay-server.example.com/quayadmin/busybox:test
    Untagged: quay-server.example.com/quayadmin/busybox:test
  6. Pull the image again, this time from your Red Hat Quay registry:

    $ sudo podman pull --tls-verify=false quay-server.example.com/quayadmin/busybox:test
    Trying to pull quay-server.example.com/quayadmin/busybox:test...
    Getting image source signatures
    Copying blob 6ef22a7134ba [--------------------------------------] 0.0b / 0.0b
    Copying config 22667f5368 done
    Writing manifest to image destination
    Storing signatures
    22667f53682a2920948d19c7133ab1c9c3f745805c14125859d20cede07f11f9