Is it possible to estimate the cost of each individual containers in a aks cluster?

Ernesto Iser 0 Reputation points
2023-03-30T16:19:14.48+00:00

I was ask to find out how to calculate the cost of each running container inside our aks cluster relative to the actual cost of the cluster

Azure Kubernetes Service (AKS)
Azure Kubernetes Service (AKS)
An Azure service that provides serverless Kubernetes, an integrated continuous integration and continuous delivery experience, and enterprise-grade security and governance.
1,999 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Ed Harris 25 Reputation points
    2023-03-30T16:59:20.8933333+00:00

    Have you set up you AKS to work with Azure Monitor and Container Insights or another third party monitoring service for Kubernetes such as Kubecost? The answer you seek lies in implementing monitoring for each container and compare their usage in relation to the total cost of your host. To help guide you in this pursuit, here are some resources to get you started. You’d need to provide more information for me to assist you further.

    https://learn.microsoft.com/en-us/azure/azure-monitor/containers/container-insights-overview

    https://www.kubecost.com/pricing

    I see your question was updated. Using the monitoring solution of choice, take the total cost of the entire cluster and divide by the cost of the container itself based on how you're billed for the host of your cluster.

    For example, let's say I'm charged a total of 1000 this month for my AKS host based on CPU usage or IOPS at a rate of 1 dollar per unit. I have three containers. Using Azure Monitor with Container Insights I see that C1 used 350 units, C2 used only 50 units, and C3 used 600 units.

    Therefore, we can say C1 cost 350 dollars of the whole for the cluster and so on. Just replace the numbers used with your own.

    Hope this helps!

    • Ed
    0 comments No comments

  2. AirGordon 7,030 Reputation points
    2023-05-24T09:33:45.2233333+00:00

    Usually you'll report on AKS cluster cost by namespace, but it is possible by pods too.

    As Ed points out you'll need additional software installed into your Kubernetes cluster to gather this data and help you report on it. Kubecost is the most popular option, but they did release OpenCost.

    For help getting started with OpenCost, the documentation is pretty good: https://www.opencost.io/docs/

    I have also created a GitHub sample that shows end to end cluster creation to OpenCost reporting : https://github.com/azure-samples/opencost

    0 comments No comments