FinOps: Realtime cost insights using Kubecost for Kubernetes Clusters
Modern, cloud-native computing is impossible to separate from containers and Kubernetes adoption.
In 2008, cgroups were merged into Linux kernel 2.6.24, which led to the creation of the project we now know as LXC. LXC stands for Linux Containers and provides virtualization at the operating system level by allowing multiple isolated Linux environments (containers) to run on a shared Linux kernel. Each one of these containers has its own process and network space.
Enter Docker.
Docker was released as an open-source project in 2013. Docker provided the ability to package software into standardized units called containers that have everything the software needs to run including libraries, system tools, code, and runtime.
Containers are a good way to bundle and run your applications. Yet as applications grew in complexity, the task of managing containers distributed across numerous servers gave rise to challenges like: how to coordinate and schedule multiple containers, how to enable communications between containers, how to scale container instances etc.
Enter Kubernetes.
Kubernetes is a container orchestration system that automates deployment, scaling and management of containerized applications. It is an open-source project that is maintained by the Cloud Native Computing Foundation (CNCF). Kubernetes is the de facto standard for container orchestration and it is used by a wide range of organizations.Kubernetes was originally developed at Google and released as open source in 2014.
A managed Kubernetes service is a cloud-based service that provides all the necessary infrastructure, tools, and support to run Kubernetes clusters.
Kubernetes is an amazingly powerful platform that provides a set of APIs to dynamically provision compute/infrastructure resources. The Kubernetes platform is commonly used in dynamic, multi-tenant environments on the cloud. The combination of these can enable teams to ramp resource consumption and costs quickly without clear visibility into why costs increased in their cloud environment. Risks of overspending in this environment are furthered by the ability to easily provision expensive resources and by programmatic provisioning tools. All of these mean that uncaught bugs or oversights can cause major cost overruns.
Enter FinOps.
FinOps is a new operating model for the cloud, bringing financial accountability to your cloud spending. It is a collaborative effort between finance, engineering, and operations teams to ensure that cloud resources are used efficiently and effectively.
The goal of FinOps is to help organizations get the most value from their cloud investments while also controlling costs.
Inform: In this phase, teams get visibility into their cloud spending in near real time and understand it at a granular level.
Optimize:Once you understand your cloud spending and cost drivers, create optimization measures and set realistic goals.In addition, cost anomaly alerts can help you identify any unusual usage patterns and cost spikes.
Operate: In this phase, your organization will implement your cost optimization plan to address the findings from the optimize phase. You should build an automated process so that cost optimization measures can be performed repeatedly
Can you gain insight into your kubernetes clusters in the cloud and understand usage patterns across kubernetes services, namespaces , pods and deployments? Yes, using Kubecost.
Kubecost is the leading open source Kubernetes cloud cost monitoring tool. It makes it easy for developers to monitor and optimize cloud infrastructure spend. Kubecost gives teams full visibility into the cost and efficiency of their modern multi-cloud infrastructure.
Main features of Kubecost
- Cost allocation: Keep track of budget allocation across all native Kubernetes concepts. This allows organisations to give their teams cost data in line with their actual cloud bill.
- Unified cost monitoring : All Kubernetes and out-of-cluster spend is found in one place. Full cloud service billing integration is included.
- Support for multiple cloud providers: Kubecost supports multiple cloud providers, including AWS, Azure, and GCP.
- Optimisation insights : Companies can save on infrastructure spend with Kubecost’s automatically generated insights.
- Alerts & governance: Real time alerts and recurring reports allow teams to effectively address monitoring interruptions instantly, monitor their spending and stay within set budgets.
How to get started with Kubecost?
In this post I have installed Kubecost on a GKE(Google Kubernetes Engine) Cluster. Google Kubernetes Engine (GKE) is a managed, production-ready environment for deploying containerized applications on Google Cloud Platform.
To install via helm 3, run the following commands:
helm upgrade — install kubecost \
— repo https://kubecost.github.io/cost-analyzer/ cost-analyzer \
— namespace kubecost — create-namespace
Port forwarding the kubecost cost-analyzer service opens up the Kubecost Dashboard.
Kubecost Components
- Kubecost cost-analyzer pod. This component runs an Nginx web server that communicates with the Kubecost back end and Prometheus server. This object performs calculations and analysis based on the cost model, and reads or writes cost utilization metrics to Prometheus for storage.
- Prometheus server. This is the time-series data store for cost metrics and analysis.
- Kube-state-metrics. This service listens to the Kubernetes API servers and generates metrics about the state of the objects, such as node and pod capacity, and status and resource requests.
- Prometheus node exporter. This exposes node-level hardware and OS-level utilization metrics.
- Grafana. An open source visualization software connects to Prometheus as a data source to build dashboards using the Kubecost cost model.
Kubecost Dashboard
Allocation
Savings and Right Sizing Recommendations
Summary
Kubecost helps uncover patterns that create overspending on infrastructure and help teams prioritize where to focus optimization efforts. This is in turn leads to improved business agility, reduces risk of non-compliance, improved governance and better visibility and transparency.