Questo contenuto non è disponibile nella lingua selezionata.
Chapter 6. Managing image streams
Image streams provide a means of creating and updating container images in an on-going way. As improvements are made to an image, tags can be used to assign new version numbers and keep track of changes. This document describes how image streams are managed.
6.1. Using image streams Copia collegamentoCollegamento copiato negli appunti!
Image streams provide an abstraction for referencing container images from within Red Hat OpenShift Service on AWS classic architecture. You can use image streams to manage image versions and automate builds and deployments.
Image streams do not contain actual image data, but present a single virtual view of related images, similar to an image repository.
You can configure builds and deployments to watch an image stream for notifications when new images are added and react by performing a build or deployment, respectively.
For example, if a deployment is using a certain image and a new version of that image is created, a deployment could be automatically performed to pick up the new version of the image.
However, if the image stream tag used by the deployment or build is not updated, then even if the container image in the container image registry is updated, the build or deployment continues using the previous, presumably known good image.
The source images can be stored in any of the following:
- Red Hat OpenShift Service on AWS classic architecture’s integrated registry.
- An external registry, for example registry.redhat.io or quay.io.
- Other image streams in the Red Hat OpenShift Service on AWS classic architecture cluster.
When you define an object that references an image stream tag, such as a build or deployment configuration, you point to an image stream tag and not the repository. When you build or deploy your application, Red Hat OpenShift Service on AWS classic architecture queries the repository using the image stream tag to locate the associated ID of the image and uses that exact image.
The image stream metadata is stored in the etcd instance along with other cluster information.
Using image streams has several significant benefits:
- You can tag, rollback a tag, and quickly deal with images, without having to re-push using the command line.
- You can trigger builds and deployments when a new image is pushed to the registry. Also, Red Hat OpenShift Service on AWS classic architecture has generic triggers for other resources, such as Kubernetes objects.
- You can mark a tag for periodic re-import. If the source image has changed, that change is picked up and reflected in the image stream, which triggers the build or deployment flow, depending upon the build or deployment configuration.
- You can share images using fine-grained access control and quickly distribute images across your teams.
- If the source image changes, the image stream tag still points to a known-good version of the image, ensuring that your application does not break unexpectedly.
- You can configure security around who can view and use the images through permissions on the image stream objects.
- Users that lack permission to read or list images on the cluster level can still retrieve the images tagged in a project using image streams.
6.2. Configuring image streams Copia collegamentoCollegamento copiato negli appunti!
To customize image retrieval and security policies for your applications, configure image streams within Red Hat OpenShift Service on AWS classic architecture. This process lets you define image pull specifications, manage tags, and control access permissions necessary for reliable application deployment.
An ImageStream object file contains the following elements.
Imagestream object definition
where
name- Specifies the name of the image stream
ruby-sample- Specifies the Docker repository path where new images can be pushed to add or update them in this image stream.
dockerImageReference- Specifies the SHA identifier that this image stream tag currently references. Resources that reference this image stream tag use this identifier
image- Specifies the SHA identifier that this image stream tag previously referenced. You can use it to rollback to an older image.
tag- Specifies the image stream tag name.
6.3. Image stream images Copia collegamentoCollegamento copiato negli appunti!
To precisely identify and manage the actual image content associated with a specific tag, reference and use image stream images in Red Hat OpenShift Service on AWS classic architecture. This ensures your application deployments reliably target immutable image definitions.
An image stream image points from within an image stream to a particular image ID.
Image stream images allow you to retrieve metadata about an image from a particular image stream where it is tagged.
Image stream image objects are automatically created in Red Hat OpenShift Service on AWS classic architecture whenever you import or tag an image into the image stream. You should never have to explicitly define an image stream image object in any image stream definition that you use to create image streams.
The image stream image consists of the image stream name and image ID from the repository, delimited by an @ sign:
<image-stream-name>@<image-id>
<image-stream-name>@<image-id>
To refer to the image in the ImageStream object example, the image stream image looks like:
origin-ruby-sample@sha256:47463d94eb5c049b2d23b03a9530bf944f8f967a0fe79147dd6b9135bf7dd13d
origin-ruby-sample@sha256:47463d94eb5c049b2d23b03a9530bf944f8f967a0fe79147dd6b9135bf7dd13d
6.4. Image stream tags Copia collegamentoCollegamento copiato negli appunti!
To maintain human-readable references to immutable images, utilize image stream tags within Red Hat OpenShift Service on AWS classic architecture. These tags are essential because they enable your builds and deployments to accurately target specific, stable image content.
An image stream tag is a named pointer to an image in an image stream. It is abbreviated as istag. An image stream tag is used to reference or retrieve an image for a given image stream and tag.
Image stream tags can reference any local or externally managed image. It contains a history of images represented as a stack of all images the tag ever pointed to. Whenever a new or existing image is tagged under a particular image stream tag, it is placed at the first position in the history stack. The image previously occupying the top position is available at the second position. This allows for easy rollbacks to make tags point to historical images again.
The following image stream tag is from an ImageStream object:
Image stream tag with two images in its history
Image stream tags can be permanent tags or tracking tags.
- Permanent tags are version-specific tags that point to a particular version of an image, such as Python 3.5.
Tracking tags are reference tags that follow another image stream tag and can be updated to change which image they follow, like a symlink. These new levels are not guaranteed to be backwards-compatible.
For example, the
latestimage stream tags that ship with Red Hat OpenShift Service on AWS classic architecture are tracking tags. This means consumers of thelatestimage stream tag are updated to the newest level of the framework provided by the image when a new level becomes available. Alatestimage stream tag tov3.10can be changed tov3.11at any time. It is important to be aware that theselatestimage stream tags behave differently than the Dockerlatesttag. Thelatestimage stream tag, in this case, does not point to the latest image in the Docker repository. It points to another image stream tag, which might not be the latest version of an image. For example, if thelatestimage stream tag points tov3.10of an image, when the3.11version is released, thelatesttag is not automatically updated tov3.11, and remains atv3.10until it is manually updated to point to av3.11image stream tag.NoteTracking tags are limited to a single image stream and cannot reference other image streams.
You can create your own image stream tags for your own needs.
The image stream tag is composed of the name of the image stream and a tag, separated by a colon:
<imagestream name>:<tag>
<imagestream name>:<tag>
For example, to refer to the sha256:47463d94eb5c049b2d23b03a9530bf944f8f967a0fe79147dd6b9135bf7dd13d image in the ImageStream object example earlier, the image stream tag would be:
origin-ruby-sample:latest
origin-ruby-sample:latest
6.5. Image stream change triggers Copia collegamentoCollegamento copiato negli appunti!
To automate your application lifecycle and ensure they use the latest code, configure image stream triggers in Red Hat OpenShift Service on AWS classic architecture. Image stream triggers allow your builds and deployments to be automatically invoked when a new version of an upstream image is available.
For example, builds and deployments can be automatically started when an image stream tag is modified. This is achieved by monitoring that particular image stream tag and notifying the build or deployment when a change is detected.
6.6. Working with image streams Copia collegamentoCollegamento copiato negli appunti!
The following sections describe how to use image streams and image stream tags.
Do not run workloads in or share access to default projects. Default projects are reserved for running core cluster components.
The following default projects are considered highly privileged: default, kube-public, kube-system, openshift, openshift-infra, openshift-node, and other system-created projects that have the openshift.io/run-level label set to 0 or 1. Functionality that relies on admission plugins, such as pod security admission, security context constraints, cluster resource quotas, and image reference resolution, does not work in highly privileged projects.
6.6.1. Getting information about image streams Copia collegamentoCollegamento copiato negli appunti!
To efficiently manage and monitor your image streams in Red Hat OpenShift Service on AWS classic architecture, retrieve information about their versions. You can get general information about the image stream and detailed information about all the tags it is pointing to, ensuring your deployed applications rely on the correct image versions.
Procedure
To get general information about the image stream and detailed information about all the tags it is pointing to, enter the following command:
oc describe is/<image-name>
$ oc describe is/<image-name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow For example:
oc describe is/python
$ oc describe is/pythonCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow To get all of the information available about a particular image stream tag, enter the following command:
oc describe istag/<image-stream>:<tag-name>
$ oc describe istag/<image-stream>:<tag-name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow For example:
oc describe istag/python:latest
$ oc describe istag/python:latestCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteMore information is output than shown.
Enter the following command to discover which architecture or operating system that an image stream tag supports:
oc get istag <image-stream-tag> -ojsonpath="{range .image.dockerImageManifests[*]}{.os}/{.architecture}{'\n'}{end}"$ oc get istag <image-stream-tag> -ojsonpath="{range .image.dockerImageManifests[*]}{.os}/{.architecture}{'\n'}{end}"Copy to Clipboard Copied! Toggle word wrap Toggle overflow For example:
oc get istag busybox:latest -ojsonpath="{range .image.dockerImageManifests[*]}{.os}/{.architecture}{'\n'}{end}"$ oc get istag busybox:latest -ojsonpath="{range .image.dockerImageManifests[*]}{.os}/{.architecture}{'\n'}{end}"Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
6.6.2. Adding tags to an image stream Copia collegamentoCollegamento copiato negli appunti!
To accurately manage and track specific versions of your container images, add tags to your image streams within Red Hat OpenShift Service on AWS classic architecture, This ensures reliable referencing and deployment throughout your environment.
Procedure
Add a tag that points to one of the existing tags by using the `oc tag`command:
oc tag <image-name:tag1> <image-name:tag2>
$ oc tag <image-name:tag1> <image-name:tag2>Copy to Clipboard Copied! Toggle word wrap Toggle overflow For example:
oc tag python:3.5 python:latest
$ oc tag python:3.5 python:latestCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Tag python:latest set to python@sha256:49c18358df82f4577386404991c51a9559f243e0b1bdc366df25.
Tag python:latest set to python@sha256:49c18358df82f4577386404991c51a9559f243e0b1bdc366df25.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Confirm the image stream has two tags, one,
3.5, pointing at the external container image and another tag,latest, pointing to the same image because it was created based on the first tag.oc describe is/python
$ oc describe is/pythonCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
6.6.3. Adding tags for an external image Copia collegamentoCollegamento copiato negli appunti!
To enable Red Hat OpenShift Service on AWS classic architecture resources to track and consume container images sourced from external registries, add tags to the corresponding image streams. This action integrates external image content securely into your cluster’s local image management system.
Procedure
Add tags pointing to internal or external images, by using the
oc tagcommand for all tag-related operations:oc tag <repository/image> <image-name:tag>
$ oc tag <repository/image> <image-name:tag>Copy to Clipboard Copied! Toggle word wrap Toggle overflow For example, this command maps the
docker.io/python:3.6.0image to the3.6tag in thepythonimage stream.oc tag docker.io/python:3.6.0 python:3.6
$ oc tag docker.io/python:3.6.0 python:3.6Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Tag python:3.6 set to docker.io/python:3.6.0.
Tag python:3.6 set to docker.io/python:3.6.0.Copy to Clipboard Copied! Toggle word wrap Toggle overflow If the external image is secured, you must create a secret with credentials for accessing that registry.
6.6.4. Updating image stream tags Copia collegamentoCollegamento copiato negli appunti!
To maintain flexibility and consistency in deployment definitions, update an image stream tag to reflect a different tag in Red Hat OpenShift Service on AWS classic architecture. Specifically, you can update a tag to reflect another tag in an image stream, which is essential for managing image versions effectively.
Procedure
Update a tag:
oc tag <image-name:tag> <image-name:latest>
$ oc tag <image-name:tag> <image-name:latest>Copy to Clipboard Copied! Toggle word wrap Toggle overflow For example, the following updates the
latesttag to reflect the3.6tag in an image stream:oc tag python:3.6 python:latest
$ oc tag python:3.6 python:latestCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Tag python:latest set to python@sha256:438208801c4806548460b27bd1fbcb7bb188273d13871ab43f.
Tag python:latest set to python@sha256:438208801c4806548460b27bd1fbcb7bb188273d13871ab43f.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
6.6.5. Removing image stream tags Copia collegamentoCollegamento copiato negli appunti!
To maintain control over your image history and simplify management within Red Hat OpenShift Service on AWS classic architecture, you can remove old tags from an image stream. This action helps ensure that your resources track only the current and necessary image references.
Procedure
Remove old tags from an image stream:
oc tag -d <image-name:tag>
$ oc tag -d <image-name:tag>Copy to Clipboard Copied! Toggle word wrap Toggle overflow For example:
oc tag -d python:3.6
$ oc tag -d python:3.6Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Deleted tag default/python:3.6
Deleted tag default/python:3.6Copy to Clipboard Copied! Toggle word wrap Toggle overflow
See Removing deprecated image stream tags from the Cluster Samples Operator for more information on how the Cluster Samples Operator handles deprecated image stream tags.
6.6.6. Configuring periodic importing of image stream tags Copia collegamentoCollegamento copiato negli appunti!
To maintain up-to-date image definitions from an external container image registry, configure periodic importing of image stream tags. This process allows you to quickly re-import images for critical security updates by using the --scheduled flag.
Procedure
Schedule importing images:
oc tag <repository/image> <image-name:tag> --scheduled
$ oc tag <repository/image> <image-name:tag> --scheduledCopy to Clipboard Copied! Toggle word wrap Toggle overflow For example:
oc tag docker.io/python:3.6.0 python:3.6 --scheduled
$ oc tag docker.io/python:3.6.0 python:3.6 --scheduledCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Tag python:3.6 set to import docker.io/python:3.6.0 periodically.
Tag python:3.6 set to import docker.io/python:3.6.0 periodically.Copy to Clipboard Copied! Toggle word wrap Toggle overflow This command causes Red Hat OpenShift Service on AWS classic architecture to periodically update this particular image stream tag. This period is a cluster-wide setting set to 15 minutes by default.
Remove the periodic check, re-run above command but omit the
--scheduledflag. This will reset its behavior to default.oc tag <repositiory/image> <image-name:tag>
$ oc tag <repositiory/image> <image-name:tag>Copy to Clipboard Copied! Toggle word wrap Toggle overflow
6.7. Importing and working with images and image streams Copia collegamentoCollegamento copiato negli appunti!
The following sections describe how to import, and work with, image streams.
6.7.1. Importing images and image streams from private registries Copia collegamentoCollegamento copiato negli appunti!
To securely manage content from external sources, configure your image streams to import tag and image metadata from private registries requiring authentication. This procedure is essential if you change the registry that the Cluster Samples Operator uses for pulling content to something other than the default registry.redhat.io.
When importing from insecure or secure registries, the registry URL defined in the secret must include the :80 port suffix or the secret is not used when attempting to import from the registry.
Procedure
You must create a
secretobject that is used to store your credentials by entering the following command:oc create secret generic <secret_name> --from-file=.dockerconfigjson=<file_absolute_path> --type=kubernetes.io/dockerconfigjson
$ oc create secret generic <secret_name> --from-file=.dockerconfigjson=<file_absolute_path> --type=kubernetes.io/dockerconfigjsonCopy to Clipboard Copied! Toggle word wrap Toggle overflow After the secret is configured, create the new image stream or enter the
oc import-imagecommand:oc import-image <imagestreamtag> --from=<image> --confirm
$ oc import-image <imagestreamtag> --from=<image> --confirmCopy to Clipboard Copied! Toggle word wrap Toggle overflow During the import process, Red Hat OpenShift Service on AWS classic architecture picks up the secrets and provides them to the remote party.
6.7.2. Working with manifest lists Copia collegamentoCollegamento copiato negli appunti!
To precisely manage multi-architecture or variant images contained within a manifest list, use the --import-mode flag with oc import-image or oc tag CLI commands. This functionality allows you to import a single sub-manifest, or all manifests, of a manifest list, providing fine-grained control over your image stream content.
In some cases, users might want to use sub-manifests directly. When oc adm prune images is run, or the CronJob pruner runs, they cannot detect when a sub-manifest list is used. As a result, an administrator using oc adm prune images, or the CronJob pruner, might delete entire manifest lists, including sub-manifests.
To avoid this limitation, you can use the manifest list by tag or by digest instead.
Procedure
Create an image stream that includes multi-architecture images, and sets the import mode to
PreserveOriginal, by entering the following command:oc import-image <multiarch-image-stream-tag> --from=<registry>/<project_name>/<image-name> \ --import-mode='PreserveOriginal' --reference-policy=local --confirm
$ oc import-image <multiarch-image-stream-tag> --from=<registry>/<project_name>/<image-name> \ --import-mode='PreserveOriginal' --reference-policy=local --confirmCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Alternatively, enter the following command to import an image with the
Legacyimport mode, which discards manifest lists and imports a single sub-manifest:oc import-image <multiarch-image-stream-tag> --from=<registry>/<project_name>/<image-name> \ --import-mode='Legacy' --confirm
$ oc import-image <multiarch-image-stream-tag> --from=<registry>/<project_name>/<image-name> \ --import-mode='Legacy' --confirmCopy to Clipboard Copied! Toggle word wrap Toggle overflow NoteThe
--import-mode=default value isLegacy. Excluding this value, or failing to specify eitherLegacyorPreserveOriginal, imports a single sub-manifest. An invalid import mode returns the following error:error: valid ImportMode values are Legacy or PreserveOriginal.
6.7.2.1. Configuring periodic importing of manifest lists Copia collegamentoCollegamento copiato negli appunti!
To maintain up-to-date image references for complex, multi-architecture images, configure periodic importing of manifest lists. To periodically re-import a manifest list, you can use the --scheduled flag, ensuring your image stream tracks the latest versions from external registries.
Procedure
Set the image stream to periodically update the manifest list by entering the following command:
oc import-image <multiarch-image-stream-tag> --from=<registry>/<project_name>/<image-name> \ --import-mode='PreserveOriginal' --scheduled=true
$ oc import-image <multiarch-image-stream-tag> --from=<registry>/<project_name>/<image-name> \ --import-mode='PreserveOriginal' --scheduled=trueCopy to Clipboard Copied! Toggle word wrap Toggle overflow
6.7.2.2. Configuring SSL/TLS when importing manifest lists Copia collegamentoCollegamento copiato negli appunti!
To control connection security and access policies for manifest lists sourced from external repositories, configure SSL/TLS settings during image importing. To configure SSL/TLS when importing a manifest list, you can use the --insecure flag to bypass standard certificate validation requirements if necessary.
Procedure
Set
--insecure=trueso that importing a manifest list skips SSL/TLS verification. For example:oc import-image <multiarch-image-stream-tag> --from=<registry>/<project_name>/<image-name> \ --import-mode='PreserveOriginal' --insecure=true
$ oc import-image <multiarch-image-stream-tag> --from=<registry>/<project_name>/<image-name> \ --import-mode='PreserveOriginal' --insecure=trueCopy to Clipboard Copied! Toggle word wrap Toggle overflow
6.7.3. Specifying architecture for --import-mode Copia collegamentoCollegamento copiato negli appunti!
To control the architecture of your imported images and ensure proper deployment, use the --import-mode= flag. You can swap your imported image stream between multi-architecture and single architecture by excluding or including the --import-mode= flag as needed.
Procedure
Run the following command to update your image stream from multi-architecture to single architecture by excluding the
--import-mode=flag:oc import-image <multiarch-image-stream-tag> --from=<registry>/<project_name>/<image-name>
$ oc import-image <multiarch-image-stream-tag> --from=<registry>/<project_name>/<image-name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Run the following command to update your image stream from single-architecture to multi-architecture:
oc import-image <multiarch_image_stream_tag> --from=<registry>/<project_name>/<image_name> \ --import-mode='PreserveOriginal'
$ oc import-image <multiarch_image_stream_tag> --from=<registry>/<project_name>/<image_name> \ --import-mode='PreserveOriginal'Copy to Clipboard Copied! Toggle word wrap Toggle overflow
6.7.4. Configuration fields for --import-mode Copia collegamentoCollegamento copiato negli appunti!
To implement multi-architecture image management using the --import-mode flag, reference the necessary configuration fields. These fields define precise parameters for selecting and importing specific manifests into your Red Hat OpenShift Service on AWS classic architecture cluster.
The following table describes the options available for the --import-mode= flag:
| Parameter | Description |
|---|---|
| Legacy |
The default option for
|
| PreserveOriginal | When specified, the original manifest is preserved. For manifest lists, the manifest list and all of its sub-manifests are imported. |