ROSA HCP Cost management

I tried to trace the cost for ROSA HCP service from the AWS console and thought I could just get the report from the AWS billing feature. However, the Cost Explorer did not provide the ROSA HCP charges from the AWS console.

I am setting up the OpenShift Cost Management Operator and exploring if I can get the necessary information.

Step to set up Cost Management Operator

  • Log in to the OpenShift Console as an administrator
  • Go to Operators under the left menu and click OperatorHub, click on Cost Management Metrics Operator
  • Click “Install”
  • Take the default value and click “Install.”
  • Wait for the Operator to completed the installation
  • Go to Operators under the left menu and click Installed Operators
  • The “Cost Management Metrics Operator” should be on the list, and click on it
  • Click “Create instance”
  • The YAML view for the CostManagementMetricsConfig under the project costmanagement-metrics-operator, update the source in the YAML with “create_source: true” and a name for the source.
  • Click “Create.”

Set up on the Red Hat Hybrid Cloud Console

  • Once you log into the Red Hat Hybrid Cloud Console (OCM), you will find the integration setting as shown below.
  • Click integration. The source name was added to the cost management operator CR should show up here under the “Red Hat” tab.
  • Click Integration Setting and select Service Accounts
  • Click “Create service account” and enter the name & description of service account.
  • Click “Create.”
  • Copy the “client id” and “client secret.”
  • Under “User Access” on the left menu, select “Groups.”
  • Click on the group with cost management roles -> click the “Service accounts” tab -> click “Add service account.”
  • Select the newly created service account from the last step -> click “Add to group.”

Update the Cost Management CR with the service account

  • Log in to the OpenShift Console as an administrator
  • Create a secret for the service account we created in the last step.
  • Will need to use the copied “client_id” and “client_secret” from the service account.
  • Under the project “costmanagement-metrics-operator, click create -> select Key/Value secret
  • Add the values for “client_id” and “client_secret” and click “Create.”
  • Go to Operators under the left menu and click Installed Operators
  • Click “Cost Management Metrics Operator” -> Click “Cost Management Metic Config” tab -> click the CMMC CR
  • Under the YAML view, update the value of the secret_name and type under “authentication” section. The name of the secret matches the name of the secret you created in the previous step.
  • Click “Save.”
  • Use OCP CLI to run this command:
$ oc label namespace costmanagement-metrics-operator insights_cost_management_optimizations='true' 
  • Go back to OCM console -> Red Hat OpenShift service -> cost management.
  • I can filter the view per cluster under Cost Management -> OpenShift using group by “Cluster.” Below is a view of a cluster
  • Click “Cost Explorer” under “Cost Management” on the menu -> select “Amazon Web Service filtered by OpenShift” under Perspective and select “Group by cluster”

The terminology “filtered by OpenShift” describes the portion of the cloud provider’s cost associated with running an OpenShift cluster. When both a cloud provider and OpenShift source have been added with matching tags or resource ids in the cost reports, Cost Management can correlate the two reports to calculate how much of your cloud provider cost is related to running OpenShift.

Reference:

Running Virtual Machine on ROSA HCP

Out of curiosity, I want to see if I can run a virtual machine on my ROSA HCP cluster.

Create ROSA HCP

OCP 4.16.2 is now available on ROSA HCP. I created ROSA HCP cluster 4.16.2 for this test. Since I am following the ROSA documentation to create the ROSA HCP cluster, I share my commands here on how I create the cluster for this test. Please refer to the “Reference” section for the details.

$ rosa create account-roles --hosted-cp
$ export ACCOUNT_ROLES_PREFIX=ManagedOpenShift
$ rosa create oidc-config --mode=auto --yes
$ export OIDC_ID=xxxxxxxx
$ export OPERATOR_ROLES_PREFIX=demo
$ rosa create operator-roles --hosted-cp --prefix=$OPERATOR_ROLES_PREFIX --oidc-config-id=$OIDC_ID --installer-role-arn arn:aws:iam::${AWS_ACCOUNT_ID}:role/${ACCOUNT_ROLES_PREFIX}-HCP-ROSA-Installer-Role
$ rosa create cluster --sts --oidc-config-id 2ci6ntk6g92bq7qm21pvhfff1fp07li1 --operator-roles-prefix demo --hosted-cp --subnet-ids $SUBNET_IDS

After my cluster installation completes, log into Red Hat Hybrid Cloud Console to configure access for the cluster.

  • Click on the cluster name -> click on the “Access control” tab -> select htpasswd as the IDP to add a user
  • Click Add after entering the user information
  • Click “Add user” to add a cluster-admin as shown below
  • Go to the Network tab -> click “open console” and log in to the ROSA HCP cluster.

Install OpenShift Virtualization Operator

  • Once you log in as cluster admin to the OpenShift console -> Click Operators -> OperatorHub -> click OpenShift Virtualization -> Click “Install”
  • Click the “Installed Operators” on the left nav -> make sure the status show as “Succeed” for OpenShift Virtualization Operator.
  • Click “OpenShift Virtualization” -> OpenShift Virtualization Deployment -> Create HyperConverged CR using the YAML as shown below.
apiVersion: hco.kubevirt.io/v1beta1
kind: HyperConverged
metadata:
name: kubevirt-hyperconverged
namespace: openshift-cnv
annotations:
deployOVS: "false"
labels:
app: kubevirt-hyperconverged
spec:
applicationAwareConfig:
allowApplicationAwareClusterResourceQuota: false
vmiCalcConfigName: DedicatedVirtualResources
certConfig:
ca:
duration: 48h0m0s
renewBefore: 24h0m0s
server:
duration: 24h0m0s
renewBefore: 12h0m0s
evictionStrategy: LiveMigrate
featureGates:
alignCPUs: false
autoResourceLimits: false
deployKubeSecondaryDNS: false
deployTektonTaskResources: false
deployVmConsoleProxy: false
disableMDevConfiguration: false
enableApplicationAwareQuota: false
enableCommonBootImageImport: true
enableManagedTenantQuota: false
nonRoot: true
persistentReservation: false
withHostPassthroughCPU: false
infra: {}
liveMigrationConfig:
allowAutoConverge: false
allowPostCopy: false
completionTimeoutPerGiB: 800
parallelMigrationsPerCluster: 5
parallelOutboundMigrationsPerNode: 2
progressTimeout: 150
resourceRequirements:
vmiCPUAllocationRatio: 10
uninstallStrategy: BlockUninstallIfWorkloadsExist
virtualMachineOptions:
disableFreePageReporting: false
disableSerialConsoleLog: true
workloadUpdateStrategy:
batchEvictionInterval: 1m0s
batchEvictionSize: 10
workloadUpdateMethods:
- LiveMigrate
workloads: {}

Create Bare Metal MachinePool (with IMDSv2)

  • Enter a name, select the subnet, select m5zn.metal as the instance type, and add a label (type=metal). You will need to use the same label when creating VMs in the later step.

Making sure the bare metal EC2 instance is up

When the machine pool was first created, I saw the metal node was terminated. I enabled the IMDSv2 on the metal node, and the node can start.

Update Notes (09/2024): using ROSA CLI 1.2.43+, you can use ROSA CLI to create the machine pool with the flag --ec2-metadata-http-tokens=required. Then you will enable IMDSv2 at the creation. An Example of the command to create a machine pool via ROSA CLI is shown below.

rosa create machinepool --cluster=rosa-hcp --name=virt-mp   --replicas=1  --instance-type=m5zn.metal --ec2-metadata-http-tokens=required

Create a VM

Once the bare metal node is up, and the OpenShift virtualization operator is installed and configured successfully. You are ready to create a VM.

  • Go to the OpenShift console, select “Overview” under Virtualization on the left menu -> click “Create VirtualMachine”
  • Create a new project and give a new of your project
  • Click “Template catalog” -> Fedora VM
  • Click “Customize VirtualMachine”

  • Click YAML tab and add nodeSelector with Label “type: metal”
  • Click “Create VirtualMachine”
  • The VirtualMachine should be in running in a few minutes.

Reference: