To expediate the process of deploying Metering, you can create the requisite OLM custom resources locally, using the openshift client.
- Need an existing
CatalogSource
custom resource (e.g. qe-app-registry) that contains the metering-operator's manifest bundle. - Verify that there's a
metering-ocp
packagemanifest. Note: there's some naming collision with the qe-app-registry and redhat-operators packages, but you should be able to tell if there's no populated publisher field for the package.
With an existing CatalogSource
, the process of deploying Metering is fairly straight-forward.
We need to create the following resources:
- OperatorGroup
- Subscription
A OperatorGroup
is a OLM custom resource that aims to provide multi-tenancy to OLM-based operators.
Here, we can target specific namespaces that OLM can then consume and generate the necessary RBAC for the metering-operator + its operands:
apiVersion: operators.coreos.com/v1
kind: OperatorGroup
metadata:
name: metering-ocp-og
namespace: openshift-metering
spec:
targetNamespaces:
- openshift-metering
OLM also has support for targeting a namespace (or list of namespaces) using label selectors, using the spec.selectors
field.
If we omitted the spec.targetNamespaces
, or the spec.selectors
OLM would interpret the metering-operator as a global operator.
For quick deletion, you may want to add a label or annotation to this object.
After verifying that there's a packagemanifest for the metering-ocp package that's being served from the qe-app-registry, we need to check what versions are available:
$ oc get packagemanifests metering-ocp -o yaml
provider:
name: Red Hat
relatedImages:
- quay.io/openshift-qe-optional-operators/ose-metering-hadoop@sha256:1caf29073c0ee07a8bd22e576aa6f4817edfb6b49b4210d0cefa3ea3546e13f3
- quay.io/openshift-qe-optional-operators/ose-metering-hive@sha256:b87ebf4b39412e0c88dd3876adc8f7109e95a6c557bc342ae84a851bbc976deb
- quay.io/openshift-qe-optional-operators/ose-metering-presto@sha256:1ce737fa627325ef52ee10cb3c61b8434006c036acc63e508f5b609669b64a15
- quay.io/openshift-qe-optional-operators/ose-metering-reporting-operator@sha256:d4f995cfb5a80c9945afdd0776024983dfee02a29e1da2048818264d021ce09b
- quay.io/openshift-qe-optional-operators/ose-metering-ansible-operator@sha256:a86b7cc6edfc78e1e5324c9eed9cc86f9b870f8a028d877523c169985b93d995
- quay.io/openshift-qe-optional-operators/ose-oauth-proxy@sha256:cd4557fe61da35450d35abd887adacf9123ddfe5a3fc8dc885a85ed9d36bc797
- quay.io/openshift-qe-optional-operators/ose-ghostunnel@sha256:9e80bcc94bb5909d3ee756c8e306858be8f65e5f6018230ad4a9d0acb9d10369
version: 4.5.0-202006161654
name: "4.5"
defaultChannel: "4.5"
packageName: metering-ocp
provider:
name: Red Hat
We see that there's a 4.5 channel available, which can then use when building up our Subscription custom resource:
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
name: metering-ocp-sub
namespace: openshift-metering
spec:
channel: "4.5"
name: metering-ocp
source: qe-app-registry
sourceNamespace: openshift-marketplace
After creating the above resource, verify an InstallPlan
and CSV
resource have been created.
Once those resources have been created, we need to instantiate a MeteringConfig
custom resource so the metering-ansible-operator Pod, which is responsible for watching that resource, can start the Ansible role.