Adding an OpenShift Container Platform source to cost management

Cost Management Service 2023

Learn how to add and configure your OpenShift Container Platform sources

Red Hat Customer Content Services

Abstract

This guide describes how to add an OpenShift Container Platform source to cost management. Cost management is part of the Red Hat Insights portfolio of services. The Red Hat Insights suite of advanced analytical tools helps you to identify and prioritize impacts on your operations, security, and business.

Chapter 1. Adding an OpenShift Container Platform source to cost management

1.1. Installation tasks summary

Whether you are replacing a prior cost management operator with the Cost Management Metrics Operator or installing it for the first time, the basic tasks are the same.

Operator installation, configuration, and source management can all be performed from the OpenShift Container Platform web console.

You will perform the following tasks to install the Cost Management Metrics Operator and begin using the cost management application in OpenShift Container Platform.

Note

To install and configure Cost Management Metrics Operator from the OpenShift Container Platform web console, you must use an account with cluster administrator privileges.

Prerequisites

Task summary

  • Install the Cost Management Metrics Operator (costmanagement-metrics-operator) and use the default token authentication.
  • Create a CostManagementMetricsConfig YAML file that configures costmanagement-metrics-operator
  • Create a cost management OpenShift Container Platform source with a new installation, or confirm an existing source with a replacement installation.
  • After installing the Cost Management Metrics Operator, delete the old cost operator. This task is required only when a previous cost management operator is installed.

If you use Basic authentication, additional steps are required to configure the Secret that holds username and password credentials.

1.2. Installing the cost operator

Install the Cost Management Metrics Operator from the OpenShift Container Platform web console.

Prerequisites

  • You are logged into the OpenShift Container Platform web console with cluster administrator privileges.

Procedure

  1. Login to the OpenShift Container Platform web console and click on the Operators > OperatorHub tab.
  2. Search for and locate Cost Management Metrics Operator.
  3. Click on the displayed Cost Management Metrics Operator tile.
  4. When the Install Operator window appears, you must select the costmanagement-metrics-operator namespace for installation. If the namespace does not yet exist, it is created for you.
  5. Click on the Install button.
  6. After a short wait, Cost Management Metrics Operator appears in the Installed Operators tab under Project: all projects or Project: costmanagement-metrics-operator.
Important

If a proxy with a custom CA certificate is configured, additional configuration is required to inject this certificate into Cost Management Metrics Operator. See, Injecting a custom CA certificate in the OpenShift Container Platform documentation for details.

1.3. Configuring the operator instance for a new installation

Use the OpenShift Container Platform web console to configure the costmanagement-metrics-operator instance after it is installed.

Prerequisites

  • You are logged into the OpenShift Container Platform web console with cluster administrator privileges.
  • The Cost Management Metrics Operator appears in the Installed Operators tab.

Procedure

  1. Under the Name heading in the list of installed operators, click the Cost Management Metrics Operator link. The Installed Operators > Operator Details window appears for Cost Management Metrics Operator.
  2. In the Details window, click + Create Instance.
  3. A Cost Management Metrics Operator > Create CostManagementMetricsConfig window appears.
  4. Click the YAML view radio button to view and modify the contents of the YAML configuration file.
  5. When you create a new cost management instance for the Cost Management Metrics Operator, make the following modifications in the YAML configuration file.
  6. Locate the following two lines in the YAML file.

        create_source: false
        name: INSERT-SOURCE-NAME
    1. Change false to true.
    2. Change INSERT-SOURCE-NAME to the new name of your source.

      Example

          create_source: true
          name: my-openshift-cost-source

      Note

      The value entered for INSERT-SOURCE-NAME will be the name of the source in cost management. Leaving this value as INSERT-SOURCE-NAME is acceptable, but it is recommended to change it to something more identifiable, especially when installing the operator in multiple clusters.

  7. Click the Create button. These actions create a new source for cost management that will appear in the Red Hat Hybrid Cloud Console cost management application.

1.4. Replacing a prior operator instance

If you are replacing a prior cost management operator with the Cost Management Metrics Operator, make certain your existing cost management source is properly configured in the YAML configuration file.

Important

When you are replacing a prior cost management operator with the Cost Management Metrics Operator and you want to use an existing source, you must make certain that the name: INSERT-SOURCE-NAME in the YAML file matches your existing source.

Prerequisites

  • You are logged into the OpenShift Container Platform web console with cluster administrator privileges.
  • You can access Red Hat Hybrid Cloud Console and view existing cost management sources.

Procedure

  1. Under the Name heading in the list of installed operators, click the Cost Management Metrics Operator link. The Installed Operators > Operator Details window appears for Cost Management Metrics Operator.
  2. In the Details window, click + Create Instance.
  3. A Cost Management Metrics Operator > Create CostManagementMetricsConfig window appears.
  4. Click the YAML view radio button to view and modify the contents of the CostManagementMetricsConfig YAML file.
  5. Open Red Hat Hybrid Cloud Console and log in using your Organization Administrator account.
  6. Click Settings Settings icon .
  7. Click the Sources tab to display existing sources.
  8. Select an existing cost management source and copy its name.
  9. In the CostManagementMetricsConfig YAML file, replace INSERT-SOURCE-NAME with the source name that you copied from the cost management source list for your organization.

        create_source: false
        name: INSERT-SOURCE-NAME    <<<< replace this string

    The create_source: false does not change because you are matching an existing source, not creating a new source.

  10. Click the Create button. No further actions are needed to configure the operator instance.

1.5. Removing a prior cost operator

After installing the costmanagement-metrics-operator, uninstall the prior cost management operator.

To avoid gaps in your cost management data, you can wait 24 to 48 hours before removing the prior operator while you verify that costmanagement-metrics-operator provides cost management reports.

Note

If you mistakenly remove the Cost Management Metrics Operator, reinstall it.

Prerequisites

  • A prior cost management operator is installed.
  • You installed the Cost Management Metrics Operator.
  • You are logged into the OpenShift Container Platform web console with cluster administrator privileges.
  • You can view the operators in the Installed Operators tab.

Procedure

  1. In the Installed Operators list, select the operator you want to remove.
  2. Click the Options menu more options in that row.
  3. Click on the Uninstall Operator option. Confirm the action to remove the operator.
  4. In the OpenShift Container Platform web console, click the Administration > Custom Resource Definitions tab.
  5. In the window that displays the custom resource definitions (CRD), locate the CostManagement CRD and the CostManagementData CRD for cost-mgmt-operator or the KokuMetricsConfig CRD for koku-metrics-operator.
  6. For each CRD, click the Options menu more optionsDelete Custom Resource Definition. Confirm the delete action.
  7. When these CRDs are deleted, the prior operator is fully uninstalled.
Note

When you install Cost Management Metrics Operator, a CostManagementMetricsConfig CRD appears in Administration > Custom Resource Definitions list.

1.6. Verifying the cost operator

View the configuration YAML file to verify the cost management operator is functioning.

Prerequisites

  • You can access the OpenShift Container Platform web console.
  • You can locate and view the Installed Operators tab.

Procedure

  1. Click on the Installed Operators tab.
  2. In the list of installed operators, click on the Cost Management Metrics Operator entry.
  3. When the metrics operator window opens, click on the CostManagementMetricsConfig tab to show a list of the configuration file names.
  4. In the name list, click on the configuration file. In the default installation, the file name is costmanagementmetricscfg-sample.
  5. When the Details window opens, click on the YAML tab. and visually check the following items.

    1. Prometheus configuration and connection are true.

        prometheus:
          last_query_start_time: '2021-01-25T20:59:06Z'
          last_query_success_time: '2021-01-25T20:59:06Z'
          prometheus_configured: true
          prometheus_connected: true
          service_address: 'https://thanos-querier.openshift-monitoring.svc:9091'
          skip_tls_verification: false
    2. Upload information shows the ingress path, successful upload and time, and accepted status.

       upload:
          ingress_path: /api/ingress/v1/upload
          last_successful_upload_time: '2021-01-25T20:59:35Z'
          last_upload_status: 202 Accepted
          last_upload_time: '2021-01-25T20:59:35Z'
          upload: true
          upload_cycle: 360
          upload_wait: 28
          validate_cert: true

1.7. Configuring basic authentication for cost operator

You can configure the cost operator to use basic authentication. By default, the cost operator uses token authentication.

There are two procedures required when you configure basic authentication.

1.7.1. Creating the secret key/value pair for basic authentication

Prerequisites

  • You are logged into the OpenShift Container Platform web console with cluster administrator privileges.
  • The Cost Management Metrics Operator appears in the Installed Operators tab.
  • You have a username and password for your Red Hat Hybrid Cloud Console account.

Procedure

