Este contenido no está disponible en el idioma seleccionado.
Chapter 8. Operators
8.1. Using Operators with MicroShift Copiar enlaceEnlace copiado en el portapapeles!
You can use Operators with MicroShift to create applications that monitor the running services in your cluster. Operators can manage applications and their resources, such as deploying a database or message bus. As customized software running inside your cluster, Operators can be used to implement and automate common operations.
Operators offer a more localized configuration experience and integrate with Kubernetes APIs and CLI tools such as kubectl and oc. Operators are designed specifically for your applications. Operators enable you to configure components instead of modifying a global configuration file.
MicroShift applications are generally expected to be deployed in static environments. However, Operators are available if helpful in your use case. To determine the compatibility of an Operator with MicroShift, check the Operator documentation.
8.1.1. How to use Operators with MicroShift clusters Copiar enlaceEnlace copiado en el portapapeles!
There are two ways to use Operators for your MicroShift clusters:
8.1.1.1. Manifests for Operators Copiar enlaceEnlace copiado en el portapapeles!
Operators can be installed and managed directly by using manifests. You can use the kustomize configuration management tool with MicroShift to deploy an application. Use the same steps to install Operators with manifests.
- See Using Kustomize manifests to deploy applications and Using manifests example for details.
8.1.1.2. Operator Lifecycle Manager for Operators Copiar enlaceEnlace copiado en el portapapeles!
You can also install add-on Operators to a MicroShift cluster using Operator Lifecycle Manager (OLM). OLM can be used to manage both custom Operators and Operators that are widely available. Building catalogs is required to use OLM with MicroShift.
- For details, see Using Operator Lifecycle Manager with MicroShift.
8.2. Using Operator Lifecycle Manager with MicroShift Copiar enlaceEnlace copiado en el portapapeles!
The Operator Lifecycle Manager (OLM) package manager is used in MicroShift for installing and running optional add-on Operators.
8.2.1. Considerations for using OLM with MicroShift Copiar enlaceEnlace copiado en el portapapeles!
- Cluster Operators as applied in OpenShift Container Platform are not used in MicroShift.
You must create your own catalogs for the add-on Operators you want to use with your applications. Catalogs are not provided by default.
-
Each catalog must have an accessible
CatalogSourceadded to a cluster, so that the OLM catalog Operator can use the catalog for content.
-
Each catalog must have an accessible
You must use the CLI to conduct OLM activities with MicroShift. The console and OperatorHub GUIs are not available.
-
Use the Operator Package Manager
opmCLI with network-connected clusters, or for building catalogs for custom Operators that use an internal registry. - To mirror your catalogs and Operators for disconnected or offline clusters, install the oc-mirror OpenShift CLI plugin.
-
Use the Operator Package Manager
Before using an Operator, verify with the provider that the Operator is supported on Red Hat build of MicroShift.
8.2.2. Determining your OLM installation type Copiar enlaceEnlace copiado en el portapapeles!
You can install the OLM package manager for use with MicroShift 4.15 or newer versions. There are different ways to install OLM for MicroShift clusters, depending on your use case.
-
You can install the
microshift-olmRPM at the same time you install the MicroShift RPM on Red Hat Enterprise Linux (RHEL). -
You can install the
microshift-olmon an existing MicroShift 4.15. Restart the MicroShift service after installing OLM for the changes to apply. See Installing the Operator Lifecycle Manager (OLM) from an RPM package. - You can embed OLM in a Red Hat Enterprise Linux for Edge (RHEL for Edge) image. See Adding the Operator Lifecycle Manager (OLM) service to a blueprint.
8.2.3. Namespace use in MicroShift Copiar enlaceEnlace copiado en el portapapeles!
The microshift-olm RPM creates the three default namespaces: one for running OLM, and two for catalog and Operator installation. You can create additional namespaces as needed for your use case.
8.2.3.1. Default namespaces Copiar enlaceEnlace copiado en el portapapeles!
The following table lists the default namespaces and a brief description of how each namespace works.
| Default Namespace | Details |
|
| The OLM package manager runs in this namespace. |
|
|
The global namespace. Empty by default. To make the catalog source to be available globally to users in all namespaces, set the |
|
|
The default namespace where Operators run in MicroShift. Operators that reference catalogs in the |
8.2.3.2. Custom namespaces Copiar enlaceEnlace copiado en el portapapeles!
If you want to use a catalog and Operator together in a single namespace, then you must create a custom namespace. After you create the namespace, you must create the catalog in that namespace. All Operators running in the custom namespace must have the same single-namespace watch scope.
8.2.4. About building Operator catalogs Copiar enlaceEnlace copiado en el portapapeles!
To use Operator Lifecycle Manager (OLM) with MicroShift, you must build custom Operator catalogs that you can then manage with OLM. The standard catalogs that are included with OpenShift Container Platform are not included with MicroShift.
8.2.4.1. File-based Operator catalogs Copiar enlaceEnlace copiado en el portapapeles!
You can create catalogs for your custom Operators or filter catalogs of widely available Operators. You can combine both methods to create the catalogs needed for your specific use case. To run MicroShift with your own Operators and OLM, make a catalog by using the file-based catalog structure.
- For details, see Managing custom catalogs and Example catalog.
-
See also
opmCLI reference.
-
When adding a catalog source to a cluster, set the
securityContextConfigvalue torestrictedin thecatalogSource.yamlfile. Ensure that your catalog can run withrestrictedpermissions.
8.2.5. How to deploy Operators using OLM Copiar enlaceEnlace copiado en el portapapeles!
After you create and deploy your custom catalog, you must create a Subscription custom resource (CR) that can access the catalog and install the Operators you choose. Where Operators run depends on the namespace in which you create the Subscription CR.
Operators in OLM have a watch scope. For example, some Operators only support watching their own namespace, while others support watching every namespace in the cluster. All Operators installed in a given namespace must have the same watch scope.
8.2.5.1. Connectivity and OLM Operator deployment Copiar enlaceEnlace copiado en el portapapeles!
Operators can be deployed anywhere a catalog is running.
- For clusters that are connected to the internet, mirroring images is not required. Images can be pulled over the network.
- For restricted networks in which MicroShift has access to an internal network only, images must be mirrored to an internal registry.
-
For use cases in which MicroShift clusters are completely offline, all images must be embedded into an
osbuildblueprint.
8.2.5.2. Adding OLM-based Operators to a networked cluster using the global namespace Copiar enlaceEnlace copiado en el portapapeles!
To deploy different operators to different namespaces, use this procedure. For MicroShift clusters that have network connectivity, Operator Lifecycle Manager (OLM) can access sources hosted on remote registries. The following procedure lists the basic steps of using configuration files to install an Operator that uses the global namespace.
To use an Operator installed in a different namespace, or in more than one namespace, make sure that the catalog source and the Subscription CR that references the Operator are running in the openshift-marketplace namespace.
Prerequisites
-
The OpenShift CLI (
oc) is installed. - Operator Lifecycle Manager (OLM) is installed.
- You have created a custom catalog in the global namespace.
Procedure
Confirm that OLM is running by using the following command:
oc -n openshift-operator-lifecycle-manager get pod -l app=olm-operator
$ oc -n openshift-operator-lifecycle-manager get pod -l app=olm-operatorCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
NAME READY STATUS RESTARTS AGE olm-operator-85b5c6786-n6kbc 1/1 Running 0 2m24s
NAME READY STATUS RESTARTS AGE olm-operator-85b5c6786-n6kbc 1/1 Running 0 2m24sCopy to Clipboard Copied! Toggle word wrap Toggle overflow Confirm that the OLM catalog Operator is running by using the following command:
oc -n openshift-operator-lifecycle-manager get pod -l app=catalog-operator
$ oc -n openshift-operator-lifecycle-manager get pod -l app=catalog-operatorCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
NAME READY STATUS RESTARTS AGE catalog-operator-5fc7f857b6-tj8cf 1/1 Running 0 2m33s
NAME READY STATUS RESTARTS AGE catalog-operator-5fc7f857b6-tj8cf 1/1 Running 0 2m33sCopy to Clipboard Copied! Toggle word wrap Toggle overflow
The following steps assume you are using the global namespace, openshift-marketplace. The catalog must run in the same namespace as the Operator. The Operator must support the AllNamespaces mode.
Create the
CatalogSourceobject by using the following example YAML:Example catalog source YAML
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- The global namespace. Setting the
metadata.namespacetoopenshift-marketplaceenables the catalog to run in all namespaces. Subscriptions in any namespace can reference catalogs created in theopenshift-marketplacenamespace. - 2
- Community Operators are not installed by default with OLM for MicroShift. Listed here for example only.
- 3
- The value of
securityContextConfigmust be set torestrictedfor MicroShift.
Apply the
CatalogSourceconfiguration by running the following command:oc apply -f <my-catalog-source.yaml>
$ oc apply -f <my-catalog-source.yaml>1 Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Replace
<my-catalog-source.yaml>with your catalog source configuration file name. In this example,catalogsource.yamlis used.
Example output
catalogsource.operators.coreos.com/operatorhubio-catalog created
catalogsource.operators.coreos.com/operatorhubio-catalog createdCopy to Clipboard Copied! Toggle word wrap Toggle overflow To verify that the catalog source is applied, check for the
READYstate by using the following command:oc describe catalogsources.operators.coreos.com -n openshift-marketplace operatorhubio-catalog
$ oc describe catalogsources.operators.coreos.com -n openshift-marketplace operatorhubio-catalogCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- The status is reported as
READY.
Confirm that the catalog source is running by using the following command:
oc get pods -n openshift-marketplace -l olm.catalogSource=operatorhubio-catalog
$ oc get pods -n openshift-marketplace -l olm.catalogSource=operatorhubio-catalogCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
NAME READY STATUS RESTARTS AGE operatorhubio-catalog-x24nh 1/1 Running 0 59s
NAME READY STATUS RESTARTS AGE operatorhubio-catalog-x24nh 1/1 Running 0 59sCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create a Subscription CR configuration file by using the following example YAML:
Example Subscription custom resource YAML
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- The global namespace. Setting the
sourceNamespacevalue toopenshift-marketplaceenables Operators to run in multiple namespaces if the catalog also runs in theopenshift-marketplacenamespace.
Apply the Subscription CR configuration by running the following command:
oc apply -f <my-subscription-cr.yaml>
$ oc apply -f <my-subscription-cr.yaml>1 Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Replace
<my-subscription-cr.yaml>with your Subscription CR filename. In this example,sub.yamlis used.
Example output
subscription.operators.coreos.com/my-cert-manager created
subscription.operators.coreos.com/my-cert-manager createdCopy to Clipboard Copied! Toggle word wrap Toggle overflow - You can create a configuration file for the specific Operand you want to use and apply it now.
Verification
Verify that your Operator is running by using the following command:
oc get pods -n openshift-operators
$ oc get pods -n openshift-operators1 Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- The namespace from the Subscription CR is used.
NoteAllow a minute or two for the Operator start.
Example output
NAME READY STATUS RESTARTS AGE cert-manager-7df8994ddb-4vrkr 1/1 Running 0 19s cert-manager-cainjector-5746db8fd7-69442 1/1 Running 0 18s cert-manager-webhook-f858bf58b-748nt 1/1 Running 0 18s
NAME READY STATUS RESTARTS AGE cert-manager-7df8994ddb-4vrkr 1/1 Running 0 19s cert-manager-cainjector-5746db8fd7-69442 1/1 Running 0 18s cert-manager-webhook-f858bf58b-748nt 1/1 Running 0 18sCopy to Clipboard Copied! Toggle word wrap Toggle overflow
8.2.5.3. Adding OLM-based Operators to a networked cluster in a specific namespace Copiar enlaceEnlace copiado en el portapapeles!
Use this procedure if you want to specify a namespace for an Operator, for example, olm-microshift. In this example, the catalog is scoped and available in the global openshift-marketplace namespace. The Operator uses content from the global namespace, but runs only in the olm-microshift namespace. For MicroShift clusters that have network connectivity, Operator Lifecycle Manager (OLM) can access sources hosted on remote registries.
All of the Operators installed in a specific namespace must have the same watch scope. In this case, the watch scope is OwnNamespace.
Prerequisites
-
The OpenShift CLI (
oc) is installed. - Operator Lifecycle Manager (OLM) is installed.
- You have created a custom catalog that is running in the global namespace.
Procedure
Confirm that OLM is running by using the following command:
oc -n openshift-operator-lifecycle-manager get pod -l app=olm-operator
$ oc -n openshift-operator-lifecycle-manager get pod -l app=olm-operatorCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
NAME READY STATUS RESTARTS AGE olm-operator-85b5c6786-n6kbc 1/1 Running 0 16m
NAME READY STATUS RESTARTS AGE olm-operator-85b5c6786-n6kbc 1/1 Running 0 16mCopy to Clipboard Copied! Toggle word wrap Toggle overflow Confirm that the OLM catalog Operator is running by using the following command:
oc -n openshift-operator-lifecycle-manager get pod -l app=catalog-operator
$ oc -n openshift-operator-lifecycle-manager get pod -l app=catalog-operatorCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
NAME READY STATUS RESTARTS AGE catalog-operator-5fc7f857b6-tj8cf 1/1 Running 0 16m
NAME READY STATUS RESTARTS AGE catalog-operator-5fc7f857b6-tj8cf 1/1 Running 0 16mCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create a namespace by using the following example YAML:
Example namespace YAML
apiVersion: v1 kind: Namespace metadata: name: olm-microshift
apiVersion: v1 kind: Namespace metadata: name: olm-microshiftCopy to Clipboard Copied! Toggle word wrap Toggle overflow Apply the namespace configuration using the following command:
oc apply -f _<ns.yaml>_
$ oc apply -f _<ns.yaml>_1 Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Replace <ns.yaml> with the name of your namespace configuration file. In this example,
olm-microshiftis used.
Example output
namespace/olm-microshift created
namespace/olm-microshift createdCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create the Operator group YAML by using the following example YAML:
Example Operator group YAML
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- For Operators using the global namespace, omit the
spec.targetNamespacesfield and values.
Apply the Operator group configuration by running the following command:
oc apply -f _<og.yaml>_
$ oc apply -f _<og.yaml>_1 Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Replace <og.yaml> with the name of your operator group configuration file.
Example output
operatorgroup.operators.coreos.com/og created
operatorgroup.operators.coreos.com/og createdCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create the
CatalogSourceobject by using the following example YAML:Example catalog source YAML
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- The global namespace. Setting the
metadata.namespacetoopenshift-marketplaceenables the catalog to run in all namespaces. Subscriptions CRs in any namespace can reference catalogs created in theopenshift-marketplacenamespace. - 2
- Community Operators are not installed by default with OLM for MicroShift. Listed here for example only.
- 3
- The value of
securityContextConfigmust be set torestrictedfor MicroShift.
Apply the
CatalogSourceconfiguration by running the following command:oc apply -f _<my-catalog-source.yaml>_
$ oc apply -f _<my-catalog-source.yaml>_1 Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Replace <my-catalog-source.yaml> with your catalog source configuration file name.
To verify that the catalog source is applied, check for the
READYstate by using the following command:oc describe catalogsources.operators.coreos.com -n openshift-marketplace operatorhubio-catalog
$ oc describe catalogsources.operators.coreos.com -n openshift-marketplace operatorhubio-catalogCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- The status is reported as
READY.
Confirm that the catalog source is running by using the following command:
oc get pods -n openshift-marketplace -l olm.catalogSource=operatorhubio-catalog
$ oc get pods -n openshift-marketplace -l olm.catalogSource=operatorhubio-catalogCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
NAME READY STATUS RESTARTS AGE operatorhubio-catalog-j7sc8 1/1 Running 0 43s
NAME READY STATUS RESTARTS AGE operatorhubio-catalog-j7sc8 1/1 Running 0 43sCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create a Subscription CR configuration file by using the following example YAML:
Example Subscription custom resource YAML
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Apply the Subscription CR configuration by running the following command:
oc apply -f _<my-subscription-cr.yaml>_
$ oc apply -f _<my-subscription-cr.yaml>_Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
subscription.operators.coreos.com/my-gitlab-operator-kubernetes
subscription.operators.coreos.com/my-gitlab-operator-kubernetesCopy to Clipboard Copied! Toggle word wrap Toggle overflow - You can create a configuration file for the specific Operand you want to use and apply it now.
Verification
Verify that your Operator is running by using the following command:
oc get pods -n olm-microshift
$ oc get pods -n olm-microshift1 Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- The namespace from the Subscription CR is used.
NoteAllow a minute or two for the Operator start.
Example output
NAME READY STATUS RESTARTS AGE gitlab-controller-manager-69bb6df7d6-g7ntx 2/2 Running 0 3m24s
NAME READY STATUS RESTARTS AGE gitlab-controller-manager-69bb6df7d6-g7ntx 2/2 Running 0 3m24sCopy to Clipboard Copied! Toggle word wrap Toggle overflow
8.3. Creating custom catalogs using the oc-mirror plugin Copiar enlaceEnlace copiado en el portapapeles!
You can create custom catalogs with widely available Operators and mirror them by using the oc-mirror OpenShift CLI (oc) plugin.
8.3.1. Using Red Hat-provided Operator catalogs and mirror registries Copiar enlaceEnlace copiado en el portapapeles!
You can filter and prune catalogs to get specific Operators and mirror them by using the oc-mirror OpenShift CLI (oc) plugin. You can also use Operators in disconnected settings or embedded in Red Hat Enterprise Linux for Edge (RHEL for Edge) images. To read more details about how to configure your systems for mirroring, use the links in the following "Additional resources" section. If you are ready to deploy Operators from Red Hat-provided Operator catalogs, mirror them, or to embed them in RHEL for Edge images, start with the following section, "Inspecting catalog contents by using the oc-mirror plugin."
8.3.2. About the oc-mirror plugin for creating a mirror registry Copiar enlaceEnlace copiado en el portapapeles!
You can use the oc-mirror OpenShift CLI (oc) plugin with MicroShift to filter and prune Operator catalogs. You can then mirror the filtered catalog contents to a mirror registry or use the container images in disconnected or offline deployments with RHEL for Edge.
MicroShift uses the generally available version (1) of the oc-mirror plugin. Do not use the following procedures with the Technical Preview version (2) of oc-mirror plugin.
You can mirror the container images required by the desired Operators locally or to a container mirror registry that supports Docker v2-2, such as {quay}. The procedure to mirror content from Red Hat-hosted registries connected to the internet to a disconnected image registry is the same, independent of the registry you choose. After you mirror the contents of your catalog, configure each cluster to retrieve this content from your mirror registry.
8.3.2.1. Connectivity considerations when populating a mirror registry Copiar enlaceEnlace copiado en el portapapeles!
When you populate your registry, you can use one of following connectivity scenarios:
- Connected mirroring
- If you have a host that can access both the internet and your mirror registry, but not your cluster node, you can directly mirror the content from that machine.
- Disconnected mirroring
If you do not have a host that can access both the internet and your mirror registry, you must mirror the images to a file system and then bring that host or removable media into your disconnected environment.
ImportantA container registry must be reachable by every machine in the clusters that you provision. Installing, updating, and other operations, such as relocating workloads, might fail if the registry is unreachable.
To avoid problems caused by an unreachable registry, use the following standard practices:
- Run mirror registries in a highly available way.
- Ensure that the mirror registry at least matches the production availability of your clusters.
8.3.2.2. Inspecting catalog contents by using the oc-mirror plugin Copiar enlaceEnlace copiado en el portapapeles!
Use the following example procedure to select a catalog and list Operators from available OpenShift Container Platform content to add to your oc-mirror plugin image set configuration file.
If you use your own catalogs and Operators, you can push the images directly to your internal registry.
Prerequisites
-
The OpenShift CLI (
oc) is installed. - Operator Lifecycle Manager (OLM) is installed.
- The oc-mirror OpenShift CLI (oc) plugin is installed.
Procedure
Get a list of available Red Hat-provided Operator catalogs to filter by running the following command:
oc mirror list operators --version 4.15 --catalogs
$ oc mirror list operators --version 4.15 --catalogsCopy to Clipboard Copied! Toggle word wrap Toggle overflow Get a list of Operators in the Red Hat Operators catalog by running the following command:
oc mirror list operators <--catalog=<catalog_source>>
$ oc mirror list operators <--catalog=<catalog_source>>1 Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Specifies your catalog source, such as
registry.redhat.io/redhat/redhat-operator-index:v4.15orquay.io/operatorhubio/catalog:latest.
-
Select an Operator. For this example,
amq-broker-rhel8is selected. Optional: To inspect the channels and versions of the Operator you want to filter, enter the following commands:
Get a list of channels by running the following command:
oc mirror list operators --catalog=registry.redhat.io/redhat/redhat-operator-index:v4.15 --package=amq-broker-rhel8
$ oc mirror list operators --catalog=registry.redhat.io/redhat/redhat-operator-index:v4.15 --package=amq-broker-rhel8Copy to Clipboard Copied! Toggle word wrap Toggle overflow Get a list of versions within a channel by running the following command:
oc mirror list operators --catalog=registry.redhat.io/redhat/redhat-operator-index:v4.15 --package=amq-broker-rhel8 --channel=7.11.x
$ oc mirror list operators --catalog=registry.redhat.io/redhat/redhat-operator-index:v4.15 --package=amq-broker-rhel8 --channel=7.11.xCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Next steps
- Create and edit an image set configuration file using the information gathered in this procedure.
- Mirror the images from the transformed image set configuration file to a mirror registry or disk.
8.3.2.3. Creating an image set configuration file Copiar enlaceEnlace copiado en el portapapeles!
You must create an image set configuration file to mirror catalog contents with the oc-mirror plugin. The image set configuration file defines which Operators to mirror along with other configuration settings for the oc-mirror plugin. After generating a default image set file, you must edit the contents so that remaining entries are compatible with both MicroShift and the Operator you plan to use.
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 plugin stores metadata in this storage backend during image set creation.
Do not delete or modify the metadata that is generated by the oc-mirror plugin. You must use the same storage backend every time you run the oc-mirror plugin for the same mirror registry.
Prerequisites
- You have created a container image registry credentials file. See Configuring credentials that allow images to be mirrored.
Procedure
Use the
oc mirror initcommand to create a template for the image set configuration and save it to a file calledimageset-config.yaml:oc mirror init <--registry <storage_backend> > imageset-config.yaml
$ oc mirror init <--registry <storage_backend> > imageset-config.yaml1 Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Specifies the location of your storage backend, such as
example.com/mirror/oc-mirror-metadata.
Example default image set configuration file
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Edit the values of your image set configuration file to meet the requirements of both MicroShift and the Operator you want to mirror, like the following example:
Example edited MicroShift image set configuration file
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Set the backend location where the image set metadata is saved. This location can be a registry or local directory. It is required to specify
storageConfigvalues. - 2
- Set the registry URL for the storage backend, such as
<example.com/mirror/oc-mirror-metadata. - 3
- Set the Operator catalog to retrieve images from.
- 4
- Specify the Operator packages to include in the image set. Remove this field to retrieve all packages in the catalog.
- 5
- Specify only certain channels of the Operator packages to include in the image set. You must always include the default channel for the Operator package even if you do not use the bundles in that channel. You can find the default channel by running the following command:
oc mirror list operators --catalog=<catalog_name> --package=<package_name>.
- Save the updated file.
Next steps
- Use the oc-mirror plugin to mirror an image set directly to a target mirror registry.
- Configure CRI-O.
- Apply the catalog sources to your clusters.
8.3.2.3.1. Image set configuration parameters Copiar enlaceEnlace copiado en el portapapeles!
The oc-mirror plugin 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 configuration of the image set. | Object |
|
| The additional images configuration of the image set. | Array of objects. For example: additionalImages: - name: registry.redhat.io/ubi8/ubi:latest
|
|
| The tag or digest of the image to mirror. |
String. For example: |
|
| List of images with a tag or digest (SHA) to block from mirroring. |
Array of strings. For example: |
|
| The Operators configuration of the image set. | Array of objects. For example: operators:
- catalog: registry.redhat.io/redhat/redhat-operator-index:v4.15
packages:
- name: elasticsearch-operator
minVersion: '2.4.0'
|
|
| The Operator catalog to include in the image set. |
String. For example: |
|
|
When |
Boolean. The default value is |
|
| The Operator packages configuration. | Array of objects. For example: operators:
- catalog: registry.redhat.io/redhat/redhat-operator-index:v4.15
packages:
- name: elasticsearch-operator
minVersion: '5.2.3-31'
|
|
| The Operator package name to include in the image set |
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 highest version of the Operator mirror across all channels in which it exists. See the following note for further information. |
String. For example: |
|
| The name of the minimum bundle to include, plus all bundles in the update graph to the channel head. Set this field only if the named bundle has no semantic version metadata. |
String. For example: |
|
| The lowest version of the Operator to mirror across all channels in which it exists. See the following note for further information. |
String. For example: |
|
| The highest version of the Operator to mirror across all channels in which it exists. See the following note for further information. |
String. For example: |
|
| The lowest version of the Operator to mirror across all channels in which it exists. See the following note for further information. |
String. For example: |
|
|
If |
Boolean. The default value is |
|
| An alternative name and optional namespace hierarchy to mirror the referenced catalog as. |
String. For example: |
|
| An alternative name to mirror the referenced catalog as.
The |
String. For example: |
|
|
An alternative tag to append to the |
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 |
Using the minVersion and maxVersion properties to filter for a specific Operator version range can result in a multiple channel heads error. The error message states that there are multiple channel heads. This is because when the filter is applied, the update graph of the Operator is truncated.
Operator Lifecycle Manager requires that every Operator channel contains versions that form an update graph with exactly one end point, that is, the latest version of the Operator. When the filter range is applied, that graph can turn into two or more separate graphs or a graph that has more than one end point.
To avoid this error, do not filter out the latest version of an Operator. If you still run into the error, depending on the Operator, either the maxVersion property must be increased or the minVersion property must be decreased. Because every Operator graph can be different, you might need to adjust these values until the error resolves.
8.3.2.4. Mirroring from mirror to mirror Copiar enlaceEnlace copiado en el portapapeles!
You can use the oc-mirror plugin to mirror an image set directly to a target mirror registry that is accessible during image set creation.
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 plugin stores metadata in this storage backend during image set creation.
Do not delete or modify the metadata that is generated by the oc-mirror plugin. You must use the same storage backend every time you run the oc-mirror plugin for the same mirror registry.
Prerequisites
- You have access to the internet to get the necessary container images.
-
You have installed the OpenShift CLI (
oc). -
You have installed the
oc-mirrorCLI plugin. - You have created the image set configuration file.
Procedure
Run the
oc mirrorcommand to mirror the images from the specified image set configuration to a specified registry:oc mirror --config=./<imageset-config.yaml> \ docker://registry.example:5000
$ oc mirror --config=./<imageset-config.yaml> \1 docker://registry.example:50002 Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Specify the image set configuration file that you created. For example,
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.
Example output
Rendering catalog image "registry.example.com/redhat/redhat-operator-index:v{ocp-version}" with file-based catalog
Rendering catalog image "registry.example.com/redhat/redhat-operator-index:v{ocp-version}" with file-based catalog
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
ImageContentSourcePolicyandCatalogSourceresources.
The ImageContentSourcePolicy YAML file is used as reference content for manual configuration of CRI-O in MicroShift. You cannot apply the resource directly into a MicroShift cluster.
Next steps
-
Convert the
ImageContentSourcePolicyYAML content for use in manually configuring CRI-O. - If required, mirror the images from mirror to disk for disconnected or offline use.
- Configure your cluster to use the resources generated by oc-mirror.
Troubleshooting
8.3.2.5. Configuring CRI-O for using a registry mirror for Operators Copiar enlaceEnlace copiado en el portapapeles!
You must transform the imageContentSourcePolicy.yaml file created with the oc-mirror plugin into a format that is compatible with the CRI-O container runtime configuration used by MicroShift.
Prerequisites
-
The OpenShift CLI (
oc) is installed. - Operator Lifecycle Manager (OLM) is installed.
- The oc-mirror OpenShift CLI (oc) plugin is installed.
-
The
yqbinary is installed. -
ImageContentSourcePolicyandCatalogSourceYAML files are available in theoc-mirror-workspace/results-*directory.
Procedure
Confirm the contents of the
imageContentSourcePolicy.yamlfile by running the following command:cat oc-mirror-workspace/<results-directory>/imageContentSourcePolicy.yaml
$ cat oc-mirror-workspace/<results-directory>/imageContentSourcePolicy.yaml1 Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Specify the
resultsdirectory name, such as<results-1707148826>.
Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Transform the
imageContentSourcePolicy.yamlinto a format ready for CRI-O configuration by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
[[registry]] prefix = "registry.redhat.io/amq7" location = "registry.example.com/amq7" mirror-by-digest-only = true insecure = true[[registry]] prefix = "registry.redhat.io/amq7" location = "registry.example.com/amq7" mirror-by-digest-only = true insecure = trueCopy to Clipboard Copied! Toggle word wrap Toggle overflow Add the output to the CRI-O configuration file in the
/etc/containers/registries.conf.d/directory:Example
crio-config.yamlmirror configuration fileCopy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Specify the host name and port of your mirror registry server, for example
microshift-quay:8443.
Apply the CRI-O configuration changes by restarting MicroShift with the following command:
sudo systemctl restart crio
$ sudo systemctl restart crioCopy to Clipboard Copied! Toggle word wrap Toggle overflow
8.3.2.6. Installing a custom catalog created with the oc-mirror plugin Copiar enlaceEnlace copiado en el portapapeles!
After you mirror your image set to the mirror registry, you must apply the generated CatalogSource custom resource (CR) into the cluster. The CatalogSource CR is used by Operator Lifecycle Manager (OLM) to retrieve information about the available Operators in the mirror registry. You must then create and apply a subscription CR to subscribe to your custom catalog.
Prerequisites
- You mirrored the image set to your registry mirror.
- You added image reference information to the CRI-O container runtime configuration.
Procedure
Apply the catalog source configuration file from the results directory to create the catalog source object by running the following command:
oc apply -f ./oc-mirror-workspace/results-1708508014/catalogSource-cs-redhat-operator-index.yaml
$ oc apply -f ./oc-mirror-workspace/results-1708508014/catalogSource-cs-redhat-operator-index.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example catalog source configuration file
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Specifies the global namespace. Setting the
metadata.namespacetoopenshift-marketplaceenables the catalog to reference catalogs in all namespaces. Subscriptions in any namespace can reference catalogs created in theopenshift-marketplacenamespace.
Example output
catalogsource.operators.coreos.com/cs-redhat-operator-index created
catalogsource.operators.coreos.com/cs-redhat-operator-index createdCopy to Clipboard Copied! Toggle word wrap Toggle overflow Verify that the
CatalogSourceresources were successfully installed by running the following command:oc get catalogsource --all-namespaces
$ oc get catalogsource --all-namespacesCopy to Clipboard Copied! Toggle word wrap Toggle overflow Verify that the catalog source is running by using the following command:
oc get pods -n openshift-marketplace
$ oc get pods -n openshift-marketplaceCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
NAME READY STATUS RESTARTS AGE cs-redhat-operator-index-4227b 2/2 Running 0 2m5s
NAME READY STATUS RESTARTS AGE cs-redhat-operator-index-4227b 2/2 Running 0 2m5sCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create a
SubscriptionCR, similar to the following example:Example
SubscriptionCRCopy to Clipboard Copied! Toggle word wrap Toggle overflow Apply the Subscription CR configuration by running the following command:
oc apply -f ./<my-subscription-cr.yaml>
$ oc apply -f ./<my-subscription-cr.yaml>1 Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Specify the name of your subscription, such as
my-subscription-cr.yaml.
Example output
subscription.operators.coreos.com/amq-broker created
subscription.operators.coreos.com/amq-broker createdCopy to Clipboard Copied! Toggle word wrap Toggle overflow
8.4. Adding OLM-based Operators to a disconnected cluster Copiar enlaceEnlace copiado en el portapapeles!
You can use OLM-based Operators in disconnected situations by embedding them in a Red Hat Enterprise Linux for Edge (RHEL for Edge) image.
8.4.1. About adding OLM-based Operators to a disconnected cluster Copiar enlaceEnlace copiado en el portapapeles!
For Operators that are installed on disconnected clusters, Operator Lifecycle Manager (OLM) by default cannot access sources hosted on remote registries because those remote sources require full internet connectivity. Therefore, you must mirror the remote registries to a highly available container registry.
The following steps are required to use OLM-based Operators in disconnected situations:
- Include OLM in the container image list for your mirror registry.
-
Configure the system to use your mirror registry by updating your CRI-O configuration directly.
ImageContentSourcePolicyis not supported in MicroShift. -
Add a
CatalogSourceobject to the cluster so that the OLM catalog Operator can use the local catalog on the mirror registry. - Ensure that MicroShift is installed to run in a disconnected capacity.
- Ensure that the network settings are configured to run in disconnected mode.
After enabling OLM in a disconnected cluster, you can continue to use your internet-connected workstation to keep your local catalog sources updated as newer versions of Operators are released.
8.4.1.1. Performing a dry run Copiar enlaceEnlace copiado en el portapapeles!
You can use oc-mirror to perform a dry run, without actually mirroring any images. This allows you to review the list of images that would be mirrored, as well as any images that would be pruned from the mirror registry. A dry run also allows you to catch any errors with your image set configuration early or use the generated list of images with other tools to carry out the mirroring operation.
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-mirrorCLI plugin. - You have created the image set configuration file.
Procedure
Run the
oc mirrorcommand with the--dry-runflag to perform a dry run:oc mirror --config=./imageset-config.yaml \ docker://registry.example:5000 \ --dry-run
$ oc mirror --config=./imageset-config.yaml \1 docker://registry.example:5000 \2 --dry-run3 Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Pass in the image set configuration file that was created. This procedure assumes that it is named
imageset-config.yaml. - 2
- Specify the mirror registry. Nothing is mirrored to this registry as long as you use the
--dry-runflag. - 3
- Use the
--dry-runflag to generate the dry run artifacts and not an actual image set file.
Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Navigate into the workspace directory that was generated:
cd oc-mirror-workspace/
$ cd oc-mirror-workspace/Copy to Clipboard Copied! Toggle word wrap Toggle overflow Review the
mapping.txtfile that was generated.This file contains a list of all images that would be mirrored.
Review the
pruning-plan.jsonfile that was generated.This file contains a list of all images that would be pruned from the mirror registry when the image set is published.
NoteThe
pruning-plan.jsonfile is only generated if your oc-mirror command points to your mirror registry and there are images to be pruned.
8.4.1.2. Getting catalogs and Operator container image references to use with RHEL for Edge in disconnected environments Copiar enlaceEnlace copiado en el portapapeles!
After performing a dry run with the oc-mirror plugin to review the list of images that you want to mirror, you must get all of the container image references, then format the output for adding to an Image Builder blueprint.
For catalogs made for proprietary Operators, you can format image references for the Image Builder blueprint without using the following procedure.
Prerequisites
- You have a catalog index for the Operators you want to use.
-
You have installed the
jqCLI tool. - You are familiar with Image Builder blueprint files.
- You have an Image Builder blueprint TOML file.
Procedure
Parse the catalog
index.jsonfile to get the image references that you need to include in the Image Builder blueprint. You can use either the unfiltered catalog or you can filter out images that cannot be mirrored:Parse the unfiltered catalog
index.jsonfile to get the image references by running the following command:jq -r --slurp '.[] | select(.relatedImages != null) | "[[containers]]\nsource = \"" + .relatedImages[].image + "\"\n"' ./oc-mirror-workspace/src/catalogs/registry.redhat.io/redhat/redhat-operator-index/v4.15/index/index.json
jq -r --slurp '.[] | select(.relatedImages != null) | "[[containers]]\nsource = \"" + .relatedImages[].image + "\"\n"' ./oc-mirror-workspace/src/catalogs/registry.redhat.io/redhat/redhat-operator-index/v4.15/index/index.jsonCopy to Clipboard Copied! Toggle word wrap Toggle overflow If you want to filter out images that cannot be mirrored, filter and parse the catalog
index.jsonfile by running the following command:jq -r --slurp '.[] | select(.relatedImages != null) | .relatedImages[] | select(.name | contains("ppc") or contains("s390x") | not) | "[[containers]]\\nsource = \\"" + .image + "\\"\\n"' ./oc-mirror-workspace/src/catalogs/registry.redhat.io/redhat/redhat-operator-index/v4.15/index/index.json$ jq -r --slurp '.[] | select(.relatedImages != null) | .relatedImages[] | select(.name | contains("ppc") or contains("s390x") | not) | "[[containers]]\\nsource = \\"" + .image + "\\"\\n"' ./oc-mirror-workspace/src/catalogs/registry.redhat.io/redhat/redhat-operator-index/v4.15/index/index.jsonCopy to Clipboard Copied! Toggle word wrap Toggle overflow NoteThis step uses the AMQ Broker Operator as an example. You can add other criteria to the
jqcommand for further filtering as required by your use case.Example image-reference output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow ImportantFor mirrored and disconnected use cases, ensure that all of the sources filtered from your catalog
index.jsonfile are digests. If any of the sources use tags instead of digests, the Operator installation fails. Tags require an internet connection.
View the
imageset-config.yamlto get the catalog image reference for theCatalogSourcecustom resource (CR) by running the following command:cat imageset-config.yaml
$ cat imageset-config.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Use the value in the
mirror.catalogcatalog image reference for the follwingjqcommand to get the image digest. In this example, <registry.redhat.io/redhat/redhat-operator-index:v4.15>.
Get the SHA of the catalog index image by running the following command:
skopeo inspect docker://<registry.redhat.io/redhat/redhat-operator-index:v4.15> | jq `.Digest`
$ skopeo inspect docker://<registry.redhat.io/redhat/redhat-operator-index:v4.15> | jq `.Digest`1 Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Use the value in the
mirror.catalogcatalog image reference for thejqcommand to get the image digest. In this example, <registry.redhat.io/redhat/redhat-operator-index:v4.15>.
Example output
"sha256:7a76c0880a839035eb6e896d54ebd63668bb37b82040692141ba39ab4c539bc6"
"sha256:7a76c0880a839035eb6e896d54ebd63668bb37b82040692141ba39ab4c539bc6"Copy to Clipboard Copied! Toggle word wrap Toggle overflow To get ready to add the image references to your Image Builder blueprint file, format the catalog image reference by using the following example:
[[containers]] source = "registry.redhat.io/redhat/redhat-operator-index@sha256:7a76c0880a839035eb6e896d54ebd63668bb37b82040692141ba39ab4c539bc6"
[[containers]] source = "registry.redhat.io/redhat/redhat-operator-index@sha256:7a76c0880a839035eb6e896d54ebd63668bb37b82040692141ba39ab4c539bc6"Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add the image references from all the previous steps to the Image Builder blueprint.
Generated Image Builder blueprint example snippet
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- References for all non-optional MicroShift RPM packages using the same version compatible with the
microshift-release-infoRPM. - 2
- References for automatically enabling MicroShift on system startup and applying default networking settings.
- 3
- References for all non-optional MicroShift container images necessary for a disconnected deployment.
- 4
- References for the catalog index.
8.4.1.3. Applying catalogs and Operators in a disconnected-deployment RHEL for Edge image Copiar enlaceEnlace copiado en el portapapeles!
After you have created a RHEL for Edge image for a disconnected environment and configured MicroShift networking settings for disconnected use, you can configure the namespace and create catalog and Operator custom resources (CR) for running your Operators.
Prerequisites
- You have a RHEL for Edge image.
- Networking is configured for disconnected use.
- You completed the oc-mirror plugin dry run procedure.
Procedure
Create a
CatalogSourcecustom resource (CR), similar to the following example:Example
my-catalog-source-cr.yamlfileCopy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- The global namespace. Setting the
metadata.namespacetoopenshift-marketplaceenables the catalog to run in all namespaces. Subscriptions in any namespace can reference catalogs created in theopenshift-marketplacenamespace.
NoteThe default pod security admission definition for
openshift-marketplaceisbaseline, therefore a catalog source custom resource (CR) created in that namespace does not require aspec.grpcPodConfig.securityContextConfigvalue to be set. You can set alegacyorrestrictedvalue if required for the namespace and Operators you want to use.Add the SHA of the catalog index commit to the Catalog Source (CR), similar to the following example:
Example namespace
spec.imageconfigurationCopy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- The SHA of the image commit. Use the same SHA you added to the Image Builder blueprint.
ImportantYou must use the SHA instead of a tag in your catalog CR or the pod fails to start.
Apply the YAML file from the oc-mirror plugin dry run results directory to the cluster by running the following command:
oc apply -f ./oc-mirror-workspace/results-1708508014/catalogSource-cs-redhat-operator-index.yaml
$ oc apply -f ./oc-mirror-workspace/results-1708508014/catalogSource-cs-redhat-operator-index.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
catalogsource.operators.coreos.com/cs-redhat-operator-index created
catalogsource.operators.coreos.com/cs-redhat-operator-index createdCopy to Clipboard Copied! Toggle word wrap Toggle overflow Verify that the
CatalogSourceresources were successfully installed by running the following command:oc get catalogsource --all-namespaces
$ oc get catalogsource --all-namespacesCopy to Clipboard Copied! Toggle word wrap Toggle overflow Verify that the catalog source is running by using the following command:
oc get pods -n openshift-marketplace
$ oc get pods -n openshift-marketplaceCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
NAME READY STATUS RESTARTS AGE cs-redhat-operator-index-4227b 2/2 Running 0 2m5s
NAME READY STATUS RESTARTS AGE cs-redhat-operator-index-4227b 2/2 Running 0 2m5sCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create a
SubscriptionCR, similar to the following example:Example
my-subscription-cr.yamlfileCopy to Clipboard Copied! Toggle word wrap Toggle overflow Apply the
SubscriptionCR by running the following command:oc apply -f ./<my-subscription-cr.yaml>
$ oc apply -f ./<my-subscription-cr.yaml>1 Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Specify the name of your
SubscriptionCR, such asmy-subscription-cr.yaml.
Example output
subscription.operators.coreos.com/amq-broker created
subscription.operators.coreos.com/amq-broker createdCopy to Clipboard Copied! Toggle word wrap Toggle overflow