Since more and more organizations are expanding the usage of container orchestrators, and Kubernetes is becoming a popular choice for many companies it’s crucial to understand how to get a clear picture of spending on K8s resources to enforce cost optimization opportunities.
The advantages of container technologies like portability and scalability and its open-source base have made Kubernetes the standard for running container-based apps across clouds.
Luckily, cloud platforms provide support and help companies of any size to adopt Kubernetes technology. Here there is a list of services provided by major cloud platforms:
- Amazon Elastic Kubernetes Service (Amazon EKS) on AWS
- Google Kubernetes Engine (GKE) on Google Cloud
- Microsoft Azure: Azure Kubernetes Service (AKS)
- IBM Cloud: IBM Cloud Kubernetes Service
- Oracle Cloud Infrastructure: Oracle Container Engine for Kubernetes
- Alibaba Cloud: Container Service for Kubernetes (ACK)
But the reality shows that it’s not just enough to use Kubernetes to get the best value of public clouds. Due to a recent StackRox report about 70% of companies detected misconfiguration in their Kubernetes environment.
A containerized structure creates challenges with cloud cost transparency, allocation, that cause significant difficulties in resource management, and optimization.
Realizing FinOps adoption at your company will help to overcome the challenges mentioned above. Let’s address them from the view of one of the main FinOps principles – visibility.
What are the key challenges for tracking Kubernetes costs and resources?
An effective cloud management needs cost visibility; it’s crucial to identify organizational units such as applications, cloud services, asset pools, business units, teams, individual engineers and map them onto cloud costs.
Nevertheless, Kubernetes usually is considered a black box. Сost allocation is a complicated task for this containerized technology, even when it is launched by one of the major cloud providers. Kubernetes is often used by hundreds of applications and dozens of engineers as multi-tenant system simultaneously. Service providers charge and include into a cloud bill the cost for every server instance that makes up a Kubernetes cluster.
Cost allocation in container-based systems makes additional difficulties. Most Kubernetes clusters are shared resources with applications run by many teams, which means that there’s no direct cost allocation to a specific container.
How to monitor Kubernetes workloads
Cost transparency across teams, applications and individual pods is a must-have to prevent budget overruns and avoid wastage. Companies often suffer from a lack of systems that identify the cost of each deployment, service or namespace, because Kubernetes doesn’t track any data about cost and resource usage.
For Kubernetes monitor and alert purposes companies often use Prometheus, built-in Kubernetes software and considered as one of powerful tools with an open-source base enabling cost transparency of queries and reports.
The Prometheus solution contains the following tools:
- The Prometheus Node Exporter helps in measuring various server resources such as CPU and memory usage of pods, containers and other metrics on nodes in a Kubernetes cluster
- Kube-State-Metrics generates metrics based on the state of Kubernetes objects e.g., node status, node capacity (CPU and memory), number of desired/available/unavailable/updated replicas per Deployment, pod status and so on
- The Prometheus Alertmanager allows to set up alert notifications, thresholds and send emails, trigger a pager or generate a ticket
- Grafana provides companies with the opportunity to visualize Kubernetes resource usage over time and interactive cost exploration
Using third-party financial management platforms also could facilitate the task of providing cloud cost transparency into Kubernetes infrastructure, improving visibility into shared Kubernetes clusters and their costs. Moreover, cloud financial management platforms often support capabilities that offer multi-cloud management across different platforms with providing billing data on a single dashboard.
5 main steps to provide visibility to Kubernetes environment
Start Kubernetes resource detection
As it is known, Kubernetes does not extract and keep any of the data, which is required for resource usage detection. As a first step towards an efficient Kubernetes cloud cost management it is important to set up a system for tracking shared Kubernetes clusters and storing this data in place.
Attribute Kubernetes workloads
Tagging or resource naming convention is a crucial component of achieving Kubernetes cost monitoring goals. With a deep labeling and tagging it becomes clear what Kubernetes workloads belong to a specific team, organizational unit, individual pods, project or cost center. Consistent labeling and namespace can improve your allocation strategy.
For example, companies can use Kubernetes annotations in order to automatically attribute costs to the right cost center.
Attach costs to Kubernetes objects
Companies need to implement an accounting system to attach Kubernetes environment costs and related cloud spend to the teams, individual users or business units that consumed these resources. Kubernetes allocation methodology allows your team to break down costs by namespace, label, cluster or service.
Set TTL rules, notifications and clean up policies for Kubernetes clusters
Smart TTL rules, alerts and budget constraints help to keep all Kubernetes clusters under control and prevent budget overruns. Clean up policies as one of the most important elements of the cost monitoring system enables teams to get rid of obsolete and unused resources.
Create reports
Since the resource usage data became available it has become possible to create reports for deep Kubernetes costs analysis to improve the effectiveness of the data usage experience.
Final thoughts
More than 80% of companies today run containers in production and 78% of them use Kubernetes services. However, despite the great number of users of Kubernetes technology, collecting Kubernetes metrics and monitoring cloud costs remain a tricky task. Today engineers and IT leaders are challenged to find the best way to provide cost transparency across teams, applications and individual pods in order to find an effective Kubernetes configuration and achieve optimization goals.
Our product, OptScale, can help bring visibility and get accurate unit economics for Kubernetes and traditional workloads.
To put theory into practice, you can have a free trial, no credit card needed → https://my.optscale.com/register