This procedure describes setting up basic authentication using the OpenShift Container Platform web console.

  1. In the OpenShift Container Platform web console, click on the Workloads > Secrets tab.
  2. In the Secrets window, select Project:costmanagement-metrics-operator from the dropdown.
  3. Click the Create > Key/Value Secret selection.
  4. In the Create Key/Value Secret window enter the following information to create a new secret that contains a username key and a password key and a value for each key.

    1. Enter a name for your secret in the Secret Name field.

      basic-auth-secret
    2. In the Key field, enter username.

      username
    3. In the Value field for the key username, enter the actual username for your authorized Red Hat Hybrid Cloud Console user account.

      Value for username key

      your_red_hat_username

    4. Click the Add Key/Value link to add the required password key name and value.
    5. In the Key field, enter password.

      password
    6. In the Value field for the key password, enter the actual password for your authorized Red Hat Hybrid Cloud Console user account.

      Value for password key

      your_red_hat_password

    7. Click the Create button to complete the creation of your basic authorization secret.
    8. After you click the Create button, you can verify the key/value details for the secret.

      Note

      Do not add the secret to the workload.

1.7.2. Modifying the YAML file

Modify the Cost Management Metrics Operator API YAML file to use basic authentication with a secret username and password key/value pair.

Prerequisites

  • You are logged into the OpenShift Container Platform web console with cluster administrator privileges.
  • You created a secret name for the username and password key/value pair.
  • The Cost Management Metrics Operator is installed.

Procedure

  1. Click on the Operators > Installed Operators tab.
  2. Locate the row that contains Cost Management Metrics Operator and click on the Cost Management Metrics Operator link that is under the Provided APIs heading.
  3. When the CostManagementMetricsConfig window appears, click on the configuration file listed in the Name column.

    The default name is costmanagementmetricscfg-sample.

  4. When the costmanagementmetricscfg-sample window appears, click in the YAML tab to open an edit and view window.
  5. Locate the following lines in the YAML view.

      authentication:
        type: token
  6. Change type: token to type: basic.
  7. Insert a new line for secret_name. Enter the value for secret_name, which is the name you previously created.

    Example

      authentication:
        secret_name: basic-auth-secret
        type: basic

  8. Click the Save button. A confirmation message appears.

1.8. Creating an Openshift Container Platform source manually

If you follow the previous steps, your OpenShift Container Platform source should be created automatically. However, there are situations, such as restricted network installations, when an OpenShift Container Platform source must be created manually on Red Hat Hybrid Cloud Console.

Prerequisites

  • OpenShift Container Platform cluster installed.
  • Red Hat account user with Sources Administrator entitlements.
  • You are logged into the OpenShift Container Platform web console.

Procedure

  1. From cost management, click Settings Settings icon .
  2. Click Sources.
  3. Click Red Hat Sources.
  4. Click Add source to open the dialog.
  5. Enter a name for the source and click Next.
  6. Select the Red Hat OpenShift Container Platform tile as the source type.
  7. Select cost management as the application and click Next.
  8. Copy your Cluster Identifier from the OpenShift Container Platform web console Home > Overview tab and click Next.
  9. Review the details and click Add to create the source.

1.9. Adding a restricted network source

You can install OpenShift Container Platform on a restricted network that does not have access to the internet.

The procedure to add an OpenShift Container Platform cluster operating on a restricted network as a cost management source is different in the following ways:

  1. Operator Lifecycle Manager is configured to install and run local sources.
  2. The costmanagement-metrics-operator is configured to store cost report CSV files locally using a persistent volume claim (PVC).
  3. Cost reports stored in the PVC are downloaded to a workstation.
  4. An OpenShift Container Platform source is created manually.
  5. Cost reports are uploaded to Red Hat Hybrid Cloud Console from your workstation.

1.9.1. Installing the cost management operator on a restricted network

For OpenShift Container Platform clusters that are installed on restricted networks, Operator Lifecycle Manager (OLM) by default cannot access the costmanagement-metrics-operator hosted remotely because those remote sources require full Internet connectivity. Therefore, OLM must be configured to install and run local sources.

Prerequisites

  • OpenShift Container Platform cluster installed.
  • Workstation with unrestricted network access.
  • You are logged into the OpenShift Container Platform web console with cluster administrator privileges.

Procedure

  1. Complete the following OpenShift Container Platform procedure to create a local mirror of the costmanagement-metrics-operator: Using Operator Lifecycle Manager on restricted networks.

    Note

    The costmanagement-metrics-operator is found in the redhat-operators catalog in the registry.redhat.io/redhat/redhat-operator-index:v4.11 index.

    Red Hat recommends pruning unwanted objects from the index before pushing to the mirrored registry. Make sure you keep the costmanagement-metrics-operator package.

  2. Log in to the OpenShift Container Platform web console and click Operators > OperatorHub.
  3. Search for and locate Cost Management Metrics Operator.
  4. Click the Cost Management Metrics Operator tile.
  5. When the Install Operator window appears, you must select the costmanagement-metrics-operator namespace for installation. If the namespace does not yet exist, it is created for you.
  6. Click Install.

