Ce contenu n'est pas disponible dans la langue sélectionnée.
Chapter 3. Setting up Clair on standalone Red Hat Quay deployments
For standalone Red Hat Quay deployments, you can set up Clair manually.
Procedure
In your Red Hat Quay installation directory, create a new directory for the Clair database data:
mkdir /home/<user-name>/quay-poc/postgres-clairv4
$ mkdir /home/<user-name>/quay-poc/postgres-clairv4Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the appropriate permissions for the
postgres-clairv4file by entering the following command:setfacl -m u:26:-wx /home/<user-name>/quay-poc/postgres-clairv4
$ setfacl -m u:26:-wx /home/<user-name>/quay-poc/postgres-clairv4Copy to Clipboard Copied! Toggle word wrap Toggle overflow Deploy a Clair PostgreSQL database by entering the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Install the PostgreSQL
uuid-osspmodule for your Clair deployment:sudo podman exec -it postgresql-clairv4 /bin/bash -c 'echo "CREATE EXTENSION IF NOT EXISTS \"uuid-ossp\"" | psql -d clair -U postgres'
$ sudo podman exec -it postgresql-clairv4 /bin/bash -c 'echo "CREATE EXTENSION IF NOT EXISTS \"uuid-ossp\"" | psql -d clair -U postgres'Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
CREATE EXTENSION
CREATE EXTENSIONCopy to Clipboard Copied! Toggle word wrap Toggle overflow NoteClair requires the
uuid-osspextension to be added to its PostgreSQL database. For users with proper privileges, creating the extension will automatically be added by Clair. If users do not have the proper privileges, the extension must be added before start Clair.If the extension is not present, the following error will be displayed when Clair attempts to start:
ERROR: Please load the "uuid-ossp" extension. (SQLSTATE 42501).Stop the
Quaycontainer if it is running and restart it in configuration mode, loading the existing configuration as a volume:sudo podman run --rm -it --name quay_config \ -p 80:8080 -p 443:8443 \ -v $QUAY/config:/conf/stack:Z \ registry.redhat.io/quay/quay-rhel8:v3.14.4 config secret
$ sudo podman run --rm -it --name quay_config \ -p 80:8080 -p 443:8443 \ -v $QUAY/config:/conf/stack:Z \ registry.redhat.io/quay/quay-rhel8:v3.14.4 config secretCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Log in to the configuration tool and click Enable Security Scanning in the Security Scanner section of the UI.
-
Set the HTTP endpoint for Clair using a port that is not already in use on the
quay-serversystem, for example,8081. Create a pre-shared key (PSK) using the Generate PSK button.
Security Scanner UI
-
Validate and download the
config.yamlfile for Red Hat Quay, and then stop theQuaycontainer that is running the configuration editor. Extract the new configuration bundle into your Red Hat Quay installation directory, for example:
tar xvf quay-config.tar.gz -d /home/<user-name>/quay-poc/
$ tar xvf quay-config.tar.gz -d /home/<user-name>/quay-poc/Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a folder for your Clair configuration file, for example:
mkdir /etc/opt/clairv4/config/
$ mkdir /etc/opt/clairv4/config/Copy to Clipboard Copied! Toggle word wrap Toggle overflow Change into the Clair configuration folder:
cd /etc/opt/clairv4/config/
$ cd /etc/opt/clairv4/config/Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a Clair configuration file, for example:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow For more information about Clair’s configuration format, see Clair configuration reference.
Start Clair by using the container image, mounting in the configuration from the file you created:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteRunning multiple Clair containers is also possible, but for deployment scenarios beyond a single container the use of a container orchestrator like Kubernetes or OpenShift Container Platform is strongly recommended.
3.1. Upgrading the Clair PostgreSQL database Copier lienLien copié sur presse-papiers!
If you are upgrading Red Hat Quay to version 13, you must migrate your Clair PostgreSQL database version from PostgreSQL version 13
Use the following procedure to upgrade your Clair PostgreSQL database from version 13
Clair security scans might become temporarily disrupted after the migration procedure has succeeded.
Procedure
Stop the Red Hat Quay container by entering the following command:
sudo podman stop <quay_container_name>
$ sudo podman stop <quay_container_name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Stop the Clair container by running the following command:
sudo podman stop <clair_container_id>
$ sudo podman stop <clair_container_id>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Run the following Podman process from SCLOrg’s Data Migration procedure, which allows for data migration from a remote PostgreSQL server:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Insert a name for your Clair PostgreSQL 15 migration database.
- 2
- Your new Clair PostgreSQL 15 database container IP address. Can obtained by running the following command:
sudo podman inspect -f "{{.NetworkSettings.IPAddress}}" postgresql-quay. - 3
- You must specify a different volume mount point than the one from your initial Clair PostgreSQL 13 deployment, and modify the access control lists for said directory. For example:
mkdir -p /host/data/clair-postgresql15-directory
$ mkdir -p /host/data/clair-postgresql15-directoryCopy to Clipboard Copied! Toggle word wrap Toggle overflow setfacl -m u:26:-wx /host/data/clair-postgresql15-directory
$ setfacl -m u:26:-wx /host/data/clair-postgresql15-directoryCopy to Clipboard Copied! Toggle word wrap Toggle overflow This prevents data from being overwritten by the new container.
Stop the Clair PostgreSQL 13 container:
sudo podman stop <clair_postgresql13_container_name>
$ sudo podman stop <clair_postgresql13_container_name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow After completing the PostgreSQL migration, run the Clair PostgreSQL 15 container, using the new data volume mount from Step 3, for example,
</host/data/clair-postgresql15-directory:/var/lib/postgresql/data>:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Start the Red Hat Quay container by entering the following command:
sudo podman run -d --rm -p 80:8080 -p 443:8443 --name=quay \ -v /home/<quay_user>/quay-poc/config:/conf/stack:Z \ -v /home/<quay_user>/quay-poc/storage:/datastorage:Z \ {productrepo}/{quayimage}:{productminv}$ sudo podman run -d --rm -p 80:8080 -p 443:8443 --name=quay \ -v /home/<quay_user>/quay-poc/config:/conf/stack:Z \ -v /home/<quay_user>/quay-poc/storage:/datastorage:Z \ {productrepo}/{quayimage}:{productminv}Copy to Clipboard Copied! Toggle word wrap Toggle overflow Start the Clair container by entering the following command:
sudo podman run -d --name clairv4 \ -p 8081:8081 -p 8088:8088 \ -e CLAIR_CONF=/clair/config.yaml \ -e CLAIR_MODE=combo \ registry.redhat.io/quay/clair-rhel8:{productminv}$ sudo podman run -d --name clairv4 \ -p 8081:8081 -p 8088:8088 \ -e CLAIR_CONF=/clair/config.yaml \ -e CLAIR_MODE=combo \ registry.redhat.io/quay/clair-rhel8:{productminv}Copy to Clipboard Copied! Toggle word wrap Toggle overflow
For more information, see Data Migration.
3.2. Using Clair with an upstream image for Red Hat Quay Copier lienLien copié sur presse-papiers!
For most users, independent upgrades of Clair from the current version (4.8) are unnecessary. In some cases, however, customers might want to pull an image of Clair from the upstream repository for various reasons, such as for specific bug fixes or to try new features that have not yet been released downstream. You can use the following procedure to run an upstream version of Clair with Red Hat Quay.
Upstream versions of Clair have not been fully tested for compatibility with Red Hat Quay. As a result, this combination might cause issues with your deployment.
Procedure
Enter the following command to stop Clair if it is running:
podman stop <clairv4_container_name>
$ podman stop <clairv4_container_name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Navigate to the upstream repository, find the version of Clair that you want to use, and pull it to your local machine. For example:
podman pull quay.io/projectquay/clair:nightly-2024-02-03
$ podman pull quay.io/projectquay/clair:nightly-2024-02-03Copy to Clipboard Copied! Toggle word wrap Toggle overflow Start Clair by using the container image, mounting in the configuration from the file you created:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow