How to streamline cost management on Microsoft Azure Red Hat OpenShift

In this hands-on learning path created by Alireza Rahmani and Jerome Boutaud, you will learn how to use cost management for Red Hat® OpenShift® on Microsoft Azure Red Hat OpenShift to monitor and optimize workload costs.

In this hands-on learning path created by Alireza Rahmani and Jerome Boutaud, you will learn how to use cost management for Red Hat® OpenShift® on Microsoft Azure Red Hat OpenShift to monitor and optimize workload costs.

Integrating Microsoft Azure data into cost management for Red Hat OpenShift

30 mins

In this resource, we will connect our Microsoft Azure data into the cost management for Red Hat® OpenShift® service and see how we can monitor cost data from different viewpoints.

What will you learn?

  • Integrating account information from Microsoft Azure into the cost management service
  • Monitoring cost data from different viewpoints

What do you need before starting?

Prerequisites

Before beginning, you’ll need to prepare the following information by running commands from the Azure Cloud Shell.

Note: You must have a Red Hat account user with Sources Administrator entitlements before you can add integrations to cost management.

  1. Run the following command to obtain the Tenant ID:
    1. az login
                                       az account list
                                       az account tenant list
  2. Run the following command to obtain the Subscription ID:
    1. az account show --query "{ id: id }" | jq '.id' | tr -d '"')
  3. Run the following command to create the Resource group. This resource group will be used for storage account and storing exported cost.
    1. az group create --name “openenv-jrf2q-sa-alireza” --location eastus
  4. Run the following command to create the Storage account. This storage account will be used for storing exported cost files.
    1. az group create --name “costmgtsa” --location eastus
  5. Run the following command to create a ServicePrincipal with a Cost Management Storage Account Contributor role.
    1. az ad sp create-for-rbac -n "CostManagement" --role "Storage Account Contributor" --scope /subscriptions/Subscription_ID/resourceGroups/ResourceGroup_Name '{"tenant": "tenant", "client_id": "appId", "secret": "password"}'

      Replace Subscription_ID and ResourceGroup_Name with your value. 

      Make a note of "client_id": appId, "secret": password, which will be used later in this document.

  6.  Run the following command to create a Cost Management Reader Role:
    1. az role assignment create --assignee "appId" --role "Cost Management Reader" --scope "ResourceGroup"
  7. To create the Azure cost export, log in to the Azure Portal and search “Cost export” in the Search box.
     

    Azure Portal search bar showing "cost export"
    Search "cost export" in the Azure Portal search bar.
  8. Fill in the requested information, and create the export.
     

    New cost export wizard
    Fill out relevant information in the new cost export wizard.



    The export job will run daily and store the export file in the storage account for further processing by openshift cost management.

  9. Run the following command to get the cost export you just created.
    1. AzureCost export scope

Integrating data

  1. Log in to http://console.redhat.com.
  2. Under All Services > Integrations and Notifications, click Integrations.
     

    All Services in the Hybrid Cloud Console, with Integrations and Notifications highlighted
    Go to Integrations in the Hybrid Cloud Console.
  3. Click Settings > Integrations > Cloud > Add Integration.
     

    Add integration from the Integrations page
    Click Add Integration to add your Azure data integration.
  4. Choose Microsoft Azure and click Next.
     

    Cloud provider options in the cloud integration wizard
    Choose Microsoft Azure as your cloud provider.
  5. Use a unique integration name. Click Next.
     

    Naming the integration in the cloud integration wizard
    Choose a unique name for your integration.
  6. Select Cost Management as your application. Click Next
     

    Select the application in the cloud integration wizard
    Select Cost Management as your application.
  7. In the Scope level, choose Subscription.
     

    Select Subscription under the Scope drawdown menu
    Select Subscription in the Scope section.
  8. Fill the Resource group name and Storage account name with values you set in the prerequisites. Then, click Next.
     

    Resource group name and Storage account names in the cloud integration wizard
    Add the Resource group name and Storage account name values from the prerequisites steps.
  9. To fill out the Cost export name, use the cost exports you created in the Prerequisites section. Click Next.
     

    Cost export name in the cloud integration wizard
    Add the cost export name from the prerequisites steps.
  10. Fill in the Subscription ID field with information from the prerequisites. Click Next.
     

    Subscription ID name in the cloud integration wizard
    Add the Subscription ID from the prerequisites steps.
  11. Fill in Tenant ID, Client ID and Secret from the value from the prerequisite steps. Click Next.
    1. Note: Skip running the az ad sp create-for-rbac and az role assignment commands. We have run them already in the prerequisites.
       

      Tenant ID, Client ID and Secret values in the cloud integration wizard
      Add the Tenant ID, Client ID and Secret from the prerequisites step.
  12. Review all details and click Add.
     

    Review details screen in the cloud integration wizard
    Review all the details from the previous steps.
  13. Confirm that your integration has been added.
     

    View of user’s integrations in the console
    The new integration will show up in your Integrations list.
  14. From the Console, go to All services > Subscriptions and Spend > OpenShift > Cost Management
     

    View of the All Services menu with the Cost Management service under Subscriptions and Spend
    Access the Cost Management service from the All Services menu.
  15. You should now be able to explore your Cost Management dashboard, including:
    1. All OpenShift costs:
       

      Single-panel dashboard view of graphs depicting all OpenShift costs filtered by top services, accounts, and regions
      A sample dashboard for all OpenShift costs in the cost management service.
    2. Infrastructure costs specific to Microsoft Azure:
       

      Single-panel dashboard view of graphs depicting Microsoft Azure infrastructure costs filtered by top services, accounts, and regions
      A sample dashboard for all Azure infrastructure costs in the cost management service.

       

      A sample dashboard for all Azure infrastructure costs in the cost management service
      A sample dashboard for all Azure infrastructure costs in the cost management service.
    3. Infrastructure costs specific to Microsoft Azure on Red Hat OpenShift:
       

      Single-panel dashboard view of graphs depicting all ARO costs filtered by top services, accounts, and regions
      A sample dashboard for all ARO costs in the cost management service.

       

      Multi-panel dashboard view of graphs depicting storage service usage, virtual machine usage, network services cost, and database services cost
      A sample dashboard for all ARO infrastructure costs in the cost management service.

Note: If you see a “Still processing the data” message, you should wait up to 24 hours for data processing.

Cost Management dashboard with a notice stating, “Still processing the data”
Your dashboard may need 24 hours to populate with data.

Validation

To ensure that all your settings are correct, you can follow these steps:

  1. Under the OpenShift Console, go to Administrator > Operators > Installed Operators > costmanagement-metrics-operator.3.2.0 > CostManagementMetricsConfig details
  2. Click the YAML tab and search for “last_successful_upload_time” to verify that your data is successfully uploading. 
     

    a YAML file confirming the correct settings
    Validate your settings in the Operator project view under the YAML tab.
Previous resource
Integrating OCP data
Next resource
Conclusion

This learning path is for operations teams or system administrators

Developers may want to check out Learn Kubernetes using the Developer Sandbox for Red Hat OpenShift on developers.redhat.com.

Get started on developers.redhat.com

Hybrid Cloud Logo LinkedIn YouTube Facebook Twitter

Products

Tools

Try, buy, sell

Communicate

About Red Hat

We’re the world’s leading provider of enterprise open source solutions—including Linux, cloud, container, and Kubernetes. We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.