Leverage OpenCost on Azure Kubernetes Service to understand and monitor your infrastructure spend
Published Apr 17 2023 11:00 PM 15.7K Views
Microsoft

By adopting Kubernetes, organizations can unlock a range of cost benefits. With workloads configured to consume only the necessary resources and dynamically scale to meet demand, businesses can optimize resource usage while reducing downtime. Additionally, Kubernetes allows organizations to deploy multiple applications from various teams or business units to a single cluster, resulting in significantly reduced infrastructure costs. However, this multitenancy approach poses a new challenge.

 

Consider this scenario: your cluster generates $100/day in infrastructure spend with a shared set of resources split across 10 developer teams. If 1 team consumes 80% of the cluster’s resources, it does not make sense to split infrastructure costs evenly across all teams at $10/day. Instead, your organization may request teams to cover a proportion of the overall cost commensurate with their usage, which is not captured in your Azure bill to date. Without cost monitoring, organizations struggle to accurately track infrastructure costs for applications, Kubernetes constructs, and organizational constructs. This makes it difficult to achieve cost efficiency and perform internal chargeback.

 

The OpenCost project was launched to address these challenges. With original code provided by Kubecost, OpenCost provides a Kubernetes cost monitoring standard for the industry. OpenCost is an open-source, vendor-neutral CNCF sandbox project that recently became a FinOps Certified Solution. The project provides real-time visibility, offering a new level of transparency on Kubernetes cloud spend.

 

Microsoft joins the OpenCost community as a contributing partner

We are excited to share that Microsoft has joined the OpenCost community as a contributing partner to bring cost visibility and monitoring to AKS customers. Our initial contributions add new functionality to both AKS and OpenCost: Azure resource prices and cost export.

 

kaysieyu_0-1681559216063.png

 

Azure resource prices

The Azure Consumption Price Sheet API provides price sheet data for your subscription and billing scope with consumption and Azure Savings Plan discounts accounted for. We’ve enabled usage of this API within OpenCost for more accurate pricing and cost allocation data that aligns with customer-specific Azure resource prices. Refer to OpenCost Azure Price Configuration docs for additional details.

 

Cost export

The cost export feature allows you to generate daily cost allocation and utilization data (namespace, controller, service, pod granularity) in a CSV format that can be pushed to an Azure Storage Account, other cloud provider storage, or local storage. Metrics in the CSV include:

 

Metric

Example

Date

4/10/2023

Namespace

opencost

ControllerKind

deployment

ControllerName

opencost

Pod

opencost-8fd7f8778-s7flr

Container

opencost

CPUCoreUsageAverage

0.004746

CPUCoreRequestAverage

0.01

RAMBytesUsageAverage

1.46E+08

RAMBytesRequestAverage

55000000

NetworkReceiveBytes

2.18E+08

NetworkTransferBytes

57502870

GPUs

0

PVBytes

0

CPUCost

0.008383

RAMCost

0.002111

NetworkCost

0

PVCost

0

GPUCost

0

TotalCost

0.010494

 

The export is simple to set up and requires minimal configuration. Easily incorporate this data into external BI tooling such as SQL, Synapse, or existing data pipelines. Refer to OpenCost CSV Export docs for additional details.

 

Install OpenCost on AKS

These features are generally available in production as of OpenCost v103. Visit OpenCost Installation instructions to get started. Additionally, check out OpenCost’s blog post to learn more about our contributions.

 

How to get involved

Excited about OpenCost and looking to get involved? Find the OpenCost code, Helm chart, and specifications at https://github.com/opencost. Join the #opencost channel in the CNCF Slack. Subscribe to the OpenCost community calendar and attend the working group meetings. We look forward to collaborating with you and the broader OpenCost community!

2 Comments
Co-Authors
Version history
Last update:
‎Jul 14 2023 01:44 PM
Updated by: