Questo contenuto non è disponibile nella lingua selezionata.
Chapter 16. Open Container Initiative support
Container registries were originally designed to support container images in the Docker image format. To promote the use of additional runtimes apart from Docker, the Open Container Initiative (OCI) was created to provide a standardization surrounding container runtimes and image formats. Most container registries support the OCI standardization as it is based on the Docker image manifest V2, Schema 2 format.
In addition to container images, a variety of artifacts have emerged that support not just individual applications, but also the Kubernetes platform as a whole. These range from Open Policy Agent (OPA) policies for security and governance to Helm charts and Operators that aid in application deployment.
Red Hat Quay is a private container registry that not only stores container images, but also supports an entire ecosystem of tooling to aid in the management of containers. Red Hat Quay strives to be as compatible as possible with the OCI 1.1 Image and Distribution specifications, and supports common media types like Helm charts (as long as they pushed with a version of Helm that supports OCI) and a variety of arbitrary media types within the manifest or layer components of container images. Support for OCI media types differs from previous iterations of Red Hat Quay, when the registry was more strict about accepted media types. Because Red Hat Quay now works with a wider array of media types, including those that were previously outside the scope of its support, it is now more versatile accommodating not only standard container image formats but also emerging or unconventional types.
In addition to its expanded support for novel media types, Red Hat Quay ensures compatibility with Docker images, including V2_2 and V2_1 formats. This compatibility with Docker V2_2 and V2_1 images demonstrates Red Hat Quay’s' commitment to providing a seamless experience for Docker users. Moreover, Red Hat Quay continues to extend its support for Docker V1 pulls, catering to users who might still rely on this earlier version of Docker images.
Support for OCI artifacts are enabled by default. The following examples show you how to use some media types, which can be used as examples for using other OCI media types.
16.1. Helm and OCI prerequisites
Helm simplifies how applications are packaged and deployed. Helm uses a packaging format called Charts which contain the Kubernetes resources representing an application. Red Hat Quay supports Helm charts so long as they are a version supported by OCI.
Use the following procedures to pre-configure your system to use Helm and other OCI media types.
The most recent version of Helm can be downloaded from the Helm releases page. After you have downloaded Helm, you must enable your system to trust SSL/TLS certificates used by Red Hat Quay.
16.1.1. Enabling your system to trust SSL/TLS certificates used by Red Hat Quay
Communication between the Helm client and Red Hat Quay is facilitated over HTTPS. As of Helm 3.5, support is only available for registries communicating over HTTPS with trusted certificates. In addition, the operating system must trust the certificates exposed by the registry. You must ensure that your operating system has been configured to trust the certificates used by Red Hat Quay. Use the following procedure to enable your system to trust the custom certificates.
Procedure
- Enter the following command to copy the - rootCA.pemfile to the- /etc/pki/ca-trust/source/anchors/folder:- sudo cp rootCA.pem /etc/pki/ca-trust/source/anchors/ - $ sudo cp rootCA.pem /etc/pki/ca-trust/source/anchors/- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Enter the following command to update the CA trust store: - sudo update-ca-trust extract - $ sudo update-ca-trust extract- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
16.2. Using Helm charts
Use the following example to download and push an etherpad chart from the Red Hat Community of Practice (CoP) repository.
Prerequisites
- You have logged into Red Hat Quay.
Procedure
- Add a chart repository by entering the following command: - helm repo add redhat-cop https://redhat-cop.github.io/helm-charts - $ helm repo add redhat-cop https://redhat-cop.github.io/helm-charts- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Enter the following command to update the information of available charts locally from the chart repository: - helm repo update - $ helm repo update- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Enter the following command to pull a chart from a repository: - helm pull redhat-cop/etherpad --version=0.0.4 --untar - $ helm pull redhat-cop/etherpad --version=0.0.4 --untar- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Enter the following command to package the chart into a chart archive: - helm package ./etherpad - $ helm package ./etherpad- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - Example output - Successfully packaged chart and saved it to: /home/user/linux-amd64/etherpad-0.0.4.tgz - Successfully packaged chart and saved it to: /home/user/linux-amd64/etherpad-0.0.4.tgz- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Log in to Red Hat Quay using - helm registry login:- helm registry login quay370.apps.quayperf370.perfscale.devcluster.openshift.com - $ helm registry login quay370.apps.quayperf370.perfscale.devcluster.openshift.com- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Push the chart to your repository using the - helm pushcommand:- helm push etherpad-0.0.4.tgz oci://quay370.apps.quayperf370.perfscale.devcluster.openshift.com - $ helm push etherpad-0.0.4.tgz oci://quay370.apps.quayperf370.perfscale.devcluster.openshift.com- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - Example output: - Pushed: quay370.apps.quayperf370.perfscale.devcluster.openshift.com/etherpad:0.0.4 Digest: sha256:a6667ff2a0e2bd7aa4813db9ac854b5124ff1c458d170b70c2d2375325f2451b - Pushed: quay370.apps.quayperf370.perfscale.devcluster.openshift.com/etherpad:0.0.4 Digest: sha256:a6667ff2a0e2bd7aa4813db9ac854b5124ff1c458d170b70c2d2375325f2451b- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Ensure that the push worked by deleting the local copy, and then pulling the chart from the repository: - rm -rf etherpad-0.0.4.tgz - $ rm -rf etherpad-0.0.4.tgz- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - helm pull oci://quay370.apps.quayperf370.perfscale.devcluster.openshift.com/etherpad --version 0.0.4 - $ helm pull oci://quay370.apps.quayperf370.perfscale.devcluster.openshift.com/etherpad --version 0.0.4- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - Example output: - Pulled: quay370.apps.quayperf370.perfscale.devcluster.openshift.com/etherpad:0.0.4 Digest: sha256:4f627399685880daf30cf77b6026dc129034d68c7676c7e07020b70cf7130902 - Pulled: quay370.apps.quayperf370.perfscale.devcluster.openshift.com/etherpad:0.0.4 Digest: sha256:4f627399685880daf30cf77b6026dc129034d68c7676c7e07020b70cf7130902- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
16.3. Annotation parsing
Some OCI media types do not utilize labels and, as such, critical information such as expiration timestamps are not included. Red Hat Quay supports metadata passed through annotations to accommodate OCI media types that do not include these labels for metadata transmission. Tools such as ORAS (OCI Registry as Storage) can now be used to embed information with artifact types to help ensure that images operate properly, for example, to expire.
The following procedure uses ORAS to add an expiration date to an OCI media artifact.
					If you pushed an image with podman push, and then add an annotation with oras, the MIME type is changed. Consequently, you will not be able to pull the same image with podman pull because Podman does not recognize that MIME type.
				
