Search
left arrowBack
Andrew Kozlowskiy

Andrew Kozlowskiy

October 19, 2023 ・ Value

Why is my K8S getting expensive? I thought I’m saving money

The move to Kubernetes often comes with high expectations, one of which is the potential for significant cost savings. While Kubernetes does offer features that can drive efficiency and reduce costs, such as bin packing and horizontal scaling, businesses that approach the migration without a thorough understanding of the potential costs and cost-saving strategies can find themselves faced with unexpected expenses. This chapter delves into the common misconceptions and pitfalls businesses encounter related to costs in their journey with Kubernetes.

First and foremost, the allure of 'running everything in containers' can lead to overprovisioning resources. Kubernetes abstracts away the underlying infrastructure, making it easy to spin up new pods and services. This ease can lead to a "deploy now, think later" mentality, which may result in unnecessary resource usage. While the cost of a single overprovisioned pod might seem insignificant, when multiplied by hundreds or thousands of pods, the expense can become substantial.

Another potential issue lies within the resource requests space. Kubernetes supports the mechanism of requests and limits to ensure all the applications have enough resources dedicated. It’s a great tool, but if used incorrectly it may, in fact, lower the actual resource utilization level due to the problem of “over-requests”. This issue appears when the requests for the application are higher than what the application really uses. It may be caused by a number of factors. Some applications are prone to spikes in the resources they are using. Some applications during the software lifetime may have been optimized without corresponding configuration changes in resource requests on the Kubernetes side. Another frequent problem is over-requesting resources on the application's initial deployment. When the application is new and its resource requests are not yet established, it’s common to request more resources to make the application work right now and “deal with the resources later”. Of course, this “later” may never actually happen if the separate task is not planned right away.

To avoid this pitfall, it's essential to have a robust capacity planning process in place. This involves understanding the resource requirements of your applications under different loads and right-sizing your pod specifications and node types accordingly, constant monitoring of pods’ resource utilization while comparing it against pods’ requests. It’s important to understand, that “capacity planning” is an ongoing process, not a task that can be completed.

The choice of instance types also plays a significant role in costs. For example, in a cloud environment, businesses often default to general-purpose instances, but these might not be the most cost-effective choice for all workloads. Some applications might be better served by compute-optimized, memory-optimized, or even spot instances (spot instance, in general, is an instance, which is not guaranteed. It usually offers big discounts but is only suitable for non-critical short-lived workloads). Understanding your workloads and choosing the right instance types can lead to significant cost savings.

Next, managing a Kubernetes environment can be operationally intensive, and the cost of additional man-hours should not be overlooked. This includes the time spent on setting up and maintaining the environment, troubleshooting issues, and staying up-to-date with the latest Kubernetes updates and best practices. Businesses need to factor in these operational costs and explore ways to reduce them, such as automating repetitive tasks and leveraging managed Kubernetes services.

This problem shines especially on the first steps of the migration process. Once the decision is made, you will need to find an experienced engineer or train one from your current system administrators. Training an engineer out of current employees brings a bunch of problems, as this engineer will have to spend a lot of time getting to know Kubernetes. During that time no actual migration will be happening. Another issue is - this engineer won’t know about any best practices and approaches accepted and used in the Kubernetes area. While hiring a dedicated Kubernetes engineer may be unfavorable because such an engineer will spend a lot of time trying to understand how and why things are working right now and even then they will not know the current infrastructure as precisely as an experienced sysadmin who was working in this company and saw the evolution of the infrastructure will.

Finally, when considering costs, it's important to think beyond just infrastructure and operational expenses. The migration to Kubernetes itself can be costly, especially if it involves significant changes to your applications to make them cloud-native. There are also potential indirect costs, such as the impact of potential downtime during the migration, the learning curve for your team, and the cost of any new tooling you might need to manage your Kubernetes environment effectively.

In summary, while Kubernetes does provide the potential for cost savings, realizing these savings requires careful planning and management. Kubernetes is a powerful tool, yet It’s not a silver bullet that will cut costs by itself. It needs fine-tuning and an in-depth understanding of how to effectively use available tools and what kinds of issues you may face. Fortunately, all the issues mentioned above are easily mitigated by one thing - an experienced team. Although it’s hard to find or hire an experienced Kubernetes team, it’s not impossible.

In the complex realm of Kubernetes, having the right expertise is essential. Our team faces these challenges head-on every day, turning them into chances for better performance and reduced costs. If you need guidance in navigating Kubernetes, we're here, equipped with the know-how and experience to assist. Reach out to us, and let's discuss how we can craft a solution tailored to your needs.

  • Value
  • Kubernetes
  • Basics