EKS Pricing: How to use Kubecost in an EKS Cluster
top of page

EKS Pricing: How to use Kubecost in an EKS Cluster

Kubecost is an efficient and powerful tool that allows you to manage costs and resource allocation in your Kubernetes cluster. It provides a detailed view of the resources used by your applications and helps optimize resource usage, which can ultimately reduce cloud costs.


the-Kubecost-front-end-reads-metrics-from-Prometheus-and-shows-them-on-the-Kubecost-user-interface


In this document, we’ll guide you through the necessary steps to use Kubecost in your Kubernetes cluster. Let’s dive in.


Deploy Kubecost in Amazon EKS

To get started, follow these steps to deploy Kubecost into your Amazon EKS cluster in just a few minutes using Helm.

  1. Install the following tools: Helm 3.9+, kubectl, and optionally eksctl and awscli.

  2. You have access to an Amazon EKS cluster. To deploy one, see Getting started with Amazon EKS.

  3. If your cluster is running Kubernetes version 1.23 or later, you must have the Amazon EBS CSI driver installed on your cluster.


Step# 1: Install Kubecost on your Amazon EKS cluster.

In your environment, run the following command from your terminal to install Kubecost on your existing Amazon EKS cluster.


helm upgrade -i kubecost \

oci://public.ecr.aws/kubecost/cost-analyzer --version 1.99.0 \

--namespace kubecost --create-namespace \

-f https://raw.githubusercontent.com/kubecost/cost-analyzer-helm-chart/develop/cost-analyzer/values-eks-cost-monitoring.yaml


Note: You can find all available versions of the EKS-optimized Kubecost bundle here. We recommend finding and installing the latest available Kubecost cost analyzer chart version.

By default, the installation includes certain prerequisite software including Prometheus and kube-state-metrics. To customize your deployment (e.g., skipping these prerequisites if you already have them running in your cluster), you can find a list of available configuration options in the Helm configuration file.



Step #2: Generate the Kubecost dashboard endpoint.


After you install Kubecost using the Helm command in step 2, it should take under two minutes to complete. You can run the following command to enable port-forwarding to expose the Kubecost dashboard:

kubectl port-forward --namespace kubecost deployment/kubecost-cost-analyzer 9090



Step #3: Access cost monitoring dashboard.

On your web browser, navigate to http://localhost:9090 to access the dashboard.

You can now start tracking your Amazon EKS cluster cost and efficiency. Depending on your organization’s requirements and set up, there are several options to expose Kubecost for on-going internal access. There are a few examples that you can use for your references:


-Overview of available metrics

The following are examples of the metrics available within the Kubecost dashboard.


metrics-available-within-the-Kubecost-dashboard-including-cumulative-cluster-costs-associated-Kubernetes-asset-costs-and-monthly-aggregated-spend

Use Kubecost to quickly see an overview of Amazon EKS spend, including cumulative cluster costs, associated Kubernetes asset costs, and monthly aggregated spend.


-Cost allocation by namespace

view-of-monthly-Amazon-EKS-costs

View monthly Amazon EKS costs as well as cumulative costs per namespace and other dimensions up to the last 15 days. This enables you to better understand which parts of your application are contributing to Amazon EKS spend.


-Spend and usage for other AWS Services associated with Amazon EKS clusters

costs-of-AWS-infrastructure-assets-that-are-associated-with-their-EKS-resources

View the costs of AWS infrastructure assets that are associated with their EKS resources.


-Export Cost Metrics

At a high level, Amazon EKS cost monitoring is deployed with Kubecost, which includes Prometheus, an open-source monitoring system and time series database. Kubecost reads metrics from Prometheus, then performs cost allocation calculations, and writes the metrics back to Prometheus. Finally, the Kubecost front end reads metrics from Prometheus and shows them on the Kubecost user interface (UI). The architecture is illustrated by the following diagram:


the-Kubecost-front-end-reads-metrics-from-Prometheus-and-shows-them-on-the-Kubecost-user-interface


-Kubecost reading metrics

With this pre-installed Prometheus, you can also write queries to ingest Kubecost data in your current business intelligence system for further analysis. You can also use it as a data source for your current Grafana dashboard to display Amazon EKS cluster costs that your internal teams are familiar with. To learn more about how to write Prometheus queries, review Kubecost’s documentation or use example Grafana JSON models in the Kubecost Github repository as references.


-AWS Cost and Usage Report (AWS CUR) integration

To perform cost allocation calculations for your Amazon EKS cluster, Kubecost retrieves the public pricing information of AWS services and resources from AWS Price List API. You can also integrate Kubecost with the AWS CUR to enhance the accuracy of pricing information that is specific to your AWS account (e.g., Enterprise Discount Programs, Reserved Instance usage, Savings Plans, and Spot usage). You can learn more on how the AWS CUR integration works at AWS Cloud Integration.


-Cleanup

You can uninstall Kubecost from your cluster with the following command.

helm uninstall kubecost --namespace kubecost



Final thoughts


Implementing Kubecost in your Amazon EKS cluster can significantly enhance your cost management and resource optimization efforts. By providing a comprehensive view of resource usage and associated costs, Kubecost empowers you to make informed decisions on optimizing resource allocation, which can lead to reduced cloud costs. Its easy deployment process using Helm makes it accessible to users with various levels of expertise.


Additionally, Kubecost's integration with Prometheus enables you to leverage your existing business intelligence systems and Grafana dashboards for further analysis and visualization.


Overall, Kubecost proves to be an invaluable tool for cost-conscious organizations seeking to maximize their Amazon EKS cluster's efficiency while keeping cloud expenditures in check. Give Kubecost a try today and take control of your Kubernetes cost management with ease.


"




Martín Carletti

Cloud Engineer

Teracloud






If you want to know more about Kubernetes, we suggest going check Conftest: The path to more efficient and effective Kubernetes automated testing

 

If you are interested in learning more about our #TeraTips or our blog's content, we invite you to see all the content entries that we have created for you and your needs. And subscribe to be aware of any news! 👇 



Entradas recientes
Buscar por tags
Síguenos
  • Twitter Basic Square
bottom of page