Prerequisites
- 
						You have downloaded the orasCLI. For more information, see Installation.
- You have pushed an OCI media artifact to your Red Hat Quay repository.
Procedure
- By default, some OCI media types, like - application/vnd.oci.image.manifest.v1+json, do not use certain labels, like expiration timestamps. You can use a CLI tool like ORAS (- oras) to add annotations to OCI media types. For example:- oras push --annotation "quay.expires-after=2d" \ --annotation "expiration = 2d" \ quay.io/<organization_name>/<repository>/<image_name>:<tag> - $ oras push --annotation "quay.expires-after=2d" \- 1 - --annotation "expiration = 2d" \- 2 - quay.io/<organization_name>/<repository>/<image_name>:<tag>- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - Example output - Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
Verification
- Pull the image with - oras. For example:- oras pull quay.io/<organization_name>/<repository>/<image_name>:<tag> - $ oras pull quay.io/<organization_name>/<repository>/<image_name>:<tag>- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Inspect the changes using - oras. For example:- oras manifest fetch quay.io/<organization_name>/<repository>/<image_name>:<tag> - $ oras manifest fetch quay.io/<organization_name>/<repository>/<image_name>:<tag>- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - Example output - {"schemaVersion":2,"mediaType":"application/vnd.oci.image.manifest.v1+json","artifactType":"application/vnd.unknown.artifact.v1","config":{"mediaType":"application/vnd.oci.empty.v1+json","digest":"sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a","size":2,"data":"e30="},"layers":[{"mediaType":"application/vnd.oci.empty.v1+json","digest":"sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a","size":2,"data":"e30="}],"annotations":{"org.opencontainers.image.created":"2024-07-11T15:22:42Z","version ":" 8.11"}}- {"schemaVersion":2,"mediaType":"application/vnd.oci.image.manifest.v1+json","artifactType":"application/vnd.unknown.artifact.v1","config":{"mediaType":"application/vnd.oci.empty.v1+json","digest":"sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a","size":2,"data":"e30="},"layers":[{"mediaType":"application/vnd.oci.empty.v1+json","digest":"sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a","size":2,"data":"e30="}],"annotations":{"org.opencontainers.image.created":"2024-07-11T15:22:42Z","version ":" 8.11"}}- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
16.4. Attaching referrers to an image tag
				The following procedure shows you how to attach referrers to an image tag using different schemas supported by the OCI distribution spec 1.1 using the oras CLI. This is useful for attaching and managing additional metadata like referrers to container images.
			
Prerequisites
- 
						You have downloaded the orasCLI. For more information, see Installation.
