- Mirroring images for a disconnected installation using the oc-mirror plug-in
- About the oc-mirror plug-in
- About the mirror registry
- Prerequisites
- Preparing your mirror hosts
- Creating the image set configuration
- Mirroring an image set to a mirror registry
- Installing the ImageContentSourcePolicy and CatalogSource resources into the cluster
- Updating your mirror registry
- Image set configuration parameters
- Image set configuration examples
Mirroring images for a disconnected installation using the oc-mirror plug-in
You can ensure your clusters only use container images that satisfy your organizational controls on external content. Before you install a cluster on infrastructure that you provision in a restricted network, you must mirror the required container images into that environment. To mirror container images, you must have a registry for mirroring.
You can use the oc-mirror OpenShift CLI (oc
) plug-in to mirror images to a mirror registry in your fully or partially disconnected environments.
Mirroring images for disconnected environments using the oc-mirror plug-in is a Technology Preview feature only. Technology Preview features are not supported with Red Hat production service level agreements (SLAs) and might not be functionally complete. Red Hat does not recommend using them in production. These features provide early access to upcoming product features, enabling customers to test functionality and provide feedback during the development process. For more information about the support scope of Red Hat Technology Preview features, see https://access.redhat.com/support/offerings/techpreview/. |
The following steps outline the high-level workflow on how to use the oc-mirror plug-in to mirror images to a mirror registry:
Create an image set configuration file.
Mirror the image set to the mirror registry.
Install the
ImageContentSourcePolicy
andCatalogSource
resources that were generated by oc-mirror into the cluster.Repeat these steps to update your mirror registry as necessary.
About the oc-mirror plug-in
You can use the oc-mirror OpenShift CLI (oc
) plug-in to mirror all required OKD content and other images to your mirror registry by using a single tool. It provides the following features:
Provides a centralized method to mirror OKD releases, Operators, helm charts, and other images.
Maintains update paths for OKD and Operators.
Uses a declarative image set configuration file to include only the OKD releases, Operators, and images that your cluster needs.
Performs incremental mirroring, which reduces the size of future image sets.
When using the oc-mirror plug-in, you specify which content to mirror in an image set configuration file. In this YAML file, you can fine-tune the configuration to only include the OKD releases and Operators that your cluster needs. This reduces the amount of data that you need to download and transfer. The oc-mirror plug-in can also mirror arbitrary helm charts and additional container images to assist users in seamlessly synchronizing their workloads onto mirror registries.
The first time you run the oc-mirror plug-in, it populates your mirror registry with the required content to perform your disconnected cluster installation. In order for your disconnected cluster to continue receiving updates, you must keep your mirror registry updated. To update your mirror registry, you run the oc-mirror plug-in using the same configuration as the first time you ran it. The oc-mirror plug-in references the metadata from the storage backend and only downloads what has been released since the last time you ran the tool. This provides update paths for OKD and Operators and performs dependency resolution as required.
When using the oc-mirror CLI plug-in to populate a mirror registry, any further updates to the mirror registry must be made using the oc-mirror tool. |
About the mirror registry
You can mirror the images that are required for OKD installation and subsequent product updates to a container mirror registry that supports Docker v2-2, such as Red Hat Quay. If you do not have access to a large-scale container registry, you can use the mirror registry for Red Hat OpenShift, which is a small-scale container registry included with OKD subscriptions.
Regardless of your chosen registry, the procedure to mirror content from Red Hat hosted sites on the internet to an isolated image registry is the same. After you mirror the content, you configure each cluster to retrieve this content from your mirror registry.
The internal registry of the OKD cluster cannot be used as the target registry because it does not support pushing without a tag, which is required during the mirroring process. |
If choosing a container registry that is not the mirror registry for Red Hat OpenShift, it must be reachable by every machine in the clusters that you provision. If the registry is unreachable, installation, updating, or normal operations such as workload relocation might fail. For that reason, you must run mirror registries in a highly available way, and the mirror registries must at least match the production availability of your OKD clusters.
When you populate your mirror registry with OKD images, you can follow two scenarios. If you have a host that can access both the internet and your mirror registry, but not your cluster nodes, you can directly mirror the content from that machine. This process is referred to as connected mirroring. If you have no such host, you must mirror the images to a file system and then bring that host or removable media into your restricted environment. This process is referred to as disconnected mirroring.
For mirrored registries, to view the source of pulled images, you must review the Trying to access
log entry in the CRI-O logs. Other methods to view the image pull source, such as using the crictl images
command on a node, show the non-mirrored image name, even though the image is pulled from the mirrored location.
Red Hat does not test third party registries with OKD. |
Additional resources
- For information about viewing the CRI-O logs to view the image source, see Viewing the image pull source.
Prerequisites
You must have a container image registry that supports Docker v2-2 in the location that will host the OKD cluster, such as Red Hat Quay.
If you use Red Hat Quay, you must use version 3.6 or later with the oc-mirror plug-in. If you have an entitlement to Red Hat Quay, see the documentation on deploying Red Hat Quay for proof-of-concept purposes or by using the Quay Operator. If you need additional assistance selecting and installing a registry, contact your sales representative or Red Hat Support.
If you do not already have an existing solution for a container image registry, subscribers of OKD are provided a mirror registry for Red Hat OpenShift. The mirror registry for Red Hat OpenShift is included with your subscription and is a small-scale container registry that can be used to mirror the required container images of OKD in disconnected installations.
Preparing your mirror hosts
Before you can use the oc-mirror plug-in to mirror images, you must install the plug-in and create a container image registry credentials file to allow the mirroring from Red Hat to your mirror.
Installing the oc-mirror OpenShift CLI plug-in
To use the oc-mirror OpenShift CLI plug-in to mirror registry images, you must install the plug-in. If you are mirroring image sets in a fully disconnected environment, ensure that you install the oc-mirror plug-in on the host with internet access and the host in the disconnected environment with access to the mirror registry.
Prerequisites
- You have installed the OpenShift CLI (
oc
).
Procedure
Download the oc-mirror CLI plug-in.
Navigate to the Downloads page of the OpenShift Cluster Manager.
Under the OpenShift disconnected installation tools section, click Download for OpenShift Client (oc) mirror plugin and save the file.
Extract the archive:
$ tar xvzf oc-mirror.tar.gz
If necessary, update the plug-in file to be executable:
$ chmod +x oc-mirror
Do not rename the
oc-mirror
file.Install the oc-mirror CLI plug-in by placing the file in your
PATH
, for example,/usr/local/bin
:$ sudo mv oc-mirror /usr/local/bin/.
Verification
Run
oc mirror help
to verify that the plug-in was successfully installed:$ oc mirror help
Additional resources
Configuring credentials that allow images to be mirrored
Create a container image registry credentials file that allows mirroring images from Red Hat to your mirror.
Do not use this image registry credentials file as the pull secret when you install a cluster. If you provide this file when you install cluster, all of the machines in the cluster will have write access to your mirror registry. |
This process requires that you have write access to a container image registry on the mirror registry and adds the credentials to a registry pull secret. |
Prerequisites
You configured a mirror registry to use in your restricted network.
You identified an image repository location on your mirror registry to mirror images into.
You provisioned a mirror registry account that allows images to be uploaded to that image repository.
Procedure
Complete the following steps on the installation host:
Generate the base64-encoded user name and password or token for your mirror registry:
$ echo -n '<user_name>:<password>' | base64 -w0 (1)
BGVtbYk3ZHAtqXs=
1 For <user_name>
and<password>
, specify the user name and password that you configured for your registry.Create a
.json
file and add a section that describes your registry to it:{
"auths": {
"<mirror_registry>": { (1)
"auth": "<credentials>", (2)
"email": "you@example.com"
}
}
}
1 For <mirror_registry>
, specify the registry domain name, and optionally the port, that your mirror registry uses to serve content. For example,registry.example.com
orregistry.example.com:5000
2 For <credentials>
, specify the base64-encoded user name and password for the mirror registry.
Creating the image set configuration
Before you can use the oc-mirror plug-in to mirror image sets, you must create an image set configuration file. This image set configuration file defines which OKD releases, Operators, and other images to mirror, along with other configuration settings for the oc-mirror plug-in.
You must specify a storage backend in the image set configuration file. This storage backend can be a local directory or a registry that supports Docker v2-2. The oc-mirror plug-in stores metadata in this storage backend during image set creation.
Do not delete or modify the metadata that is generated by the oc-mirror plug-in. You must use the same storage backend every time you run the oc-mirror plug-in for the same mirror registry. |
Procedure
Create an
ImageSetConfiguration
resource that specifies the necessary configuration details:Example
ImageSetConfiguration
fileapiVersion: mirror.openshift.io/v1alpha1
kind: ImageSetConfiguration
archiveSize: 4 (1)
mirror:
ocp:
channels:
- name: stable-4.9 (2)
operators:
- catalog: registry.redhat.io/redhat/redhat-operator-index:v4.9 (3)
storageConfig: (4)
registry:
imageURL: example.com/example/oc-mirror (5)
1 The maximum size, in GiB, of each file within the image set. 2 The channel to retrieve the OKD images from. 3 The Operator catalog to retrieve the OKD images from. 4 The back-end location to save the image set metadata to. This location can be a registry or local directory. It is required to specify storageConfig
values.5 The registry URL for the storage backend. This example pulls images from the
stable-4.9
channel for theregistry.redhat.io/redhat/redhat-operator-index:v4.9
operator catalog and saves the image set metadata to theexample.com/example/oc-mirror
registry.Save the file as
imageset-config.yaml
. This file is required by theoc mirror
command when mirroring content.
Additional resources
Mirroring an image set to a mirror registry
You can use the oc-mirror CLI plug-in to mirror images to a mirror registry in a partially disconnected environment or in a fully disconnected environment.
These procedures assume that you already have your mirror registry set up.
Mirroring an image set in a partially disconnected environment
In a partially disconnected environment, you can mirror an image set directly to the target mirror registry.
Mirroring from mirror to mirror
You can use the oc-mirror plug-in to mirror an image set directly to a target mirror registry that is accessible during image set creation.
Depending on the configuration specified in the image set configuration file, using oc-mirror to mirror images might download several hundreds of gigabytes of data to disk before mirroring to the destination mirror registry. The initial image set download when you populate the mirror registry is often the largest. Because you only download the images that changed since the last time you ran the command, when you run the oc-mirror plug-in again, the generated image set is often smaller. |
You are required to specify a storage backend in the image set configuration file. This storage backend can be a local directory or a Docker v2 registry. The oc-mirror plug-in stores metadata in this storage backend during image set creation.
Do not delete or modify the metadata that is generated by the oc-mirror plug-in. You must use the same storage backend every time you run the oc-mirror plug-in for the same mirror registry. |
Prerequisites
You have access to the internet to obtain the necessary container images.
You have installed the OpenShift CLI (
oc
).You have installed the
oc-mirror
CLI plug-in.You have created the image set configuration file.
Procedure
Run the
oc mirror
command to mirror the images from the specified image set configuration to a specified registry:$ oc mirror --config=./imageset-config.yaml \ (1)
docker://registry.example:5000 (2)
1 Pass in the image set configuration file that was created. This procedure assumes that it is named imageset-config.yaml
.2 Specify the registry to mirror the image set file to. The registry must start with docker://
. If you specify a top-level namespace for the mirror registry, you must also use this same namespace on subsequent executions.
Verification
Navigate into the
oc-mirror-workspace/
directory that was generated.Navigate into the results directory, for example,
results-1639608409/
.Verify that YAML files are present for the
ImageContentSourcePolicy
andCatalogSource
resources.
Next steps
- Install the
ImageContentSourcePolicy
andCatalogSource
resources into the cluster.
Mirroring an image set in a fully disconnected environment
To mirror an image set in a fully disconnected environment, you must first mirror the image set to disk, then mirror the image set file on disk to a mirror.
Mirroring from mirror to disk
You can use the oc-mirror plug-in to generate an image set and save the contents to disk. The generated image set can then be transferred to the disconnected environment and mirrored to the target registry.
Depending on the configuration specified in the image set configuration file, using oc-mirror to mirror images might download several hundreds of gigabytes of data to disk. The initial image set download when you populate the mirror registry is often the largest. Because you only download the images that changed since the last time you ran the command, when you run the oc-mirror plug-in again, the generated image set is often smaller. |
You are required to specify a storage backend in the image set configuration file. This storage backend can be a local directory or a docker v2 registry. The oc-mirror plug-in stores metadata in this storage backend during image set creation.
Do not delete or modify the metadata that is generated by the oc-mirror plug-in. You must use the same storage backend every time you run the oc-mirror plug-in for the same mirror registry. |
Prerequisites
You have access to the internet to obtain the necessary container images.
You have installed the OpenShift CLI (
oc
).You have installed the
oc-mirror
CLI plug-in.You have created the image set configuration file.
Procedure
Run the
oc mirror
command to mirror the images from the specified image set configuration to disk:$ oc mirror --config=./imageset-config.yaml \ (1)
file://<path_to_output_directory> (2)
1 Pass in the image set configuration file that was created. This procedure assumes that it is named imageset-config.yaml
.2 Specify the target directory where you want to output the image set file. The target directory path must start with file://
.
Verification
Navigate to your output directory:
$ cd <path_to_output_directory>
Verify that an image set
.tar
file was created:$ ls
Example output
mirror_seq1_000000.tar
Next steps
- Transfer the image set .tar file to the disconnected environment.
Mirroring from disk to mirror
You can use the oc-mirror plug-in to mirror the contents of a generated image set to the target mirror registry.
Prerequisites
You have installed the OpenShift CLI (
oc
) in the disconnected environment.You have installed the
oc-mirror
CLI plug-in in the disconnected environment.You have generated the image set file by using the
oc mirror
command.You have transferred the image set file to the disconnected environment.
Procedure
Run the
oc mirror
command to process the image set file on disk and mirror the contents to a target mirror registry:$ oc mirror --from=./mirror_seq1_000000.tar \ (1)
docker://registry.example:5000 (2)
1 Pass in the image set .tar file to mirror, named mirror_seq1_000000.tar
in this example. If anarchiveSize
value was specified in the image set configuration file, the image set might be broken up into multiple .tar files. In this situation, you can pass in a directory that contains the image set .tar files.2 Specify the registry to mirror the image set file to. The registry must start with docker://
. If you specify a top-level namespace for the mirror registry, you must also use this same namespace on subsequent executions.This command updates the mirror registry with the image set and generates the
ImageContentSourcePolicy
andCatalogSource
resources.
Verification
Navigate into the
oc-mirror-workspace/
directory that was generated.Navigate into the results directory, for example,
results-1639608409/
.Verify that YAML files are present for the
ImageContentSourcePolicy
andCatalogSource
resources.
Next steps
- Install the
ImageContentSourcePolicy
andCatalogSource
resources into the cluster.
Installing the ImageContentSourcePolicy and CatalogSource resources into the cluster
After you have mirrored your image set to the mirror registry, you must install the generated ImageContentSourcePolicy
and CatalogSource
resources into the cluster.
The ImageContentSourcePolicy
resource associates the mirror registry with the source registry and redirects image pull requests from the online registries to the mirror registry. The CatalogSource
resource is used by Operator Lifecycle Manager (OLM) to retrieve information about the available Operators in the mirror registry.
Prerequisites
You have mirrored the image set to the registry mirror in the disconnected environment.
You have access to the cluster as a user with the
cluster-admin
role.
Procedure
Log in to the OpenShift CLI as a user with the
cluster-admin
role.Apply the YAML files from the results directory to the cluster:
$ oc apply -f ./oc-mirror-workspace/results-1639608409/
Verification
Verify that the
ImageContentSourcePolicy
resources were successfully installed:$ oc get imagecontentsourcepolicy --all-namespaces
Verify that the
CatalogSource
resources were successfully installed:$ oc get catalogsource --all-namespaces
Updating your mirror registry
After you publish a full image set to the mirror registry, you can use the oc-mirror plug-in to update the mirror registry with updated images.
When you run the oc-mirror plug-in again, it generates an image set that only contains new and updated images since the previous execution.
You must use the same storage backend as the initial execution of oc-mirror for the same mirror registry. Do not delete or modify the metadata that is generated by the oc-mirror plug-in. |
Because it only pulls in the differences since the previous image set was created, the generated image set is often smaller and faster to process than the initial image set.
Generated image sets are sequential and must be synchronized to the target mirror registry in order. |
Prerequisites
You have used the oc-mirror plug-in to mirror the initial image set to your mirror registry.
You have access to the storage backend that was used for the initial execution of the oc-mirror plug-in.
Procedure
Follow the same steps that you used to create the initial image set and mirror it to the mirror registry. For instructions, see Mirroring an image set in a partially disconnected environment or Mirroring an image set in a fully disconnected environment.
You must provide the same storage backend so that only a differential image set is created and mirrored.
If you specified a top-level namespace for the mirror registry during the initial image set creation, then you must use this same namespace every time you run the oc-mirror plug-in for the same mirror registry.
Install the
ImageContentSourcePolicy
andCatalogSource
resources into the cluster.
Additional resources
Mirroring an image set in a partially disconnected environment
Installing the ImageContentSourcePolicy and CatalogSource resources into the cluster
Image set configuration parameters
The oc-mirror plug-in requires an image set configuration file that defines what images to mirror. The following table lists the available parameters for the ImageSetConfiguration
resource.
Parameter | Description | Values |
---|---|---|
| The API version for the | String. For example: |
| The maximum size, in GiB, of each archive file within the image set. | Integer. For example: |
| The configuration of the image set. | Object |
| The additional images configuration of the image set. | Array of objects. For example:
|
| The tag of the image to mirror. | String. For example: |
| The helm configuration of the image set. Note that the oc-mirror plug-in supports only helm charts that do not require user input when rendered. | Object |
| The local helm charts to mirror. | Array of objects. For example:
|
| The name of the local helm chart to mirror. | String. For example: |
| The path of the local helm chart to mirror. | String. For example: |
| The remote helm repositories to mirror from. | Array of objects. For example:
|
| The name of the helm repository to mirror from. | String. For example: |
| The URL of the helm repository to mirror from. | String. For example: |
| The remote helm charts to mirror. | Array of objects. |
| The name of the helm chart to mirror. | String. For example: |
| The version of the named helm chart to mirror. | String. For example: |
| The platform configuration of the image set. | Object |
| The platform channel configuration of the image set. | Array of objects. For example:
|
| The name of the release channel. | String. For example: |
| The list of release versions within the named channel. | String. For example: |
| The Operators configuration of the image set. | Array of objects. For example:
|
| The Operator catalog to include in the image set. | String. For example: |
| Toggles between downloading channel HEADs and full channels. Cannot be used in conjunction with | Boolean |
| The Operator packages configuration. | Array of objects. For example:
|
| The Operator package name to include in the image set | String. For example: |
| The starting version of the Operator package to mirror. All versions of the Operator are mirrored between the value of | String. For example: |
| The Operator package channel configuration. | Object |
| The Operator channel name, unique within a package, to include in the image set. | String. For example: |
| The starting version of the Operator channel to mirror. All versions of the Operator are mirrored between the value of | String. For example: |
| The back-end configuration of the image set. | Object |
| The local back-end configuration of the image set. | Object |
| The path of the directory to contain the image set metadata. | String. For example: |
| The registry back-end configuration of the image set. | Object |
| The back-end registry URI. Can optionally include a namespace reference in the URI. | String. For example: |
| Optionally skip TLS verification of the referenced back-end registry. | Boolean. The default value is |
Image set configuration examples
The following ImageSetConfiguration
file examples show the configuration for various mirroring use cases.
Use case: Including arbitrary images and helm charts
The following ImageSetConfiguration
file uses a registry storage backend and includes helm charts and an additional Red Hat Universal Base Image (UBI).
Example ImageSetConfiguration
file
apiVersion: mirror.openshift.io/v1alpha1
kind: ImageSetConfiguration
archiveSize: 4
storageConfig:
registry:
imageURL: example.com/example/oc-mirror
skipTLS: false
mirror:
ocp:
channels:
- name: stable-4.9
operators:
- catalog: registry.redhat.io/redhat/redhat-operator-index:v4.9
helm:
repos:
- name: redhat-helm-charts
url: https://raw.githubusercontent.com/redhat-developer/redhat-helm-charts/master
charts:
- name: ibm-mongodb-enterprise-helm
version: 0.2.0
additionalImages:
- name: registry.redhat.io/ubi8/ubi:latest
Use case: Including specific Operator versions
The following ImageSetConfiguration
file uses a local storage backend and includes only the Red Hat Advanced Cluster Security for Kubernetes Operator, versions starting at 3.67.0 and later.
Example ImageSetConfiguration
file
apiVersion: mirror.openshift.io/v1alpha1
kind: ImageSetConfiguration
storageConfig:
local:
path: /home/user/metadata
mirror:
operators:
- catalog: registry.redhat.io/redhat/redhat-operator-index:v4.9
headsOnly: false
packages:
- name: rhacs-operator
channels:
- name: latest
startingVersion: 3.67.0