Cheapest way to run Kubernetes on Azure?

20 Jul 2022

Kubernetes is the future. There is no doubt about its capabilities, and the role it is currently and will continue to play will increase the demand for software professionals to learn Kubernetes in order to land high-paying jobs.

Harsh reality of Kubernetes is that it is not free to run, especially when you are learning and experimenting, and you must fund it out of your own pocket. As a result, today I’m going to tell you cheapest way to run/maintain a cluster in Azure.

Please keep in mind, that these recommendations are intended for running your DEV/Test/POC workloads.

Let’s get started; here are a few things to think of for “cost-optimization” about before deploying the cluster in Azure.

  1. Cluster Configuration.
  2. Region
  3. Public IP’s.
  4. Load Balancer SKU.
  5. Azure Policy.
  6. Stop the cluster.
  7. Spot Node Pool
  8. Scheduler Control
  9. Cluster Autoscaler

Cluster Configuration:

Node pool selection is critical for your cluster configuration because it’s what we’re charged for, and it has hidden costs from these four major areas, which I’ve listed below.

Instance Type — Standard B2’s .
Number of Instances — 1 (Single User Node Pool) .
Disk/Storage — Standard SSD E2.

Coming to User node pool size I’m using single node Standard B2’s instance as it’s most inexpensive VM Size at 0.042 per hour, which offers optimal performance for Dev/test workloads where as coming to Disk I’m choosing Standard SS E2 8 GB at 0.60 per hour.
                                                       Photo by Author ©


Most of us ignore region when allocating resources, but it matters a lot because prices vary from region to region. During my research, I discovered that B2’s VM and disk are relatively inexpensive in these regions: East US, East US 2, North Central US, West US 2
                                         Photo by Author ©

Public IP’s:

Unless absolutely necessary, try to keep public IP addresses to a minimum because they are charged and not offered for free. I haven’t used public IP for any services/nodes except Ingress LoadBalancer.

Load Balancer:

Services within the cluster can be exposed using a Loadbalancer/Application gateway, and they are available in two SKUs: Basic and Standard.Use the loadbalancer as much as necessary unless you want to leverage L7 capabilities such as path-based routing, etc. The basic loadbalancer SKU is provided for free; however, once provisioned, it cannot be changed.
                                                Photo by Author ©

Azure Policy:

Azure policy is offered for free of charge, and they are currently supported on Linux nodes with AKS 1.14 version and above. Enable, the built-in “Ensure CPU and memory resource limits policy” which prevents workloads from being scheduled if they exceed the policy’s resource parameters.
                                               Photo by Author ©

Stop the cluster:

AKS introduced a new feature that allows you to stop and start the kubernetes cluster whenever needed, and this is a great way to save the money when you are not using it. Even if you stop the cluster, you will continue to pay for the underlying Storage/Disks provisioned.
Here’s the cost of my single Node AKS Cluster charges incurred 5.98$ for week, which is nothing but 0.98$ per day.
                             Photo by Author ©

All of the above rules, apply to single and multi-node instances in single/multi-node pools, but if you need multiple nodes to test a few more k8’s functionalities, the following considerations should be made.

Spot Node Pool:

Use spot node pools to take advantage of unused capacity in Azure while still reaping the cost benefits of virtual machine scale set. Please keep in mind that Spot node pools cannot be upgraded and are not guaranteed.

Scheduler Control:

When deploying workloads in Kubernetes, you can tell the scheduler which nodes the workloads can and cannot run on. Workload scheduling is controlled by configuring taints, toleration, or node affinity. Spot nodes are programmed with a unique label and taint.

Cluster Autoscaler:

The Cluster Autoscaler monitors your cluster for pods that cannot be scheduled due to resource constraints. It automatically increases and decreases the number of nodes as needed to balance resource utilization.

I'm writing on medium, please follow my articles here on Cheapest way to run Kubernetes on Azure? | by Musunuru Sharmila | Towards Cloud Computing | Jul, 2022 | Medium

If you find the post enjoyable, please consider leaving us a positive review to help the author out.!! Thank you for time :)

Write & Read to Earn with BULB

Learn More

Enjoy this blog? Subscribe to sharmilamusunuru


No comments yet.
Most relevant comments are displayed, so some may have been filtered out.