The fundamentals of Kubernetes cost management

Kubernetes cost management is about more than numbers. Culture and collaboration help bring together the expertise for you to achieve Kubernetes cost savings.

high-five team
Rawpixel (CC0)

AWS recently began offering Kubecost—a third-party Kubernetes cost monitoring and management tool—to help customers rein in Enterprise Kubernetes Service (EKS) spending. It’s an unusual step for AWS that underscores the complexity of Kubernetes cost management for today’s devops teams.

Kubecost allows you to track the costs of your Kubernetes resources by namespace, deployment, service, cluster, pod, or organizational concepts like team, department, or application. But while visibility into costs is a necessary first step, it’s not all that’s needed to get Kubernetes costs under control.

Here are some guidelines to start instituting Kubernetes cost management practices in your organization.

Kubernetes cost management principles

There are some foundational principles when it comes to Kubernetes cost management. These principles don’t involve number crunching but set you up for cost management success.

Create a cost management culture

Kubernetes cost management, much like cloud cost management, is a complex undertaking. You’ll need to cultivate Kubernetes cost management expertise across your organization, starting with giving your developers and finance people the skills and tools required to manage Kubernetes costs. In many ways, Kubernetes fits perfectly into a cloud cost management initiative you may already be undertaking.

Collaboration is your copilot

Successful Kubernetes cost management doesn’t happen in a silo. Instead, it takes collaboration between team members, especially between engineering and finance. Cost optimization isn’t usually part of a developer’s skillset. Kubernetes isn’t going to be part of an accountant’s skillset either. However, the accountant will undoubtedly question the high cost of cloud services, especially runaway container costs. A cost management tool gives your development team a way to make minor Kubernetes or container configuration adjustments to reduce costs or help them build a business case for additional budget. A cost management tool can also serve as a collaboration platform between developers and finance.

Document and educate

When you have built up sufficient cross-organization expertise in Kubernetes and cost management, it’s time to document procedures and processes regarding how you use your chosen tool to calculate your Kubernetes costs. Such documentation could take a few forms:

  • Internal training about your cost management practices,
  • “Cheat sheets” that document using your chosen tool to calculate Kubernetes costs, and
  • Job aids and basic training that prepare stakeholders who aren’t Kubernetes-savvy to interact with your reporting.

Kubernetes cost management 101

Developing a Kubernetes cost management strategy can be daunting if your organization lacks significant Kubernetes expertise. But once your organization understands how to calculate Kubernetes-related costs and has come up with a way to track them, it’s ready for the next step. 

Here is the framework of a basic cost management strategy for Kubernetes.

Right size your Kubernetes environment for FinOps

Right-sizing your Kubernetes environment is a crucial cost management strategy. It’s one in which the number and types of resources available are suitable for whatever roadmap an IT organization is addressing with cloud, Kubernetes, or containers. This setup requires careful resource management to control both what resources are in use and what resources are available on standby for scaling and failover purposes.

The Cloud Native Computing Foundation (CNCF) recommends targeting the pod level for FinOps. You’ll need to depend on your organization’s Kubernetes expertise to set pod requests and limits. A pod can contain multiple containers. You’ll want to use these settings to control resource usage across all of the containers to limit the resources the pod requires.

Use Kubernetes labels for cost tracking

Your teams should already be familiar with using labels on their cloud projects for cost tracking. They should use Kubernetes labels to identify Kubernetes objects and segment them into groups. The appropriate use of labels enables your finance team to identify pod level resource usage across different applications and Kubernetes environments.

Make cost monitoring and alerting part of your daily ops

Kubernetes cost management needs to become part of your day-to-day operations. You want to give your developers the tools and strategies to automatically detect and alert them to CPU and memory requests that exceed their current usage, thus avoiding wasted costs. Such monitoring and alerting should be an extension of the service quality monitoring your teams are already performing.

Take the time to iterate on the readability and design of cost reports that break down your Kubernetes costs by deployment, service, and namespace label because these reports will serve as a common language between your devops and finance teams. Doing this work will go a long way toward making Kubernetes cost management just another automated reporting task, thus taking away some trepidation around cost management work.

Kubernetes cost management tools

While Kubernetes cost management tools make some big promises about cost savings, don’t expect to reap big savings right out of the gate. Cost management comes with a learning curve. But by helping you identify inefficiencies, waste, and opportunities for reducing costs, cost management tools can deliver significant savings over time.

Here are three Kubernetes cost management tools to consider.

Kubecost

Kubecost is a Kubernetes cost management tool with open-source roots. You’ll need to upgrade from the free version for unlimited cluster monitoring, saved reports, notifications, and other advanced capabilities. But all editions include cost allocation, which breaks down costs by namespace, deployment, services, and other variables across on-prem and cloud providers. Kubecost lets you view your Kubernetes and out-of-cluster spending in one place.

CloudZero

CloudZero enables you to ingest any cloud or software spend, including Kubernetes. It promises dynamic and explorable cost data, not static reports. CloudZero isn’t dependent on tags to track spending. It uses a proprietary domain-specific language to organize your spending in a YAML file. Being able to allocate untagged and untaggable resources makes CloudZero an appealing solution to Kubernetes cost management challenges.

Loft

Loft is a Kubernetes control plane designed for self-service and multi-tenancy. It works with industry standard Kubernetes clusters including Amazon EKS, Google Kubernetes Engine, and Rancher. Loft enables you to configure and automate the detection of idle namespaces and virtual clusters after a period you choose. You can set account quotas to limit CPU, memory, and other factors that can aggregate across all namespaces and virtual clusters belonging to a team or individual user. You can also configure an auto-delete for ephemeral instances after a period of inactivity you set. Loft includes a Prometheus integration and Grafana dashboards to enable you to set up monitoring dashboards.

The ability of your teams to learn continuously, iterate, and automate—all part of a devops culture—will be integral to the growth and maturity of your Kubernetes cost management practices. Creating detailed cost reporting will also help to ensure that your developers can collaborate with finance and other business stakeholders in a language that everyone understands.

Copyright © 2022 IDG Communications, Inc.