At times, we may question the high costs of Cloud providers. However, when constructing infrastructure, the Total Cost of Ownership (TCO) is a crucial factor that must be considered. To maintain a favorable TCO, various measures must be taken, and there are numerous online discussions available on cost optimization.
In this article, we will explore one method of maintaining a reasonable number of worker nodes by adjusting application requests. In Kubernetes, the request and limit features are utilized to manage resources efficiently. By specifying resource requests for containers in a Pod, the kube-scheduler can determine which node to allocate the Pod to.
Request configuration is crucial for cost optimization. If requests are set too high, nodes may be provisioned to allocate PODs with excessive resource requests, leading to the wastage of compute resources and a loss of money for the cloud provider.
In many articles on cost optimization, the resource aspect is often overlooked. It is necessary to review the resources allocated, requested, and utilized for Namespaces in your Kubernetes cluster. However, doing this manually can be a tedious process. Fortunately, all of this information can be obtained from metrics, and dashboards can be created to display this data.
We will cover the following in this article:
- A Grafana dashboard that provides an overview of overall CPU/memory/ephemeral disk usage in your K8s cluster.
- A Grafana dashboard or table that lists current CPU usage, CPU request, current CPU request usage percentage, average CPU request usage percentage, resource limits, etc.
- A Grafana dashboard that displays the overall CPU/memory/POD usage in your Namespace.
- A Grafana dashboard that analyzes the resources used by PODs in a K8s Namespace.
Several dashboards are available for this purpose. As part of a recent analysis, I have created three dashboards (L1, L2, and L3) that provide a resource summary of your Kubernetes cluster and Namespace. The L1 dashboard provides an overview, while the L2 and L3 dashboards allow you to drill down for more detailed information.