Demystifying Kubecost with EKS cluster
Soumyadip Chatterjee
AWS DevOps Engineer| EPAM Systems |Ex-TCS| Terraform ???, |Docker ?? | K8's??| Snowflake ?? | Argo CD?? | Helm ?? | GitLab ?? | Ansible ?? | Certifications:- 2x AWS ??, 1x Azure???, 1x OCI??, 1x Commvault
In Cloud & Devops community I got multiple inspirations on a daily basis from many folks . But there are few special ones , who really spot on . Amongst them Mathesh M .
In this article we will walk through and understand the below topic towards cost optimization of EKS cluster which is most critical part from the enterprises prospective . So why wait , let's get started
What is eksdemo ?
It's a command line tool to spin up EKS cluster manage , monitor just like eksctl . It's incorporated by AWS within its community and then developing things . Hopefully we will seen more improvements and enhancements towards eksdemo going forward .
What is Kubecost ?
Kubecost is a powerful tool used to track , monitor and notify EKS cluster admins , DevOps folks for underutilized , unused pods , nodes towards Cost optimization . Kubecost provides real-time cost visibility and insights for teams using Kubernetes, helping you continuously reduce your cloud costs.
How eksdemo relate with Kubecost ?
Eksdemo is like kubectl which is a command line tool to create , manage , isolate or delete EKS clusters which by the assistance with CloudFormation (IaaC) the EKS cluster creation can be automated .
Another significant feature in kubecost is that it comes pre-configure with Prometheus ,so metric collection and customise Dashboard can be in tandem with KubeCost . It's act as a centralized platform for all of our enterprises to manage multiple EKS cluster and huge no of nodes and pods at scale . It's also comes with Free & Paid version .
End to End demo of Kubecost by spinning up a EKS cluster via eksdemo command line tool .
For Linux:
wget https://github.com/awslabs/eksdemo/releases/download/v0.15.0/eksdemo_Linux_x86_64.tar.gz
tar -xvf eksdemo_Linux_x86_64.tar.gz
sudo mv eksdemo /usr/local/bin/
eksdemo version
eksdemo create cluster -c <cluster-name>
# The above command will create the EKS Cluster with the default configurations. Also one thing to mention, as I told earlier, eksdemo is built on top of eksctl. So behind the scenes, it will use the eksctl to create the EKS Cluster.
eksdemo get cluster
Now prior to install the Kubecost we require EBS CSI Driver . Additionally if you are installing Kubecost using Helm , then please read the following notes .
领英推荐
So from the above notes we should have Helm and EBS CSI driver installed in the EKS cluster .
eksdemo install storage-ebs-csi -c Eksdemocluster
Installing Kubecost :-
As previously highlighted that Kubecost pre-configure comes with Prometheus , hence you can view all of the pods both for Kubecost & Prometheus .Because for collecting the metrics, Kubecost uses the Prometheus behind the scenes.
If you already have the Prometheus installed in your EKS cluster, you can skip the --node-exporter flag.
eksdemo install kubecost-eks-amp -c <cluster-name> --node-exporter
The command also create a Load balancer to expose the service and access the Kubecost Dashboard from web by running the Load balancer URL .
kubectl get svc -n kubecost
Let's now navigate to some of the features by some useful snippets ,which will ease things about Kubecost .
Savings :- It can displayed an approximate Savings on EKS clusters with all recommendations in multiple areas from pods to nodes .
The Allocation feature also provide cumulative cost by namespace . So if my EKS cluster setup by any namespace. We can optimize the cost based on Namespace as well which will an impact of a Microservices feature .
Alerts Toggle :- In the top right hand Alerts icon can be notify users , administrators who are monitoring Kubecost on daily basis .
Lastly under Contexts we can switch clusters from one to another through Kubecost UI .
Also you might be interested in Reporting and sharing with multiple stakeholders .
This concludes the End to End walk through of Kubecost which facilitates the comprehensive cost monitoring of metrics back by Prometheus and play a significant role in Enterprise towards Kubernetes cost monitoring and reduction towards Application transformation journey .