Getty Images


How to reduce the cost of Kubernetes

Is your Kubernetes bill getting out of hand? Luckily, there are ways to reduce costs. Take these five steps to lower costs without losing functionality.

Cloud computing must support applications efficiently, and cost-effectiveness is a part of that. Unfortunately, many Kubernetes deployments focus on technical operations capabilities and fail to consider the costs associated with their benefits. When cutting cloud costs, organizations must consider cost-management best practices, but Kubernetes deployments might require special attention.

Before digging too deep into cost management for Kubernetes deployments, consider the cost relationship among the ways your organization uses Kubernetes in the cloud. The most economical strategy for most enterprises is to deploy Kubernetes software and applications on cloud VMs. This gives organizations the most cost-control options and works just as well in the data center as in the cloud.

To learn how to reduce the cost of Kubernetes, we'll focus on how to approach Kubernetes with VM hosting. Managed container and Kubernetes services are likely to be higher in service costs, though they might save operations costs. Before you make any significant changes to your approach, see if a different Kubernetes hosting model would be a better option.

Begin with tools

To start cost-management initiatives, decide on a Kubernetes cost-management tool. Most enterprises trying to analyze and reduce Kubernetes costs use Kubecost, an open source tool that analyzes the IT environment to recommend cost-reduction strategies. While Kubecost is a great enterprise strategy, it's overkill for smaller organizations or companies with limited Kubernetes use. Some users prefer other tools, such as CloudForecast. Kubernetes monitoring tools can also drive cost analysis and optimization, but require more work.

It's important that Kubernetes cost-management tools and practices accommodate chargeback and cost-review policies. Most organizations don't monitor cloud costs centrally if they're allocated to business units, and this can leave major holes in cost visibility. If Kubernetes deployments share components, it can be difficult to discern whether they're inefficient or used more widely than expected.

Analyze resource use

The next thing to consider to cut down the cost of Kubernetes is how applications use resources. Most cloud Kubernetes deployments on VMs are based on a combination of reserved and on-demand instances, and some include serverless components. A move from reserved to serverless brings higher costs when applications run, but is balanced by not paying for idle resources.

Kubernetes scaling might push IT orgs into on-demand instances, which means higher hosting charges. Function hosting can create even greater cost variations under load, so explore the duty cycle of the application set and allocate enough reserved instances to support your average workloads.

Manage instances and traffic

A related best practice is to optimize AWS Spot Instances. Spot Instances are the cheapest cloud resources, but they're not always available. If you have applications or components that are used rarely and can tolerate a delay in execution to check on spot instance availability, this can often cut costs significantly.

Another scaling problem that arises in redeployment of failed components is accidental border crossings. Nearly all cloud providers charge for ingress and egress traffic, and moving a component from its normal hosting point to somewhere across a border, such as into the cloud or across multi-cloud boundaries, will lead to additional costs. Tune Kubernetes through affinities, taints and tolerations to avoid stretching application workflows across a boundary where traffic charges will apply.

Map resources appropriately

In addition to inefficient Kubernetes tuning, a significant source of cost overruns is not matching container resource requirements to node resources. There's a temptation to simplify a Kubernetes deployment by limiting the number of different resource classes used. Some pros believe that having multiple classes of resources will fragment the resource pool and lower efficiency.

But running a container with modest resource needs in a node that supplies more than enough of something wastes money. Look at how many resources are wasted by this kind of oversupply, and redesign container resource classes and Kubernetes deployment policies to better use nodes and reduce the excess.

Evaluate provider options

A final logical step to lower costs is to explore other cloud provider options. There are often significant cost differences for Kubernetes deployments across cloud providers. All major providers have cost-estimation tools, and if you're trying to lower costs, rather than to estimate the cost of a new Kubernetes deployment, this will provide enough data to get a realistic cost estimate.

If your organization finds another provider whose estimator shows potential cost saving by switching, conduct a pilot test to validate the estimate and to calculate the potential cost to switch over applications. Generally, the more provider web services an application uses, the more expensive this will be.

Whatever measures your organization takes to lower its cloud Kubernetes bill, keep in mind that reducing cloud costs can result in increasing operations costs or affecting user quality of experience (QoE). Explore each measure fully to uncover any potential Opex or QoE impacts, or you could end up pushing costs down in one place only to increase them -- or reduce application benefits -- in another.

Next Steps

Break down the Amazon EKS pricing model

Dig Deeper on Containers and virtualization

Software Quality
App Architecture
Cloud Computing
Data Center