Setup Metering Operator in OpenShift using static NFS volume
Recently I have to setup the Metering Operator inside a OpenShift cluster in order to collect usage data. The environment doesn’t offer any storage provisioner and static NFS provisioning is the only option.
Install the Metering Operator
Prepare the namespace-openshift-metering.yaml
YAML file for namespace creation:
apiVersion: v1
kind: Namespace
metadata:
name: openshift-metering
annotations:
openshift.io/node-selector: ""
labels:
openshift.io/cluster-monitoring: "true"
Create openshift-metering
namespace:
$ oc create -f namespace-openshift-metering.yaml
namespace/openshift-metering created
Then install Metering Operator using OpenShift Container Platform web console:
- 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 Subscribe.
- 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.

Prepare Persistent Volumes
Step 1: Prepare the NFS exports
In the NFS server, setup two NFS exports for:
- Metering warehouse data: /mnt/nfsdata/metering/warehouse
- Hive metastore DB data: /mnt/nfsdata/metering/dbdata
Step 2: Create PV and PVC for metering warehouse data
Prepare the metering-warehouse-pv.yaml
YAML file.
apiVersion: v1
kind: PersistentVolume
metadata:
name: metering-warehouse-pv
spec:
accessModes:
- ReadWriteMany
capacity:
storage: 100Gi
nfs:
path: /mnt/nfsdata/metering/warehouse
server: nfsserver
persistentVolumeClaimPolicy: Retain
storageClassName: static-nfs
Create the PV.
$ oc create -f metering-warehouse-pv.yaml
persistentvolume/metering-warehouse-pv created
Prepare the metering-warehouse-pvc.yaml
YAML file.
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: metering-warehouse-pvc
namespace: openshift-metering
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 100Gi
storageClassName: static-nfs
volumeName: metering-warehouse-pv
Create the PVC.
$ oc create -f metering-warehouse-pvc.yaml
persistentvolumeclaim/metering-warehouse-pvc created
Step 3: Create PV and PVC for hive metastore DB data
Prepare the hive-metastore-db-data-pv.yaml
YAML file.
apiVersion: v1
kind: PersistentVolume
metadata:
name: hive-metastore-db-data-pv
spec:
accessModes:
- ReadWriteOnce
capacity:
storage: 5Gi
nfs:
path: /mnt/nfsdata/metering/dbdata
server: nfsserver
persistentVolumeClaimPolicy: Retain
storageClassName: static-nfs
Create the PV.
$ oc create -f hive-metastore-db-data-pv.yaml
persistentvolume/hive-metastore-db-data-pv created
Prepare the hive-metastore-db-data-pvc.yaml
YAML file.
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
labels:
app: hive-metastore
metering.openshift.io/ns-prune: openshift-metering
metering.openshift.io/prune: hive-metastore-pvc
name: hive-metastore-db-data
namespace: openshift-metering
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
storageClassName: static-nfs
volumeName: hive-metastore-db-data-pv
Create the PVC.
$ oc create -f hive-metastore-db-data-pvc.yaml
persistentvolumeclaim/hive-metastore-db-data created
Step 4: Verify the PVCs
Verify that the two PVCs are Bound
to the target PVs.
$ oc get pvc -n openshift-metering
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
hive-metastore-db-data Bound hive-metastore-db-data-pv 5Gi RWO static-nfs 17s
metering-warehouse-pvc Bound metering-warehouse-pv 100Gi RWX static-nfs 4m46s
Deploy the Metering stack
With the PVCs created, it is now ready to deploy the Metering stack.
Prepare the metering-config.yaml
YAML file.
apiVersion: metering.openshift.io/v1
kind: MeteringConfig
metadata:
name: operator-metering
namespace: openshift-metering
spec:
storage:
type: hive
hive:
type: sharedPVC
sharedPVC:
claimName: metering-warehouse-pvc
Deploy the Metering stack.
$ oc create -f metering-config.yaml
meteringconfig.metering.openshift.io/operator-metering created
Check that the MeteringConfig has been created.
$ oc get meteringconfig -n openshift-metering
NAME AGE
operator-metering 12s
Wait for a few minutes, then verify that the following Pods are up and running.
$ oc get pods -n openshift-metering
NAME READY STATUS RESTARTS AGE
hive-metastore-0 2/2 Running 0 11m
hive-server-0 3/3 Running 0 11m
metering-operator-7cbf68cd4c-4m4rx 2/2 Running 0 29m
presto-coordinator-0 2/2 Running 0 10m
reporting-operator-d8f55dc45-rvhbg 1/2 Running 0 10m
The setup of Metering Operator is now completed. You could proceed to create Report for metering data collection.