Add a catalog source to a cluster

To make Operators from a custom index image available for installation, create a catalog source that adds the catalog content to your cluster.

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 AdministrationCluster SettingsConfigurationOperatorHub page, click the Sources tab, where you can create, update, delete, disable, and enable individual sources.

Prerequisites
  • You built and pushed an index image to a registry.

  • You have access to the cluster as a user with the cluster-admin role.

Procedure
  1. Create a CatalogSource object that references your index image.

    1. Modify the following to your specifications and save it as a catalogSource.yaml file:

      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

      where:

      metadata.namespace

      Specifies the value for the metadata.namespace parameter. If you want the catalog source to be available globally to users in all namespaces, specify the openshift-marketplace namespace. Otherwise, you can specify a different namespace for the catalog to be scoped and available only for that namespace.

      metadata.annotations

      Specifies the value for the metadata.annotations parameter. This is optional to set the olm.catalogImageTemplate annotation 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.

      spec.grpcPodConfig.securityContextConfig

      Specifies the value of legacy or restricted. If the field is not set, the default value is legacy. In a future OpenShift Container Platform release, it is planned that the default value will be restricted.

      Note

      If your catalog cannot run with restricted permissions, it is recommended that you manually set this field to legacy.

      spec.image

      Specifies your index image. If you specify a tag after the image name, for example :v{product-version}, the catalog source pod uses an image pull policy of Always, meaning the pod always pulls the image before starting the container. If you specify a digest, for example @sha256:<id>, the image pull policy is IfNotPresent, meaning the pod pulls the image only if it does not already exist on the node.

      spec.publisher

      Specifies your name or an organization name publishing the catalog.

      spec.updateStrategy.registryPoll

      Specifies the value for the spec.updateStrategy.registryPoll parameter. The catalog sources can automatically check for new versions to keep up to date.

    2. Use the file to create the CatalogSource object:

      $ oc apply -f catalogSource.yaml
  2. Verify the following resources are created successfully.

    1. Check the pods:

      $ oc get pods -n openshift-marketplace

      The following is example output:

      NAME                                    READY   STATUS    RESTARTS  AGE
      my-operator-catalog-6njx6               1/1     Running   0         28s
      marketplace-operator-d9f549946-96sgr    1/1     Running   0         26h
    2. Check the catalog source:

      $ oc get catalogsource -n openshift-marketplace

      The following is example output:

      NAME                  DISPLAY               TYPE PUBLISHER  AGE
      my-operator-catalog   My Operator Catalog   grpc            5s
    3. Check the package manifest:

      $ oc get packagemanifest -n openshift-marketplace

      The following is example output:

      NAME                          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.