Managing custom catalogs
Cluster administrators and Operator catalog maintainers can create and manage custom catalogs packaged using the bundle format on Operator Lifecycle Manager (OLM) in OpenShift Container Platform.
Important
Kubernetes periodically deprecates certain APIs that are removed in subsequent releases. As a result, Operators are unable to use removed APIs starting with the version of OpenShift Container Platform that uses the Kubernetes version that removed the API.
Prerequisites
-
You have installed the
opmCLI.
File-based catalogs
File-based catalogs are the latest iteration of the catalog format in Operator Lifecycle Manager (OLM). It is a plain text-based (JSON or YAML) and declarative config evolution of the earlier SQLite database format, and it is fully backwards compatible.
Important
As of OpenShift Container Platform 4.11, the default Red Hat-provided Operator catalog releases in the file-based catalog format. The default Red Hat-provided Operator catalogs for OpenShift Container Platform 4.6 through 4.10 released in the deprecated SQLite database format.
The opm subcommands, flags, and functionality related to the SQLite database format are also deprecated and will be removed in a future release. The features are still supported and must be used for catalogs that use the deprecated SQLite database format.
Many of the opm subcommands and flags for working with the SQLite database format, such as opm index prune, do not work with the file-based catalog format.
For more information about working with file-based catalogs, see Operator Framework packaging format and Mirroring images for a disconnected installation using the oc-mirror plugin.
Creating a file-based catalog image
You can use the opm CLI to create a catalog image that uses the plain text file-based catalog format (JSON or YAML), which replaces the deprecated SQLite database format.
-
You have installed the
opmCLI. -
You have
podmanversion 1.9.3+. -
A bundle image is built and pushed to a registry that supports Docker v2-2.
-
Initialize the catalog:
-
Create a directory for the catalog by running the following command:
$ mkdir <catalog_dir> -
Generate a Dockerfile that can build a catalog image by running the
opm generate dockerfilecommand:$ opm generate dockerfile <catalog_dir> \ -i registry.redhat.io/openshift4/ose-operator-registry-rhel9:v4.19- Specify the official Red Hat base image by using the
-iflag, otherwise the Dockerfile uses the default upstream image.
The Dockerfile must be in the same parent directory as the catalog directory that you created in the previous step:
Example directory structure. ├── <catalog_dir> └── <catalog_dir>.Dockerfile- Parent directory
- Catalog directory
- Dockerfile generated by the
opm generate dockerfilecommand
- Specify the official Red Hat base image by using the
-
Populate the catalog with the package definition for your Operator by running the
opm initcommand:$ opm init <operator_name> \ --default-channel=preview \ --description=./README.md \ --icon=./operator-icon.svg \ --output yaml \ > <catalog_dir>/index.yaml- Operator, or package, name
- Channel that subscriptions default to if unspecified
- Path to the Operator’s
README.mdor other documentation - Path to the Operator’s icon
- Output format: JSON or YAML
- Path for creating the catalog configuration file
This command generates an
olm.packagedeclarative config blob in the specified catalog configuration file.
-
-
Add a bundle to the catalog by running the
opm rendercommand:$ opm render <registry>/<namespace>/<bundle_image_name>:<tag> \ --output=yaml \ >> <catalog_dir>/index.yaml- Pull spec for the bundle image
- Path to the catalog configuration file
Note
Channels must contain at least one bundle.
-
Add a channel entry for the bundle. For example, modify the following example to your specifications, and add it to your
<catalog_dir>/index.yamlfile:Example channel entry--- schema: olm.channel package: <operator_name> name: preview entries: - name: <operator_name>.v0.1.0- Ensure that you include the period (
.) after<operator_name>but before thevin the version. Otherwise, the entry fails to pass theopm validatecommand.
- Ensure that you include the period (
-
Validate the file-based catalog:
-
Run the
opm validatecommand against the catalog directory:$ opm validate <catalog_dir> -
Check that the error code is
0:$ echo $?Example output0
-
-
Build the catalog image by running the
podman buildcommand:$ podman build . \ -f <catalog_dir>.Dockerfile \ -t <registry>/<namespace>/<catalog_image_name>:<tag> -
Push the catalog image to a registry:
-
If required, authenticate with your target registry by running the
podman logincommand:$ podman login <registry> -
Push the catalog image by running the
podman pushcommand:$ podman push <registry>/<namespace>/<catalog_image_name>:<tag>
-
Updating or filtering a file-based catalog image
You can use the opm CLI to update or filter a catalog image that uses the file-based catalog format. By extracting the contents of an existing catalog image, you can modify the catalog as needed, for example:
-
Adding packages
-
Removing packages
-
Updating existing package entries
-
Detailing deprecation messages per package, channel, and bundle
You can then rebuild the image as an updated version of the catalog.
Note
Alternatively, if you already have a catalog image on a mirror registry, you can use the oc-mirror CLI plugin to automatically prune any removed images from an updated source version of that catalog image while mirroring it to the target registry.
For more information about the oc-mirror plugin and this use case, see the "Keeping your mirror registry content updated" section, and specifically the "Pruning images" subsection, of "Mirroring images for a disconnected installation using the oc-mirror plugin".
-
You have the following on your workstation:
-
The
opmCLI. -
podmanversion 1.9.3+. -
A file-based catalog image.
-
A catalog directory structure recently initialized on your workstation related to this catalog.
If you do not have an initialized catalog directory, create the directory and generate the Dockerfile. For more information, see the "Initialize the catalog" step from the "Creating a file-based catalog image" procedure.
-
-
Extract the contents of the catalog image in YAML format to an
index.yamlfile in your catalog directory:$ opm render <registry>/<namespace>/<catalog_image_name>:<tag> \ -o yaml > <catalog_dir>/index.yamlNote
Alternatively, you can use the
-o jsonflag to output in JSON format. -
Modify the contents of the resulting
index.yamlfile to your specifications:Important
After a bundle has been published in a catalog, assume that one of your users has installed it. Ensure that all previously published bundles in a catalog have an update path to the current or newer channel head to avoid stranding users that have that version installed.
-
To add an Operator, follow the steps for creating package, bundle, and channel entries in the "Creating a file-based catalog image" procedure.
-
To remove an Operator, delete the set of
olm.package,olm.channel, andolm.bundleblobs that relate to the package. The following example shows a set that must be deleted to remove theexample-operatorpackage from the catalog:Example removed entries
--- defaultChannel: release-2.7 icon: base64data: <base64_string> mediatype: image/svg+xml name: example-operator schema: olm.package --- entries: - name: example-operator.v2.7.0 skipRange: '>=2.6.0 <2.7.0' - name: example-operator.v2.7.1 replaces: example-operator.v2.7.0 skipRange: '>=2.6.0 <2.7.1' - name: example-operator.v2.7.2 replaces: example-operator.v2.7.1 skipRange: '>=2.6.0 <2.7.2' - name: example-operator.v2.7.3 replaces: example-operator.v2.7.2 skipRange: '>=2.6.0 <2.7.3' - name: example-operator.v2.7.4 replaces: example-operator.v2.7.3 skipRange: '>=2.6.0 <2.7.4' name: release-2.7 package: example-operator schema: olm.channel --- image: example.com/example-inc/example-operator-bundle@sha256:<digest> name: example-operator.v2.7.0 package: example-operator properties: - type: olm.gvk value: group: example-group.example.io kind: MyObject version: v1alpha1 - type: olm.gvk value: group: example-group.example.io kind: MyOtherObject version: v1beta1 - type: olm.package value: packageName: example-operator version: 2.7.0 - type: olm.bundle.object value: data: <base64_string> - type: olm.bundle.object value: data: <base64_string> relatedImages: - image: example.com/example-inc/example-related-image@sha256:<digest> name: example-related-image schema: olm.bundle --- -
To add or update deprecation messages for an Operator, ensure there is a
deprecations.yamlfile in the same directory as the package’sindex.yamlfile. For information on thedeprecations.yamlfile format, see "olm.deprecations schema".
-
-
Save your changes.
-
Validate the catalog:
$ opm validate <catalog_dir> -
Rebuild the catalog:
$ podman build . \ -f <catalog_dir>.Dockerfile \ -t <registry>/<namespace>/<catalog_image_name>:<tag> -
Push the updated catalog image to a registry:
$ podman push <registry>/<namespace>/<catalog_image_name>:<tag>
-
In the web console, navigate to the OperatorHub configuration resource in the Administration → Cluster Settings → Configuration page.
-
Add the catalog source or update the existing catalog source to use the pull spec for your updated catalog image.
For more information, see "Adding a catalog source to a cluster" in the "Additional resources" of this section.
-
After the catalog source is in a READY state, navigate to the Ecosystem → Software Catalog page. Select Operators under the Type heading and check that the changes you made are reflected in the list of Operators.
SQLite-based catalogs
Important
The SQLite database format for Operator catalogs is a deprecated feature. Deprecated functionality is still included in OpenShift Container Platform and continues to be supported; however, it will be removed in a future release of this product and is not recommended for new deployments.
For the most recent list of major functionality that has been deprecated or removed within OpenShift Container Platform, refer to the Deprecated and removed features section of the OpenShift Container Platform release notes.
Creating a SQLite-based index image
You can create an index image based on the SQLite database format by using the opm CLI.
-
You have installed the
opmCLI. -
You have
podmanversion 1.9.3+. -
A bundle image is built and pushed to a registry that supports Docker v2-2.
-
Start a new index:
$ opm index add \ --bundles <registry>/<namespace>/<bundle_image_name>:<tag> \ --tag <registry>/<namespace>/<index_image_name>:<tag> \ [--binary-image <registry_base_image>]- Comma-separated list of bundle images to add to the index.
- The image tag that you want the index image to have.
- Optional: An alternative registry base image to use for serving the catalog.
-
Push the index image to a registry.
-
If required, authenticate with your target registry:
$ podman login <registry> -
Push the index image:
$ podman push <registry>/<namespace>/<index_image_name>:<tag>
-
Updating a SQLite-based index image
After configuring the software catalog to use a catalog source that references a custom index image, cluster administrators can keep the available Operators on their cluster up-to-date by adding bundle images to the index image.
You can update an existing index image using the opm index add command.
-
You have installed the
opmCLI. -
You have
podmanversion 1.9.3+. -
An index image is built and pushed to a registry.
-
You have an existing catalog source referencing the index image.
-
Update the existing index by adding bundle images:
$ opm index add \ --bundles <registry>/<namespace>/<new_bundle_image>@sha256:<digest> \ --from-index <registry>/<namespace>/<existing_index_image>:<existing_tag> \ --tag <registry>/<namespace>/<existing_index_image>:<updated_tag> \ --pull-tool podman- The
--bundlesflag specifies a comma-separated list of additional bundle images to add to the index. - The
--from-indexflag specifies the previously pushed index. - The
--tagflag specifies the image tag to apply to the updated index image. - The
--pull-toolflag specifies the tool used to pull container images.where:
<registry>-
Specifies the hostname of the registry, such as
quay.ioormirror.example.com. <namespace>-
Specifies the namespace of the registry, such as
ocs-devorabc. <new_bundle_image>-
Specifies the new bundle image to add to the registry, such as
ocs-operator. <digest>-
Specifies the SHA image ID, or digest, of the bundle image, such as
c7f11097a628f092d8bad148406aa0e0951094a03445fd4bc0775431ef683a41. <existing_index_image>-
Specifies the previously pushed image, such as
abc-redhat-operator-index. <existing_tag>-
Specifies a previously pushed image tag, such as
4.19. <updated_tag>-
Specifies the image tag to apply to the updated index image, such as
4.19.1.
Example command$ opm index add \ --bundles quay.io/ocs-dev/ocs-operator@sha256:c7f11097a628f092d8bad148406aa0e0951094a03445fd4bc0775431ef683a41 \ --from-index mirror.example.com/abc/abc-redhat-operator-index:4.19 \ --tag mirror.example.com/abc/abc-redhat-operator-index:4.19.1 \ --pull-tool podman
- The
-
Push the updated index image:
$ podman push <registry>/<namespace>/<existing_index_image>:<updated_tag> -
After Operator Lifecycle Manager (OLM) automatically polls the index image referenced in the catalog source at its regular interval, verify that the new packages are successfully added:
$ oc get packagemanifests -n openshift-marketplace
Filtering a SQLite-based index image
An index image, based on the Operator bundle format, is a containerized snapshot of an Operator catalog. You can filter, or prune, an index of all but a specified list of packages, which creates a copy of the source index containing only the Operators that you want.
-
You have
podmanversion 1.9.3+. -
You have
grpcurl(third-party command-line tool). -
You have installed the
opmCLI. -
You have access to a registry that supports Docker v2-2.
-
Authenticate with your target registry:
$ podman login <target_registry> -
Determine the list of packages you want to include in your pruned index.
-
Run the source index image that you want to prune in a container. For example:
$ podman run -p50051:50051 \ -it registry.redhat.io/redhat/redhat-operator-index:v4.19Example outputTrying to pull registry.redhat.io/redhat/redhat-operator-index:v4.19... Getting image source signatures Copying blob ae8a0c23f5b1 done ... INFO[0000] serving registry database=/database/index.db port=50051 -
In a separate terminal session, use the
grpcurlcommand to get a list of the packages provided by the index:$ grpcurl -plaintext localhost:50051 api.Registry/ListPackages > packages.out -
Inspect the
packages.outfile and identify which package names from this list you want to keep in your pruned index. For example:Example snippets of packages list... { "name": "advanced-cluster-management" } ... { "name": "jaeger-product" } ... { { "name": "quay-operator" } ... -
In the terminal session where you executed the
podman runcommand, press Ctrl and C to stop the container process.
-
-
Run the following command to prune the source index of all but the specified packages:
$ opm index prune \ -f registry.redhat.io/redhat/redhat-operator-index:v4.19 \ -p advanced-cluster-management,jaeger-product,quay-operator \ [-i registry.redhat.io/openshift4/ose-operator-registry-rhel9:v4.19] \ -t <target_registry>:<port>/<namespace>/redhat-operator-index:v4.19- Index to prune.
- Comma-separated list of packages to keep.
- Required only for IBM Power® and IBM Z® images: Operator Registry base image with the tag that matches the target OpenShift Container Platform cluster major and minor version.
- Custom tag for new index image being built.
-
Run the following command to push the new index image to your target registry:
$ podman push <target_registry>:<port>/<namespace>/redhat-operator-index:v4.19where
<namespace>is any existing namespace on the registry.
Catalog sources and pod security admission
Pod security admission was introduced in OpenShift Container Platform 4.11 to ensure pod security standards. Catalog sources built using the SQLite-based catalog format and a version of the opm CLI tool released before OpenShift Container Platform 4.11 cannot run under restricted pod security enforcement.
In OpenShift Container Platform 4.19,
namespaces do not have restricted pod security enforcement by default and the default catalog source security mode is set to legacy.
Default restricted enforcement for all namespaces is planned for inclusion in a future OpenShift Container Platform release. When restricted enforcement occurs, the security context of the pod specification for catalog source pods must match the restricted pod security standard. If your catalog source image requires a different pod security standard, the pod security admissions label for the namespace must be explicitly set.
Note
If you do not want to run your SQLite-based catalog source pods as restricted, you do not need to update your catalog source in OpenShift Container Platform 4.19.
However, it is recommended that you take action now to ensure your catalog sources run under restricted pod security enforcement. If you do not take action to ensure your catalog sources run under restricted pod security enforcement, your catalog sources might not run in future OpenShift Container Platform releases.
As a catalog author, you can enable compatibility with restricted pod security enforcement by completing either of the following actions:
-
Migrate your catalog to the file-based catalog format.
-
Update your catalog image with a version of the
opmCLI tool released with OpenShift Container Platform 4.11 or later.
Note
The SQLite database catalog format is deprecated, but still supported by Red Hat. In a future release, the SQLite database format will not be supported, and catalogs will need to migrate to the file-based catalog format. As of OpenShift Container Platform 4.11, the default Red Hat-provided Operator catalog is released in the file-based catalog format. File-based catalogs are compatible with restricted pod security enforcement.
If you do not want to update your SQLite database catalog image or migrate your catalog to the file-based catalog format, you can configure your catalog to run with elevated permissions.
Migrating SQLite database catalogs to the file-based catalog format
You can update your deprecated SQLite database format catalogs to the file-based catalog format.
-
You have a SQLite database catalog source.
-
You have access to the cluster as a user with the
cluster-adminrole. -
You have the latest version of the
opmCLI tool released with OpenShift Container Platform 4.19 on your workstation.
-
Migrate your SQLite database catalog to a file-based catalog by running the following command:
$ opm migrate <registry_image> <fbc_directory> -
Generate a Dockerfile for your file-based catalog by running the following command:
$ opm generate dockerfile <fbc_directory> \ --binary-image \ registry.redhat.io/openshift4/ose-operator-registry-rhel9:v4.19
-
The generated Dockerfile can be built, tagged, and pushed to your registry.
Rebuilding SQLite database catalog images
You can rebuild your SQLite database catalog image with the latest version of the opm CLI tool that is released with your version of OpenShift Container Platform.
-
You have a SQLite database catalog source.
-
You have access to the cluster as a user with the
cluster-adminrole. -
You have the latest version of the
opmCLI tool released with OpenShift Container Platform 4.19 on your workstation.
-
Run the following command to rebuild your catalog with a more recent version of the
opmCLI tool:$ opm index add --binary-image \ registry.redhat.io/openshift4/ose-operator-registry-rhel9:v4.19 \ --from-index <your_registry_image> \ --bundles "" -t \<your_registry_image>
Configuring catalogs to run with elevated permissions
If you do not want to update your SQLite database catalog image or migrate your catalog to the file-based catalog format, you can perform the following actions to ensure your catalog source runs when the default pod security enforcement changes to restricted:
-
Manually set the catalog security mode to legacy in your catalog source definition. This action ensures your catalog runs with legacy permissions even if the default catalog security mode changes to restricted.
-
Label the catalog source namespace for baseline or privileged pod security enforcement.
Note
The SQLite database catalog format is deprecated, but still supported by Red Hat. In a future release, the SQLite database format will not be supported, and catalogs will need to migrate to the file-based catalog format. File-based catalogs are compatible with restricted pod security enforcement.
-
You have a SQLite database catalog source.
-
You have access to the cluster as a user with the
cluster-adminrole. -
You have a target namespace that supports running pods with the elevated pod security admission standard of
baselineorprivileged.
-
Edit the
CatalogSourcedefinition by setting thespec.grpcPodConfig.securityContextConfiglabel tolegacy, as shown in the following example:ExampleCatalogSourcedefinitionapiVersion: operators.coreos.com/v1alpha1 kind: CatalogSource metadata: name: my-catsrc namespace: my-ns spec: sourceType: grpc grpcPodConfig: securityContextConfig: legacy image: my-image:latestTip
In OpenShift Container Platform 4.19, the
spec.grpcPodConfig.securityContextConfigfield is set tolegacyby default. In a future release of OpenShift Container Platform, it is planned that the default setting will change torestricted. If your catalog cannot run under restricted enforcement, it is recommended that you manually set this field tolegacy. -
Edit your
<namespace>.yamlfile to add elevated pod security admission standards to your catalog source namespace, as shown in the following example:Example<namespace>.yamlfileapiVersion: v1 kind: Namespace metadata: ... labels: security.openshift.io/scc.podSecurityLabelSync: "false" openshift.io/cluster-monitoring: "true" pod-security.kubernetes.io/enforce: baseline name: "<namespace_name>"- Turn off pod security label synchronization by adding the
security.openshift.io/scc.podSecurityLabelSync=falselabel to the namespace. - Apply the pod security admission
pod-security.kubernetes.io/enforcelabel. Set the label tobaselineorprivileged. Use thebaselinepod security profile unless other workloads in the namespace require aprivilegedprofile.
- Turn off pod security label synchronization by adding the
Adding a catalog source to a cluster
Adding a catalog source to an OpenShift Container Platform cluster enables the discovery and installation of Operators for users.
Cluster administrators
can create a CatalogSource object that references an index image. The software catalog uses catalog sources to populate the user interface.
Tip
Alternatively, you can use the web console to manage catalog sources. From the Administration → Cluster Settings → Configuration → OperatorHub page, click the Sources tab, where you can create, update, delete, disable, and enable individual sources.
-
You built and pushed an index image to a registry.
-
You have access to the cluster as a user with the
cluster-adminrole.
-
Create a
CatalogSourceobject that references your index image.-
Modify the following to your specifications and save it as a
catalogSource.yamlfile:apiVersion: operators.coreos.com/v1alpha1 kind: CatalogSource metadata: name: my-operator-catalog namespace: openshift-marketplace annotations: olm.catalogImageTemplate: "<registry>/<namespace>/<index_image_name>:v{kube_major_version}.{kube_minor_version}.{kube_patch_version}" spec: sourceType: grpc grpcPodConfig: securityContextConfig: <security_mode> image: <registry>/<namespace>/<index_image_name>:<tag> displayName: My Operator Catalog publisher: <publisher_name> updateStrategy: registryPoll: interval: 30m- If you want the catalog source to be available globally to users in all namespaces, specify the
openshift-marketplacenamespace. Otherwise, you can specify a different namespace for the catalog to be scoped and available only for that namespace. - Optional: Set the
olm.catalogImageTemplateannotation to your index image name and use one or more of the Kubernetes cluster version variables as shown when constructing the template for the image tag. - Specify the value of
legacyorrestricted. If the field is not set, the default value islegacy. In a future OpenShift Container Platform release, it is planned that the default value will berestricted.Note
If your catalog cannot run with
restrictedpermissions, it is recommended that you manually set this field tolegacy. - Specify your index image. If you specify a tag after the image name, for example
:v4.19, the catalog source pod uses an image pull policy ofAlways, meaning the pod always pulls the image prior to starting the container. If you specify a digest, for example@sha256:<id>, the image pull policy isIfNotPresent, meaning the pod pulls the image only if it does not already exist on the node. - Specify your name or an organization name publishing the catalog.
- Catalog sources can automatically check for new versions to keep up to date.
- If you want the catalog source to be available globally to users in all namespaces, specify the
-
Use the file to create the
CatalogSourceobject:$ oc apply -f catalogSource.yaml
-
-
Verify the following resources are created successfully.
-
Check the pods:
$ oc get pods -n openshift-marketplaceExample outputNAME READY STATUS RESTARTS AGE my-operator-catalog-6njx6 1/1 Running 0 28s marketplace-operator-d9f549946-96sgr 1/1 Running 0 26h -
Check the catalog source:
$ oc get catalogsource -n openshift-marketplaceExample outputNAME DISPLAY TYPE PUBLISHER AGE my-operator-catalog My Operator Catalog grpc 5s -
Check the package manifest:
$ oc get packagemanifest -n openshift-marketplaceExample outputNAME CATALOG AGE jaeger-product My Operator Catalog 93s
-
You can now install the Operators from the Software Catalog page on your OpenShift Container Platform web console.
Accessing images for Operators from private registries
If certain images relevant to Operators managed by Operator Lifecycle Manager (OLM) are hosted in an authenticated container image registry, also known as a private registry, OLM and the software catalog are unable to pull the images by default. To enable access, you can create a pull secret that contains the authentication credentials for the registry. By referencing one or more pull secrets in a catalog source, OLM can handle placing the secrets in the Operator and catalog namespace to allow installation.
Other images required by an Operator or its Operands might require access to private registries as well. OLM does not handle placing the secrets in target tenant namespaces for this scenario, but authentication credentials can be added to the global cluster pull secret or individual namespace service accounts to enable the required access.
The following types of images should be considered when determining whether Operators managed by OLM have appropriate pull access:
- Index images
-
A
CatalogSourceobject can reference an index image, which use the Operator bundle format and are catalog sources packaged as container images hosted in images registries. If an index image is hosted in a private registry, a secret can be used to enable pull access. - Bundle images
-
Operator bundle images are metadata and manifests packaged as container images that represent a unique version of an Operator. If any bundle images referenced in a catalog source are hosted in one or more private registries, a secret can be used to enable pull access.
- Operator and Operand images
-
If an Operator installed from a catalog source uses a private image, either for the Operator image itself or one of the Operand images it watches, the Operator will fail to install because the deployment will not have access to the required registry authentication. Referencing secrets in a catalog source does not enable OLM to place the secrets in target tenant namespaces in which Operands are installed.
Instead, the authentication details can be added to the global cluster pull secret in the
openshift-confignamespace, which provides access to all namespaces on the cluster. Alternatively, if providing access to the entire cluster is not permissible, the pull secret can be added to thedefaultservice accounts of the target tenant namespaces.
You can access images from Operator from private registries by creating a secret for your registry credentials and adding the secret for use with relevant catalogs.
-
You have at least one of the following hosted in a private registry:
-
An index image or catalog image.
-
An Operator bundle image.
-
An Operator or Operand image.
-
-
You have access to the cluster as a user with the
cluster-adminrole.
-
Create a secret for each required private registry.
-
Log in to the private registry to create or update your registry credentials file:
$ podman login <registry>:<port>Note
The file path of your registry credentials can be different depending on the container tool used to log in to the registry. For the
podmanCLI, the default location is${XDG_RUNTIME_DIR}/containers/auth.json. For thedockerCLI, the default location is/root/.docker/config.json. -
It is recommended to include credentials for only one registry per secret, and manage credentials for multiple registries in separate secrets. Multiple secrets can be included in a
CatalogSourceobject in later steps, and OpenShift Container Platform will merge the secrets into a single virtual credentials file for use during an image pull.A registry credentials file can, by default, store details for more than one registry or for multiple repositories in one registry. Verify the current contents of your file. For example:
File storing credentials for multiple registries{ "auths": { "registry.redhat.io": { "auth": "FrNHNydQXdzclNqdg==" }, "quay.io": { "auth": "fegdsRib21iMQ==" }, "https://quay.io/my-namespace/my-user/my-image": { "auth": "eWfjwsDdfsa221==" }, "https://quay.io/my-namespace/my-user": { "auth": "feFweDdscw34rR==" }, "https://quay.io/my-namespace": { "auth": "frwEews4fescyq==" } } }Because this file is used to create secrets in later steps, ensure that you are storing details for only one registry per file. This can be accomplished by using either of the following methods:
-
Use the
podman logout <registry>command to remove credentials for additional registries until only the one registry you want remains. -
Edit your registry credentials file and separate the registry details to be stored in multiple files. For example:
File storing credentials for one registry{ "auths": { "registry.redhat.io": { "auth": "FrNHNydQXdzclNqdg==" } } }File storing credentials for another registry{ "auths": { "quay.io": { "auth": "Xd2lhdsbnRib21iMQ==" } } }
-
-
Create a secret in the
openshift-marketplacenamespace that contains the authentication credentials for a private registry:$ oc create secret generic <secret_name> \ -n openshift-marketplace \ --from-file=.dockerconfigjson=<path/to/registry/credentials> \ --type=kubernetes.io/dockerconfigjsonRepeat this step to create additional secrets for any other required private registries, updating the
--from-fileflag to specify another registry credentials file path.
-
-
Create or update an existing
CatalogSourceobject to reference one or more secrets:apiVersion: operators.coreos.com/v1alpha1 kind: CatalogSource metadata: name: my-operator-catalog namespace: openshift-marketplace spec: sourceType: grpc secrets: - "<secret_name_1>" - "<secret_name_2>" grpcPodConfig: securityContextConfig: <security_mode> image: <registry>:<port>/<namespace>/<image>:<tag> displayName: My Operator Catalog publisher: <publisher_name> updateStrategy: registryPoll: interval: 30m- Add a
spec.secretssection and specify any required secrets. - Specify the value of
legacyorrestricted. If the field is not set, the default value islegacy. In a future OpenShift Container Platform release, it is planned that the default value will berestricted.Note
If your catalog cannot run with
restrictedpermissions, it is recommended that you manually set this field tolegacy.
- Add a
-
If any Operator or Operand images that are referenced by a subscribed Operator require access to a private registry, you can either provide access to all namespaces in the cluster, or individual target tenant namespaces.
-
To provide access to all namespaces in the cluster, add authentication details to the global cluster pull secret in the
openshift-confignamespace.Warning
Cluster resources must adjust to the new global pull secret, which can temporarily limit the usability of the cluster.
-
Extract the
.dockerconfigjsonfile from the global pull secret:$ oc extract secret/pull-secret -n openshift-config --confirm -
Update the
.dockerconfigjsonfile with your authentication credentials for the required private registry or registries and save it as a new file:$ cat .dockerconfigjson | \ jq --compact-output '.auths["<registry>:<port>/<namespace>/"] |= . + {"auth":"<token>"}' \ > new_dockerconfigjson- Replace
<registry>:<port>/<namespace>with the private registry details and<token>with your authentication credentials.
- Replace
-
Update the global pull secret with the new file:
$ oc set data secret/pull-secret -n openshift-config \ --from-file=.dockerconfigjson=new_dockerconfigjson
-
-
To update an individual namespace, add a pull secret to the service account for the Operator that requires access in the target tenant namespace.
-
Recreate the secret that you created for the
openshift-marketplacein the tenant namespace:$ oc create secret generic <secret_name> \ -n <tenant_namespace> \ --from-file=.dockerconfigjson=<path/to/registry/credentials> \ --type=kubernetes.io/dockerconfigjson -
Verify the name of the service account for the Operator by searching the tenant namespace:
$ oc get sa -n <tenant_namespace>- If the Operator was installed in an individual namespace, search that namespace. If the Operator was installed for all namespaces, search the
openshift-operatorsnamespace.
Example outputNAME SECRETS AGE builder 2 6m1s default 2 6m1s deployer 2 6m1s etcd-operator 2 5m18s- Service account for an installed etcd Operator.
- If the Operator was installed in an individual namespace, search that namespace. If the Operator was installed for all namespaces, search the
-
Link the secret to the service account for the Operator:
$ oc secrets link <operator_sa> \ -n <tenant_namespace> \ <secret_name> \ --for=pull
-
-
-
See What is a secret? for more information on the types of secrets, including those used for registry credentials.
-
See Updating the global cluster pull secret for more details on the impact of changing this secret.
-
See Allowing pods to reference images from other secured registries for more details on linking pull secrets to service accounts per namespace.
Disabling the default software catalog sources
Operator catalogs that source content provided by Red Hat and community projects are configured for the software catalog by default during an OpenShift Container Platform installation. As a cluster administrator, you can disable the set of default catalogs.
-
Disable the sources for the default catalogs by adding
disableAllDefaultSources: trueto theOperatorHubobject:$ oc patch OperatorHub cluster --type json \ -p '[{"op": "add", "path": "/spec/disableAllDefaultSources", "value": true}]'
Tip
Alternatively, you can use the web console to manage catalog sources. From the Administration → Cluster Settings → Configuration → OperatorHub page, click the Sources tab, where you can create, update, delete, disable, and enable individual sources.
Removing custom catalogs
As a cluster administrator, you can remove custom Operator catalogs that have been previously added to your cluster by deleting the related catalog source.
-
You have access to the cluster as a user with the
cluster-adminrole.
-
In the Administrator perspective of the web console, navigate to Administration → Cluster Settings.
-
Click the Configuration tab, and then click OperatorHub.
-
Click the Sources tab.
-
Select the Options menu
for the catalog that you want to remove, and then click Delete CatalogSource.