8.4. Adding OLM-based Operators to a disconnected cluster
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 リンクのコピーリンクがクリップボードにコピーされました!
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 リンクのコピーリンクがクリップボードにコピーされました!
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 \1 docker://registry.example:5000 \2 --dry-run3 - 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
Checking push permissions for registry.example:5000 Creating directory: oc-mirror-workspace/src/publish Creating directory: oc-mirror-workspace/src/v2 Creating directory: oc-mirror-workspace/src/charts Creating directory: oc-mirror-workspace/src/release-signatures No metadata detected, creating new workspace wrote mirroring manifests to oc-mirror-workspace/operators.1658342351/manifests-redhat-operator-index ... info: Planning completed in 31.48s info: Dry run complete Writing image mapping to oc-mirror-workspace/mapping.txtNavigate into the workspace directory that was generated:
$ cd oc-mirror-workspace/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.
注記The
pruning-plan.jsonfile is only generated if your oc-mirror command points to your mirror registry and there are images to be pruned.
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.17/index/index.jsonIf 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.17/index/index.json注記This 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
[[containers]] source = "registry.redhat.io/amq7/amq-broker-init-rhel8@sha256:0b2126cfb6054fdf428c1f43b69e36e93a09a49ce15350e9273c98cc08c6598b" [[containers]] source = "registry.redhat.io/amq7/amq-broker-init-rhel8@sha256:0dde839c2dce7cb684094bf26523c8e16677de03149a0fff468b8c3f106e1f4f" ... ... [[containers]] source = "registry.redhat.io/amq7/amq-broker-rhel8@sha256:e8fa2a00e576ecb95561ffbdbf87b1c82d479c8791ab2c6ce741dd0d0b496d15" [[containers]] source = "registry.redhat.io/amq7/amq-broker-rhel8@sha256:ff6fefad518a6c997d4c5a6e475ba89640260167f0bc27715daf3cc30116fad1" … EOF重要For 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.yamlExample output
kind: ImageSetConfiguration apiVersion: mirror.openshift.io/v1alpha2 storageConfig: registry: imageURL: registry.example.com/microshift-mirror mirror: operators: - catalog: registry.redhat.io/redhat/redhat-operator-index:v4.171 packages: - name: amq-broker-rhel8 channels: - name: 7.11.x- 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.17>.
Get the SHA of the catalog index image by running the following command:
$ skopeo inspect docker://<registry.redhat.io/redhat/redhat-operator-index:v4.17> | jq `.Digest`1 - 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.17>.
Example output
"sha256:7a76c0880a839035eb6e896d54ebd63668bb37b82040692141ba39ab4c539bc6"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"Add the image references from all the previous steps to the Image Builder blueprint.
Generated Image Builder blueprint example snippet
name = "microshift_blueprint" description = "MicroShift 4.17.1 on x86_64 platform" version = "0.0.1" modules = [] groups = [] [[packages]]1 name = "microshift" version = "4.17.1" ... ... [customizations.services]2 enabled = ["microshift"] [customizations.firewall] ports = ["22:tcp", "80:tcp", "443:tcp", "5353:udp", "6443:tcp", "30000-32767:tcp", "30000-32767:udp"] ... ... [[containers]]3 source = "quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:f41e79c17e8b41f1b0a5a32c3e2dd7cd15b8274554d3f1ba12b2598a347475f4" [[containers]] source = "quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:dbc65f1fba7d92b36cf7514cd130fe83a9bd211005ddb23a8dc479e0eea645fd" ... ... [[containers]]4 source = "registry.redhat.io/redhat/redhat-operator-index@sha256:7a76c0880a839035eb6e896d54ebd63668bb37b82040692141ba39ab4c539bc6" ... ... [[containers]] source = "registry.redhat.io/amq7/amq-broker-init-rhel8@sha256:0dde839c2dce7cb684094bf26523c8e16677de03149a0fff468b8c3f106e1f4f" ... ... [[containers]] source = "registry.redhat.io/amq7/amq-broker-rhel8@sha256:e8fa2a00e576ecb95561ffbdbf87b1c82d479c8791ab2c6ce741dd0d0b496d15" [[containers]] source = "registry.redhat.io/amq7/amq-broker-rhel8@sha256:ff6fefad518a6c997d4c5a6e475ba89640260167f0bc27715daf3cc30116fad1" … EOF- 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 リンクのコピーリンクがクリップボードにコピーされました!
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.yamlfileapiVersion: operators.coreos.com/v1alpha1 kind: CatalogSource metadata: name: cs-redhat-operator-index namespace: openshift-marketplace1 spec: image: registry.example.com/redhat/redhat-operator-index:v4.17 sourceType: grpc displayName: publisher: updateStrategy: registryPoll: interval: 60m- 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.
注記The 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.imageconfigurationapiVersion: operators.coreos.com/v1alpha1 kind: CatalogSource metadata: name: cs-redhat-operator-index namespace: openshift-marketplace spec: image: registry.example.com/redhat/redhat-operator-index@sha256:7a76c0880a839035eb6e896d54ebd63668bb37b82040692141ba39ab4c539bc61 sourceType: grpc displayName: publisher: updateStrategy: registryPoll: interval: 60m- 1
- The SHA of the image commit. Use the same SHA you added to the image builder blueprint.
重要You 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.yamlExample output
catalogsource.operators.coreos.com/cs-redhat-operator-index createdVerify that the
CatalogSourceresources were successfully installed by running the following command:$ oc get catalogsource --all-namespacesVerify that the catalog source is running by using the following command:
$ oc get pods -n openshift-marketplaceExample output
NAME READY STATUS RESTARTS AGE cs-redhat-operator-index-4227b 2/2 Running 0 2m5sCreate a
SubscriptionCR, similar to the following example:Example
my-subscription-cr.yamlfileapiVersion: operators.coreos.com/v1alpha1 kind: Subscription metadata: name: amq-broker namespace: openshift-operators spec: channel: 7.11.x name: amq-broker-rhel8 source: cs-redhat-operator-index sourceNamespace: openshift-marketplaceApply the
SubscriptionCR by running the following command:$ oc apply -f ./<my-subscription-cr.yaml>1 - 1
- Specify the name of your
SubscriptionCR, such asmy-subscription-cr.yaml.
Example output
subscription.operators.coreos.com/amq-broker created