Verification steps

  • After a short wait, Cost Management Metrics Operator appears in the Installed Operators tab under Project: all projects or Project: costmanagement-metrics-operator.

Additional resources

1.9.2. Configuring Cost Operator on a restricted network

After the costmanagement-metrics-operator is installed, you must configure it to run on a restricted network.

Prerequisites

  • costmanagement-metrics-operator installed.
  • You are logged into the OpenShift Container Platform web console with cluster administrator privileges.

Procedure

  1. From the OpenShift Container Platform web console, select Operators > Installed Operators > costmanagement-metrics-operator > CostManagementMetricsConfig > Create Instance.
  2. Specify the desired storage. If not specified, the operator will create a default persistent volume claim called costmanagement-metrics-operator-data with 10Gi of storage.

    Note

    To configure the costmanagement-metrics-operator to use or create a different PVC, update the volume_claim_template configuration in YAML view.

  3. Select YAML view.
  4. Specify the maximum number of reports to store using max_reports_to_store, and time between report generation in minutes using upload_cycle.

        packaging:
          max_reports_to_store: 30
          max_size_MB: 100
        upload:
          upload_cycle: 360
    Important

    The costmanagement-metrics-operator creates one report every 360 minutes by default. Therefore, the default value of 30 reports and 360 minutes gives you 7.5 days of reports.

    Any report generated after the total number specified will replace the oldest report in storage. Download generated reports from your PVC before they are lost.

  5. Set upload_toggle to false.

        upload:
          upload_cycle: 360
          upload_toggle: false
  6. Replace the configuration in the source section with empty brackets.

        source: {}
  7. Replace the configuration in the authentication section with empty brackets.

        authentication: {}
  8. Click Create.

Verification steps

  1. Select the CostManagementMetricsConfig you created.
  2. Select YAML view.
  3. Verify that a report has been created in the packaging section.

        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.gz
    Note

    costmanagement-metrics-operator will generate an initial report after it is configured. Generated reports will be listed under packaged_files.

1.9.3. Downloading cost reports

If the costmanagement-metrics-operator is configured to run in a restricted network, copy the reports from the PVC where they are temporarily stored to a workstation with unrestricted network access for upload to Red Hat Hybrid Cloud Console.

Note

The default configuration saves one week of reports. Therefore, download the reports locally and upload them to Red Hat Hybrid Cloud Console weekly to prevent loss of metrics data.

Prerequisites

  • Workstation with unrestricted network access.
  • costmanagement-metrics-operator reports in your PVC.

