Skip to content

Improve docs for Kubecost #980

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: mainline
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -314,17 +314,13 @@ Yes. `Kubectl-cost` is an open source tool by Kubecost (Apache 2.0 License) that

Kubecost provides a web dashboard that you can access through `kubectl` port forwarding, an ingress, or a load balancer. You can also use the {aws} Load Balancer Controller to expose Kubecost and use Amazon Cognito for authentication, authorization, and user management. For more information, see link:containers/how-to-use-application-load-balancer-and-amazon-cognito-to-authenticate-users-for-your-kubernetes-web-apps[How to use Application Load Balancer and Amazon Cognito to authenticate users for your Kubernetes web apps,type="blog"] on the {aws} blog.

*Is Amazon EKS Anywhere supported?*

No.
Comment on lines -317 to -319
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


[#kubecost-additional]
== Additional Kubecost Features

* The following features are available in both Kubecost v1 and v2.
* *Export cost metrics* – Amazon EKS optimized cost monitoring is deployed with Kubecost and Prometheus, which is an open-source monitoring system and time series database. Kubecost reads metric from Prometheus and then performs cost allocation calculations and writes the metrics back to Prometheus. The Kubecost front-end reads metrics from Prometheus and shows them on the Kubecost user interface. The architecture is illustrated in the following diagram.
** *Export cost metrics* – Amazon EKS optimized cost monitoring is deployed with Kubecost and Prometheus, which is an open-source monitoring system and time series database. Kubecost reads metric from Prometheus and then performs cost allocation calculations and writes the metrics back to Prometheus. The Kubecost front-end reads metrics from Prometheus and shows them on the Kubecost user interface. The architecture is illustrated in the following diagram.
+
image::images/kubecost-architecture.png[Kubecost architecture,scaledwidth=100%]
+
With https://prometheus.io/[Prometheus] pre-installed, you can write queries to ingest Kubecost data into your current business intelligence system for further analysis. You can also use it as a data source for your current https://grafana.com/[Grafana] dashboard to display Amazon EKS cluster costs that your internal teams are familiar with. To learn more about how to write Prometheus queries, see the https://opencost.io/docs/installation/prometheus/[Prometheus Configuration]``readme`` file on GitHub or use the example Grafana JSON models in the https://github.com/kubecost/cost-analyzer-helm-chart/tree/develop/cost-analyzer[Kubecost Github repository] as references.
* *{aws} Cost and Usage Report integration* – To perform cost allocation calculations for your Amazon EKS cluster, Kubecost retrieves the public pricing information of {aws} services and {aws} resources from the {aws} Price List API. You can also integrate Kubecost with *{aws} Cost and Usage Report* to enhance the accuracy of the pricing information specific to your {aws} account. This information includes enterprise discount programs, reserved instance usage, savings plans, and spot usage. To learn more about how the {aws} Cost and Usage Report integration works, see https://www.ibm.com/docs/en/kubecost/self-hosted/2.x?topic=integrations-aws-cloud-billing-integration[{aws} Cloud Billing Integration] in the Kubecost documentation.
** *{aws} Cost and Usage Report integration* – To perform cost allocation calculations for your Amazon EKS cluster, Kubecost retrieves the public pricing information of {aws} services and {aws} resources from the {aws} Price List API. You can also integrate Kubecost with *{aws} Cost and Usage Report* to enhance the accuracy of the pricing information specific to your {aws} account. This information includes enterprise discount programs, reserved instance usage, savings plans, and spot usage. To learn more about how the {aws} Cost and Usage Report integration works, see https://www.ibm.com/docs/en/kubecost/self-hosted/2.x?topic=integrations-aws-cloud-billing-integration[{aws} Cloud Billing Integration] in the Kubecost documentation.
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
include::../attributes.txt[]

[.topic]
[#cost-monitoring-kubecost-dashboard]
= Access Kubecost Dashboard

[#kubecost-prereqs-dashboard]
== Prerequisites

. Make sure the kubecost related Pods' state are "Running".

[source,bash,subs="verbatim,attributes"]
----
kubectl get pods --namespace kubecost
----

[#kubecost-dashboard]
== Access Kubecost Dashboard

. On your device, enable port-forwarding to expose the Kubecost dashboard.
+
[source,bash,subs="verbatim,attributes"]
----
kubectl port-forward deployment/kubecost-cost-analyzer 9090 --namespace kubecost
----
+
Alternatively, you can use the <<aws-load-balancer-controller,{aws} Load Balancer Controller>> to expose Kubecost and use Amazon Cognito for authentication, authorization, and user management. For more information, see link:containers/how-to-use-application-load-balancer-and-amazon-cognito-to-authenticate-users-for-your-kubernetes-web-apps[How to use Application Load Balancer and Amazon Cognito to authenticate users for your Kubernetes web apps,type="blog"].
. On the same device that you completed the previous step on, open a web browser and enter the following address.
+
[source,bash,subs="verbatim,attributes"]
----
http://localhost:9090
----
+
You see the Kubecost Overview page in your browser. It might take 5–10 minutes (or more) for Kubecost to gather metrics, depends on your cluster size. You can see your Amazon EKS spend, including cumulative cluster costs, associated Kubernetes asset costs, and monthly aggregated spend.
Copy link
Contributor Author

@guessi guessi Apr 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could be vary if cluster size is relatively large, minor tweak to add ... (or more) and , depends on your cluster size after page moved.

+
. To track costs at a cluster level, tag your Amazon EKS resources for billing. For more information, see <<tag-resources-for-billing>>.


* *Cost allocation* – View monthly Amazon EKS costs and cumulative costs for each of your namespaces and other dimensions over the past seven days. This is helpful for understanding which parts of your application are contributing to Amazon EKS spend.
* *Assets* – View the costs of the {aws} infrastructure assets that are associated with your Amazon EKS resources.
110 changes: 11 additions & 99 deletions latest/ug/cluster-management/cost-monitoring-kubecost.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ include::../attributes.txt[]

[.topic]
[#cost-monitoring-kubecost]
= Install Kubecost and access dashboard
= Install Kubecost
:info_titleabbrev: Install Kubecost

Amazon EKS supports Kubecost, which you can use to monitor your costs broken down by Kubernetes resources including Pods, nodes, namespaces, and labels. This topic covers installing Kubecost, and accessing the Kubecost dashboard.
Amazon EKS supports Kubecost, which you can use to monitor your costs broken down by Kubernetes resources including Pods, nodes, namespaces, and labels. This topic covers installing Kubecost, and accessing the Kubecost dashboard.

Amazon EKS provides an {aws} optimized bundle of Kubecost for cluster cost visibility. You can use your existing {aws} support agreements to obtain support. For more information about the available versions of Kubecost, see <<cost-monitoring-kubecost-bundles>>.

Expand All @@ -18,104 +18,16 @@ Kubecost v2 introduces several major new features. <<kubecost-v2,Learn more abou

For more information about Kubecost, see the https://www.ibm.com/docs/en/kubecost/self-hosted/2.x[Kubecost] documentation and <<cost-monitoring-faq, Frequently asked questions>>.

[#kubecost-overview]
== Install Amazon EKS optimized Kubecost bundle

[#kubecost-addon]
== Install Kubecost using Amazon EKS Add-ons
You can use one of the following procedures to install the _Amazon EKS optimized Kubecost bundle_:

[NOTE]
====
Install Kubecost as an Amazon EKS Add-on and benefit from additional features at no additional cost with the _Amazon EKS optimized Kubecost bundle_. For more information, see <<kubecost-v2>>.
====

Amazon EKS Add-ons reduce the complexity of upgrading Kubecost, and managing licenses. EKS Add-ons are integrated with the {aws} marketplace.

. View link:marketplace/seller-profile?id=983de668-2731-4c99-a7e2-74f27d796173[Kubecost in the {aws} Marketplace console,type="marketing"] and subscribe.
. Determine the name of your cluster, and the region. Verify you are logged into the {aws} CLI with sufficient permissions to manage EKS.
. Create the Kubecost addon.
+
[source,bash,subs="verbatim,attributes"]
----
aws eks create-addon --addon-name kubecost_kubecost --cluster-name $YOUR_CLUSTER_NAME --region $AWS_REGION
----

Learn how to <<removing-an-add-on,remove an EKS Add-on>>, such as Kubecost.

[#kubecost-helm]
== Install Kubecost using Helm

* An existing Amazon EKS cluster. To deploy one, see <<getting-started>>.
* The `kubectl` command line tool is installed on your device or {aws} CloudShell. The version can be the same as or up to one minor version earlier or later than the Kubernetes version of your cluster. For example, if your cluster version is `1.29`, you can use `kubectl` version `1.28`, `1.29`, or `1.30` with it. To install or upgrade `kubectl`, see <<install-kubectl>>.
* https://helm.sh/docs/topics/version_skew/#supported-version-skew[Supported Helm versions] on your device or {aws} CloudShell. To install or update Helm, see <<helm>>.
* Cluster version should be `1.21 (or higher)` and `1.31` is officially supported as of v2. Learn more at https://www.ibm.com/docs/en/kubecost/self-hosted/2.x?topic=installation-environment#ariaid-title2[Supported Kubernetes versions].
* If your cluster is version `1.23` or later, you must have the <<ebs-csi,Store Kubernetes volumes with Amazon EBS>> installed on your cluster.

. Determine the version of Kubecost to install. You can see the available versions at https://gallery.ecr.aws/kubecost/cost-analyzer[kubecost/cost-analyzer] in the Amazon ECR Public Gallery. For more information about the compatibility of Kubecost versions and Amazon EKS, see the https://www.ibm.com/docs/en/kubecost/self-hosted/2.x?topic=installation-environment[Environment Requirements] in the Kubecost documentation.
. Install Kubecost with the following command. Replace [.replaceable]`KUBECOST_VERSION` with the value retrieved from ECR, such as [.replaceable]`1.108.1`.
+
[source,bash,subs="verbatim,attributes"]
----
export KUBECOST_VERSION="1.108.1"

helm upgrade -i kubecost \
oci://public.ecr.aws/kubecost/cost-analyzer \
--version ${KUBECOST_VERSION} \
--namespace kubecost --create-namespace \
-f https://github.com/raw/kubecost/cost-analyzer-helm-chart/refs/tags/v${KUBECOST_VERSION}/cost-analyzer/values-eks-cost-monitoring.yaml
----
+
Kubecost releases new versions regularly. You can update your version using https://helm.sh/docs/helm/helm_upgrade/[helm upgrade]. By default, the installation includes a local https://prometheus.io/[Prometheus] server and `kube-state-metrics`. You can customize your deployment to use link:mt/integrating-kubecost-with-amazon-managed-service-for-prometheus[Amazon Managed Service for Prometheus,type="blog"] by following the documentation in link:prometheus/latest/userguide/integrating-kubecost.html[Integrating with Amazon EKS cost monitoring,type="documentation"]. For a list of all other settings that you can configure, see the https://github.com/kubecost/cost-analyzer-helm-chart/blob/develop/cost-analyzer/values-eks-cost-monitoring.yaml[sample configuration file] on GitHub.

+
* You can remove Kubecost from your cluster with the following commands.
+
[source,bash,subs="verbatim,attributes"]
----
helm uninstall kubecost --namespace kubecost
----
+
[source,bash,subs="verbatim,attributes"]
----
kubectl delete namespace kubecost
----

[#kubecost-dashboard]
== Access Kubecost Dashboard
. Make sure the required Pods are running.

[source,bash,subs="verbatim,attributes"]
----
kubectl get pods --namespace kubecost
----

An example output is as follows.

[source,bash,subs="verbatim,attributes"]
----
NAME READY STATUS RESTARTS AGE
kubecost-cost-analyzer-b9788c99f-5vj5b 2/2 Running 0 3h27m
kubecost-kube-state-metrics-99bb8c55b-bn2br 1/1 Running 0 3h27m
kubecost-prometheus-server-7d9967bfc8-9c8p7 2/2 Running 0 3h27m
----
. On your device, enable port-forwarding to expose the Kubecost dashboard.
+
[source,bash,subs="verbatim,attributes"]
----
kubectl port-forward deployment/kubecost-cost-analyzer 9090 --namespace kubecost
----
+
Alternatively, you can use the <<aws-load-balancer-controller,{aws} Load Balancer Controller>> to expose Kubecost and use Amazon Cognito for authentication, authorization, and user management. For more information, see link:containers/how-to-use-application-load-balancer-and-amazon-cognito-to-authenticate-users-for-your-kubernetes-web-apps[How to use Application Load Balancer and Amazon Cognito to authenticate users for your Kubernetes web apps,type="blog"].
. On the same device that you completed the previous step on, open a web browser and enter the following address.
+
[source,bash,subs="verbatim,attributes"]
----
http://localhost:9090
----
+
You see the Kubecost Overview page in your browser. It might take 5–10 minutes for Kubecost to gather metrics. You can see your Amazon EKS spend, including cumulative cluster costs, associated Kubernetes asset costs, and monthly aggregated spend.
+
image::images/kubecost.png[Kubecost dashboard,scaledwidth=100%]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove image here as the image is for v1 whereas the instruction may be v2.

. To track costs at a cluster level, tag your Amazon EKS resources for billing. For more information, see <<tag-resources-for-billing>>.
* Before start, it is recommended to review https://www.ibm.com/docs/en/kubecost/self-hosted/2.x?topic=installations-amazon-eks-integration[Kubecost - Architecture Overview] to understand how Kubecost works on Amazon EKS.
* If you are new to Amazon EKS we recommend that you use Helm for the installation because it simplifies the _Amazon EKS optimized Kubecost bundle_ installation. For more information, see https://www.ibm.com/docs/en/kubecost/self-hosted/2.x?topic=installations-amazon-eks-integration#ariaid-title3[Deploying Kubecost on an Amazon EKS cluster using Amazon EKS add-on].
* To customize the installation, you might configure your _Amazon EKS optimized Kubecost bundle_ with Helm. For more information, see https://www.ibm.com/docs/en/kubecost/self-hosted/2.x?topic=installations-amazon-eks-integration#ariaid-title8[Deploying Kubecost on an Amazon EKS cluster using Helm] in the _Kubecost documentation_.

[#kubecost-access-dashbaard]
== Access Kubecost dashboard

* *Cost allocation* – View monthly Amazon EKS costs and cumulative costs for each of your namespaces and other dimensions over the past seven days. This is helpful for understanding which parts of your application are contributing to Amazon EKS spend.
* *Assets* – View the costs of the {aws} infrastructure assets that are associated with your Amazon EKS resources.
Once the _Amazon EKS optimized Kubecost bundle_ setup done, you should have access to Kubecost dashboard. For more information, see <<cost-monitoring-kubecost-dashboard>>.
4 changes: 3 additions & 1 deletion latest/ug/cluster-management/cost-monitoring.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ Cost monitoring is an essential aspect of managing your Kubernetes clusters on A

*{aws} Billing split cost allocation data for Amazon EKS* -- This native feature integrates seamlessly with the {aws} Billing Console, allowing you to analyze and allocate costs using the same familiar interface and workflows you use for other {aws} services. With split cost allocation, you can gain insights into your Kubernetes costs directly alongside your other {aws} spend, making it easier to optimize costs holistically across your {aws} environment. You can also leverage existing {aws} Billing features like Cost Categories and Cost Anomaly Detection to further enhance your cost management capabilities. For more information, see link:cur/latest/userguide/split-cost-allocation-data.html[Understanding split cost allocation data,type="documentation"] in the {aws} Billing User Guide.

*Kubecost* -- Amazon EKS supports Kubecost, a Kubernetes cost monitoring tool. Kubecost offers a feature-rich, Kubernetes-native approach to cost monitoring, providing granular cost breakdowns by Kubernetes resources, cost optimization recommendations, and out-of-the-box dashboards and reports. Kubecost also retrieves accurate pricing data by integrating with the {aws} Cost and Usage Report, ensuring you get a precise view of your Amazon EKS costs. Learn how to <<kubecost-addon,Install Kubecost>>.
*Kubecost* -- Amazon EKS supports Kubecost, a Kubernetes cost monitoring tool. Kubecost offers a feature-rich, Kubernetes-native approach to cost monitoring, providing granular cost breakdowns by Kubernetes resources, cost optimization recommendations, and out-of-the-box dashboards and reports. Kubecost also retrieves accurate pricing data by integrating with the {aws} Cost and Usage Report, ensuring you get a precise view of your Amazon EKS costs. Learn how to <<kubecost-overview,Install Kubecost>>.

include::cost-monitoring-aws.adoc[leveloffset=+1]

include::cost-monitoring-kubecost.adoc[leveloffset=+1]

include::cost-monitoring-kubecost-view-dashboard.adoc[leveloffset=+1]

include::cost-monitoring-kubecost-bundles.adoc[leveloffset=+1]
Binary file removed latest/ug/images/kubecost.png
Binary file not shown.