Chapter 2. Integrate and use cost management with OpenShift Container Platform on a restricted network
On restricted or disconnected networks without internet access, configure the Operator Lifecycle Manager to manage local integrations and store cost reports locally for manual upload to Red Hat Hybrid Cloud Console.
- Create a OpenShift Container Platform integration manually.
- Configure the Operator Lifecycle Manager to install and run local integrations.
- Configure the costmanagement-metrics-operator to store cost report CSV files locally using a persistent volume claim (PVC).
- Download cost reports stored in the PVC to a workstation.
- Upload cost reports to Red Hat Hybrid Cloud Console from your workstation.
2.1. Manually create an Openshift Container Platform integration Copy linkLink copied to clipboard!
Create an OpenShift Container Platform integration manually on Red Hat Hybrid Cloud Console for restricted network installations and other scenarios where automatic integration creation is not available.
Prerequisites
- You have an OpenShift Container Platform cluster installed.
- You are logged into the OpenShift Container Platform web console and have cluster administrator privileges.
Procedure
-
From Red Hat Hybrid Cloud Console, click Settings Menu
> Integrations.
- Click the Red Hat tab.
- Click , which opens the Add a cloud integration wizard.
- In Select your integration type, click .
- In Application, click cost management. Then click .
- Enter a name in Integration name. Then click .
-
In a new tab, access the OpenShift Container Platform web console. Go to
and copy your Cluster Identifier. - Back in cost management, enter your Cluster Identifier. Then click .
- Review the details and click to create the integration.
Verification
- In Red Hat Hybrid Cloud Console, navigate to Settings > Integrations > Red Hat.
- Verify that your new OpenShift Container Platform integration appears in the list with status Active.
2.2. Install the cost management operator on a restricted network Copy linkLink copied to clipboard!
Because remote integrations require full Internet connectivity, Operator Lifecycle Manager (OLM) cannot access OpenShift Container Platform clusters that are installed on restricted (disconnected) networks. You must install and configure OLM to run locally.
Prerequisites
- You installed an OpenShift Container Platform cluster.
- You have a workstation with unrestricted network access.
- You logged in to the OpenShift Container Platform web console and have cluster administrator privileges.
Procedure
Complete the following OpenShift Container Platform procedure to create a local mirror of the
costmanagement-metrics-operator: Using Operator Lifecycle Manager in disconnected environments.NoteThe
costmanagement-metrics-operatoris in theredhat-operatorscatalog in theregistry.redhat.io/redhat/redhat-operator-index:OCP_VERSIONwhereOCP_VERSIONmatches the cluster version.Prune unwanted objects from the index before you push to the mirrored registry, but do not delete the
costmanagement-metrics-operatorpackage.Log in to the OpenShift Container Platform web console and navigate the Software Catalog page.
NoteIf you are using OpenShift Container Platform 4.18 or earlier, navigate to the Operator Hub page.
- Click Cost Management Metrics Operator.
-
The Install Operator window opens. Select the
costmanagement-metrics-operatornamespace that you want to install. If the namespace does not exist, it gets created. - Click .
Verification
After a short wait, Cost Management Metrics Operator appears in the Installed Operators tab in Project: all projects or Project: costmanagement-metrics-operator.
2.3. Configure the cost operator on a restricted network Copy linkLink copied to clipboard!
Configure the costmanagement-metrics-operator to store cost reports locally on a persistent volume claim for restricted network environments without internet access.
Prerequisites
-
You installed
costmanagement-metrics-operator. - You logged into the OpenShift Container Platform web console and have cluster administrator privileges.
Procedure
-
From the OpenShift Container Platform web console, select Operators > Installed Operators >
costmanagement-metrics-operator> CostManagementMetricsConfig > Create Instance. Set a storage amount. If you do not specify an amount, the operator creates a default persistent volume claim (PVC) called
costmanagement-metrics-operator-datawith 10Gi of storage.NoteTo configure the
costmanagement-metrics-operatorto use a different PVC, editvolume_claim_templatein YAML view.Select YAML view and configure the following settings:
-
Enter a value in
max_reports_to_storeto set the maximum number of reports that you want to store. Enter a value in
upload_cycleto set how many minutes you want to pass between each report generation.packaging: max_reports_to_store: 30 max_size_MB: 100upload: upload_cycle: 360ImportantThe
costmanagement-metrics-operatorcreates one report every 360 minutes by default. The default value of 30 reports and 360 minutes gives you 7.5 days of reports.After the maximum number of reports generate, any subsequent reports replace the oldest report in storage. To avoid losing reports, download them from your PVC.
-
Enter a value in
Configure restricted network settings by setting the following values:
Set
upload_toggletofalse:upload: upload_cycle: 360 upload_toggle: falseSet
sourceto empty braces:source: {}Set
authenticationto empty braces:authentication: {}
- Click .
Verification
- Select the CostManagementMetricsConfig that you created.
- Click .
Verify that a report was created by viewing the data in
packaging:packaging: last_successful_packaging_time: `current date and time` max_reports_to_store: 30 max_size_MB: 100 number_of_reports_stored: 1 packaged_files: - >- /tmp/costmanagement-metrics-operator-reports/upload/YYYYMMDDTHHMMSS-cost-mgmt.tar.gzNoteAfter configuration,
costmanagement-metrics-operatorgenerates an initial report. These reports are inpackaged_files.
2.4. Download cost reports Copy linkLink copied to clipboard!
If you configured the costmanagement-metrics-operator to run on a restricted network, the reports from the persistent volume claims (PVC) are temporarily stored in a workstation. Copy the reports to an unrestricted network.
The default configuration saves one week of reports. To avoid losing metrics data, download the reports locally and upload them to Red Hat Hybrid Cloud Console weekly.
You can configure any PVC, but by default, most PVCs are ReadWriteOnce. For ReadWriteOnce PVCs, the volume-shell must be attached to the same node as the operator pod.
Prerequisites
- You have a workstation with unrestricted network access.
-
costmanagement-metrics-operatorreports in your PVC.
Procedure
Create the following pod and set
claimNameto the PVC with the report data:kind: Pod apiVersion: v1 metadata: name: volume-shell namespace: costmanagement-metrics-operator spec: volumes: - name: costmanagement-metrics-operator-reports persistentVolumeClaim: claimName: costmanagement-metrics-operator-data containers: - name: volume-shell image: busybox command: ['sleep', '3600'] volumeMounts: - name: costmanagement-metrics-operator-reports mountPath: /tmp/costmanagement-metrics-operator-reportsRun
rsyncto copy all of the files from the PVC to a local folder:$ oc rsync volume-shell:/tmp/costmanagement-metrics-operator-reports/upload local/path/to/save/folderRun the following command to connect to the pod and delete the contents of the upload folder:
$ oc rsh volume-shell $ rm /tmp/costmanagement-metrics-operator-reports/upload/*Optional: Run the following command to delete the pod that you used to connect to the PVC:
$ oc delete -f volume-shell.yaml
Verification
-
Verify that the cost report files were copied to your local folder and have the naming format
YYYYMMDDTHHMMSS-cost-mgmt.tar.gz.
Next steps
View your PVC usage.
+ In the OpenShift tab in Red Hat Hybrid Cloud Console, your PVCs with the highest usage automatically populate under Persistent Volume Claims. To view all PVCs, click at the end of the section.
+ You can filter your PVC data by the following fields: * Persistent volume claim * Cluster * StorageClass
2.5. Upload cost reports to the Red Hat Hybrid Cloud Console Copy linkLink copied to clipboard!
Manually upload your locally stored cost reports from a restricted network to Red Hat Hybrid Cloud Console. The default configuration saves one week of reports. Download the reports locally and upload them to Red Hat Hybrid Cloud Console weekly to avoid losing metrics data.
The service account used to upload data must be added to a user group that has the cost management:settings:write permission. When configuring this in the Red Hat Hybrid Cloud Console, ensure that the group’s assigned role includes the cost-management application and the settings resource type with write operations enabled. This is required to access the Ingress Reports application programming interface (API) for data uploads.
Prerequisites
- You created a Bearer token.
-
You have
costmanagement-metrics-operatorreports downloaded locally. - You are a Red Hat account user with Organization Administrator entitlements.
- You have a workstation with unrestricted network access.
Procedure
To upload your reports to Red Hat Hybrid Cloud Console, set your
client_idandclient_secretto your credentials, setFILE_NAMEto the report that you want to upload, and enter your Bearer token in$TOKEN:$ curl -vvvv -F "file=@$FILE_NAME.tar.gz;type=application/vnd.redhat.hccm.tar+tgz" -H "Authorization: Bearer $TOKEN" https://console.redhat.com/api/ingress/v1/upload
Verification
- From cost management, click .
- On the OpenShift details page, confirm that you have OpenShift usage data for your cluster.