Procedure

  1. Create the following pod with claimName matching the PVC containing 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-reports
  2. Use rsync to 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/folder
  3. Confirm that the files have been copied.
  4. Connect to the pod and delete the contents of the upload folder.

    $ oc rsh volume-shell
    $ rm /tmp/costmanagement-metrics-operator-reports/upload/*
  5. (Optional) Delete the pod that was used to connect to the PVC.

    $ oc delete -f volume-shell.yaml

Additional resources

1.9.4. Uploading cost reports to console.redhat.com

You must manually upload locally stored cost reports from a restricted network to Red Hat Hybrid Cloud Console.

Note

The default configuration saves one week of reports. Therefore, download the reports locally and upload them to Red Hat Hybrid Cloud Console weekly to prevent loss of metrics data.

Prerequisites

Procedure

  • Upload your reports to Red Hat Hybrid Cloud Console, replacing USERNAME and PASSWORD with your Red Hat Hybrid Cloud Console login credentials, and FILE_NAME with the report to upload:

    $ curl -vvvv -F "file=@FILE_NAME.tar.gz;type=application/vnd.redhat.hccm.tar+tgz"  https://cloud.redhat.com/api/ingress/v1/upload -u USERNAME:PASS

Verification steps

  1. From cost management, click OpenShift.
  2. Verify you have OpenShift usage data for your cluster on the OpenShift details page.

Chapter 2. Next steps for managing your costs

After adding your OpenShift Container Platform and cloud infrastructure sources, in addition to showing cost data by source, cost management will automatically show AWS and Azure cost and usage related to running your OpenShift Container Platform clusters on their platforms.

On the cost management Overview page, your cost data will be sorted into OpenShift and Infrastructure tabs. From here, you can use Perspective to select different views of your cost data.

You can also use the left navigation menu to view the additional details of your costs by service.

2.1. Limit access to cost management resources

After adding and configuring sources in cost management, it is a good idea to limit access to cost data and resources. For example, you may not want users to have access to all cost data, but instead only data specific to their projects or organization. Using role-based access control, you can limit the visibility of resources involved in cost management reports. For example, you may want to restrict a user’s view to only AWS sources, rather than the entire environment.

For more information about limiting access see, Limiting access to cost management resources.

2.2. Configure tagging for your sources

The cost management application tracks cloud and infrastructure costs using tags (called labels in OpenShift), which you can refine to filter and attribute to resources. Tags in cost management allow you to organize your resources by cost and to allocate the costs to different parts of your cloud infrastructure.

Important

Tags and labels can only be configured directly on a source. While you can choose what tags are activated in cost management, you cannot edit tags and labels in the cost management application.

See Managing cost data using tagging to learn more about:

  • Planning your tagging strategy to organize your view of cost data.
  • Understanding how cost management associates tags.
  • Configuring tags and labels on your sources.

2.3. Configure cost models to accurately report costs

Now that you have configured your sources to collect cost and usage data into cost management, you can configure cost models to associate prices to metrics and usage, and fine-tune the costs of running your cloud.

A cost model is a framework used to define the calculations for the costs stored in cost management, using raw costs and metrics. Costs generated by a cost model can be recorded, categorized and distributed to specific customers, business units or projects.

From the Cost Models area of cost management, you can:

  • Classify your costs as infrastructure or supplementary costs.
  • Capture monthly costs for OpenShift nodes and clusters.
  • Apply a markup to account for additional support costs.
  • Learn how to configure a cost model in Using cost models.

2.4. Use the Cost Explorer to visualize your costs

The cost management Cost Explorer allows you to create custom graphs of time-scaled cost and usage information to better visualize and interpret your costs.

See Visualizing your costs using Cost Explorer to learn more about:

  • Using Cost Explorer to identify abnormal events.
  • Understanding how your cost data changes over time.
  • Creating custom bar charts of your cost and usage data.
  • Exporting custom cost data tables.

Providing feedback on Red Hat documentation

We appreciate your feedback on our documentation. To provide feedback, highlight text in a document and add comments.

Prerequisites

  • You are logged in to the Red Hat Customer Portal.
  • In the Red Hat Customer Portal, the document is in the Multi-page HTML viewing format.

Procedure

To provide your feedback, perform the following steps:

  1. Click the Feedback button in the upper-right corner of the document to see existing feedback.

    Note

    The feedback feature is enabled only in the Multi-page HTML format.

  2. Highlight the section of the document where you want to provide feedback.
  3. Click the Add Feedback pop-up that appears near the highlighted text.

    A text box appears in the feedback section on the right side of the page.

  4. Enter your feedback in the text box and click Submit.

    A documentation issue is created.

  5. To view the issue, click the issue link in the feedback view.

Legal Notice

Copyright © 2023 Red Hat, Inc.
The text of and illustrations in this document are licensed by Red Hat under a Creative Commons Attribution–Share Alike 3.0 Unported license ("CC-BY-SA"). An explanation of CC-BY-SA is available at http://creativecommons.org/licenses/by-sa/3.0/. In accordance with CC-BY-SA, if you distribute this document or an adaptation of it, you must provide the URL for the original version.
Red Hat, as the licensor of this document, waives the right to enforce, and agrees not to assert, Section 4d of CC-BY-SA to the fullest extent permitted by applicable law.
Red Hat, Red Hat Enterprise Linux, the Shadowman logo, the Red Hat logo, JBoss, OpenShift, Fedora, the Infinity logo, and RHCE are trademarks of Red Hat, Inc., registered in the United States and other countries.
Linux® is the registered trademark of Linus Torvalds in the United States and other countries.
Java® is a registered trademark of Oracle and/or its affiliates.
XFS® is a trademark of Silicon Graphics International Corp. or its subsidiaries in the United States and/or other countries.
MySQL® is a registered trademark of MySQL AB in the United States, the European Union and other countries.
Node.js® is an official trademark of Joyent. Red Hat is not formally related to or endorsed by the official Joyent Node.js open source or commercial project.
The OpenStack® Word Mark and OpenStack logo are either registered trademarks/service marks or trademarks/service marks of the OpenStack Foundation, in the United States and other countries and are used with the OpenStack Foundation's permission. We are not affiliated with, endorsed or sponsored by the OpenStack Foundation, or the OpenStack community.
All other trademarks are the property of their respective owners.