- You have access to an OCI media artifact.
Procedure
- Tag an OCI media artifact by entering the following command: - podman tag <myartifact_image> <quay-server.example.com>/<organization_name>/<repository>/<image_name>:<tag> - $ podman tag <myartifact_image> <quay-server.example.com>/<organization_name>/<repository>/<image_name>:<tag>- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Push the artifact to your Red Hat Quay registry. For example: - podman push <myartifact_image> <quay-server.example.com>/<organization_name>/<repository>/<image_name>:<tag> - $ podman push <myartifact_image> <quay-server.example.com>/<organization_name>/<repository>/<image_name>:<tag>- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Enter the following command to attach a manifest using the OCI 1.1 referrers - APIschema with- oras:- oras attach --artifact-type <MIME_type> --distribution-spec v1.1-referrers-api <myartifact_image> \ <quay-server.example.com>/<organization_name>/<repository>/<image_name>:<tag> \ <example_file>.txt - $ oras attach --artifact-type <MIME_type> --distribution-spec v1.1-referrers-api <myartifact_image> \ <quay-server.example.com>/<organization_name>/<repository>/<image_name>:<tag> \ <example_file>.txt- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - Example output - Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Enter the following command to attach a manifest using the OCI 1.1 referrers - tagschema:- oras attach --artifact-type <MIME_type> --distribution-spec v1.1-referrers-tag \ <myartifact_image> <quay-server.example.com>/<organization_name>/<repository>/<image_name>:<tag> \ <example_file>.txt - $ oras attach --artifact-type <MIME_type> --distribution-spec v1.1-referrers-tag \ <myartifact_image> <quay-server.example.com>/<organization_name>/<repository>/<image_name>:<tag> \ <example_file>.txt- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - Example output - Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Enter the following command to discoverer referrers of the artifact using the - tagschema:- oras discover --insecure --distribution-spec v1.1-referrers-tag \ <quay-server.example.com>/<organization_name>/<repository>/<image_name>:<tag> - $ oras discover --insecure --distribution-spec v1.1-referrers-tag \ <quay-server.example.com>/<organization_name>/<repository>/<image_name>:<tag>- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - Example output - quay.io/testorg3/myartifact-image@sha256:db440c57edfad40c682f9186ab1c1075707ce7a6fdda24a89cb8c10eaad424da └── doc/example └── sha256:2d4b54201c8b134711ab051389f5ba24c75c2e6b0f0ff157fce8ffdfe104f383- quay.io/testorg3/myartifact-image@sha256:db440c57edfad40c682f9186ab1c1075707ce7a6fdda24a89cb8c10eaad424da └── doc/example └── sha256:2d4b54201c8b134711ab051389f5ba24c75c2e6b0f0ff157fce8ffdfe104f383- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Enter the following command to discoverer referrers of the artifact using the - APIschema:- oras discover --distribution-spec v1.1-referrers-api \ <quay-server.example.com>/<organization_name>/<repository>/<image_name>:<tag> - $ oras discover --distribution-spec v1.1-referrers-api \ <quay-server.example.com>/<organization_name>/<repository>/<image_name>:<tag>- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - Example output - Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Optional. You can also discover referrers by using the - /v2/<organization_name>/<repository_name>/referrers/<sha256_digest>endpoint. For this to work, you must generate a v2 API token and set- FEATURE_REFERRERS_API: truein your- config.yamlfile.- Update your - config.yamlfile to include the- FEATURE_REFERRERS_APIfield. For example:- # ... FEATURE_REFERRERS_API: true # ... - # ... FEATURE_REFERRERS_API: true # ...- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Enter the following command to Base64 encode your credentials: - echo -n '<username>:<password>' | base64 - $ echo -n '<username>:<password>' | base64- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - Example output - abcdeWFkbWluOjE5ODlraWROZXQxIQ== - abcdeWFkbWluOjE5ODlraWROZXQxIQ==- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Enter the following command to use the base64 encoded token and modify the URL endpoint to your Red Hat Quay server: - curl --location '<quay-server.example.com>/v2/auth?service=<quay-server.example.com>&scope=repository:quay/listocireferrs:pull,push' --header 'Authorization: Basic <base64_username:password_encode_token>' -k | jq - $ curl --location '<quay-server.example.com>/v2/auth?service=<quay-server.example.com>&scope=repository:quay/listocireferrs:pull,push' --header 'Authorization: Basic <base64_username:password_encode_token>' -k | jq- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - Example output - { "token": "<example_token_output>..." }- { "token": "<example_token_output>..." }- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
 
- Enter the following command, using the v2 API token, to list OCI referrers of a manifest under a repository: - GET https://<quay-server.example.com>/v2/<organization_name>/<repository_name>/referrers/sha256:0de63ba2d98ab328218a1b6373def69ec0d0e7535866f50589111285f2bf3fb8 - $ GET https://<quay-server.example.com>/v2/<organization_name>/<repository_name>/referrers/sha256:0de63ba2d98ab328218a1b6373def69ec0d0e7535866f50589111285f2bf3fb8 --header 'Authorization: Bearer <v2_bearer_token> -k | jq- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - Example output - Copy to Clipboard Copied! - Toggle word wrap Toggle overflow