2.2. Installing the Metering Operator
You can install metering by deploying the Metering Operator. The Metering Operator creates and manages the components of the metering stack.
You cannot create a project starting with openshift-
using the web console or by using the oc new-project
command in the CLI.
If the Metering Operator is installed using a namespace other than openshift-metering
, the metering reports are only viewable using the CLI. It is strongly suggested throughout the installation steps to use the openshift-metering
namespace.
2.2.1. Installing metering using the web console
You can use the OpenShift Container Platform web console to install the Metering Operator.
Procedure
Create a namespace object YAML file for the Metering Operator with the
oc create -f <file-name>.yaml
command. You must use the CLI to create the namespace. For example,metering-namespace.yaml
:apiVersion: v1 kind: Namespace metadata: name: openshift-metering 1 annotations: openshift.io/node-selector: "" 2 labels: openshift.io/cluster-monitoring: "true"
-
In the OpenShift Container Platform web console, click Operators
OperatorHub. Filter for metering
to find the Metering Operator. - Click the Metering card, review the package description, and then click Install.
- Select an Update Channel, Installation Mode, and Approval Strategy.
- Click Install.
Verify that the Metering Operator is installed by switching to the Operators
Installed Operators page. The Metering Operator has a Status of Succeeded when the installation is complete. 注意It might take several minutes for the Metering Operator to appear.
- Click Metering on the Installed Operators page for Operator Details. From the Details page you can create different resources related to metering.
To complete the metering installation, create a MeteringConfig
resource to configure metering and install the components of the metering stack.
2.2.2. Installing metering using the CLI
You can use the OpenShift Container Platform CLI to install the Metering Operator.
Procedure
Create a
Namespace
object YAML file for the Metering Operator. You must use the CLI to create the namespace. For example,metering-namespace.yaml
:apiVersion: v1 kind: Namespace metadata: name: openshift-metering 1 annotations: openshift.io/node-selector: "" 2 labels: openshift.io/cluster-monitoring: "true"
Create the
Namespace
object:$ oc create -f <file-name>.yaml
For example:
$ oc create -f openshift-metering.yaml
Create the
OperatorGroup
object YAML file. For example,metering-og
:apiVersion: operators.coreos.com/v1 kind: OperatorGroup metadata: name: openshift-metering 1 namespace: openshift-metering 2 spec: targetNamespaces: - openshift-metering
Create a
Subscription
object YAML file to subscribe a namespace to the Metering Operator. This object targets the most recently released version in theredhat-operators
catalog source. For example,metering-sub.yaml
:apiVersion: operators.coreos.com/v1alpha1 kind: Subscription metadata: name: metering-ocp 1 namespace: openshift-metering 2 spec: channel: "4.5" 3 source: "redhat-operators" 4 sourceNamespace: "openshift-marketplace" name: "metering-ocp" installPlanApproval: "Automatic" 5
- 1
- The name is arbitrary.
- 2
- You must specify the
openshift-metering
namespace. - 3
- Specify 4.5 as the channel.
- 4
- Specify the
redhat-operators
catalog source, which contains themetering-ocp
package manifests. If your OpenShift Container Platform is installed on a restricted network, also known as a disconnected cluster, specify the name of theCatalogSource
object you created when you configured the Operator LifeCycle Manager (OLM). - 5
- Specify "Automatic" install plan approval.