Cloud Services / DevOps / Kubernetes / Contributed

Run a Google Kubernetes Engine Cluster for Under $25/Month

13 Jan 2022 10:00am, by
Eric Murphy
Eric is a field engineer for Solo.io. He loves to think big picture about software design and how technology can solve business problems. In the past, Eric has led workshops on topics such as Kubernetes, Java and domain-driven design. Additionally, Eric is a published author through O’Reilly and has presented globally at technical conferences.

If you’re learning or tinkering with Kubernetes, you have great options to run Kubernetes with a discount service provider such as Civo, or simply run Kubernetes on your laptop. Yet, running Kubernetes on a major cloud provider is the only way to get the full experience of Kubernetes and gain the critical skills needed for a job using Kubernetes in the cloud.

The options to run Kubernetes at a discount on Amazon Web Services, Azure, and Google Cloud are confusing and ultimately riddled with hidden costs. Additionally, many free credits are temporary. One major benefit of Civo — the cost is fixed and simple to understand. As a learner or tinkerer, you want to keep the costs minimal, under $1 per day if possible.

This article will demonstrate a solution (available on GitHub) for running a full-blown GKE cluster on Google Cloud with a goal to keep the costs under $1 per day. The cluster has three nodes, six cores, and 24GB RAM and is large enough to run nontrivial workloads to learn the critical skills on how to scale applications on Kubernetes.

You can easily deploy the Cheap GKE Solution by using the instructions in the GitHub repo and the provided Terraform configuration. It’s as easy as running terraform init and terraform apply after setting your Google Project ID.

Cost Comparison for the Cheap GKE Solution

By leveraging steep discounts on Google Cloud, one can achieve over 90% cost savings on running one GKE cluster all-inclusive. Here is a cost-comparison table:

Service GKE On Demand Civo Cheap GKE Solution

Cluster Specifications

# of Control Planes 1 1 1
# of Cluster Nodes 3 3 3
# of Cluster Cores 6 6 6
Total Cluster RAM 24 GB 24 GB 24 GB
Storage (All Nodes) 60 GB Non-SSD 45 GB SSD 60 GB Non-SSD
Ingress Traffic  Unlimited 24 TB (Ingress/Egress) Unlimited
Egress Traffic $0.12 per GB $0.085 per GB
Cloud Load Balancer 1 Forwarding Rule 1 Load Balancer 1 Forwarding Rule

Monthly Pricing Info (Rounded to Nearest Dollar)

1 Control Plane $72 Free (Free Tier) $0
3 Cluster Nodes (On-Demand) $165 $48 (Spot VMs) $22
Storage $3 (Included) $0 $3
Cloud Load Balancer $20 $10 (Regional Promo) $0
NAT Gateway $0 N/A $3-4
Cloud Logging (After Free Tier) $20 N/A $0
Total $208-280 (+ egress) $58 $23-24 (+ egress)

As you can see, at $24 per month, the Cheap GKE Solution is less than half the cost of a comparable Civo deployment, provided that you use minimal data egress. However, you should examine the information for Spot VMs on the Compute Engine Pricing page to see how your referred region compares. us-west4 is currently the cheapest region with asia-east2 being slightly more expensive.

Cheap GKE Solution Cost Breakdown

To help understand and predict charges for running the Cheap GKE Solution, here is the cost breakdown per GCP SKU on a daily basis. Data processing charges apply to external service calls from GKE, such as pulling images from Docker Hub. If you pull images frequently, using Artifact Registry is advised to keep NAT Gateway Data Processing charges low.

Google Cloud SKU

Cost Per Day

Spot Preemptible E2 Instance Core running in Las Vegas

$0.35

Spot Preemptible E2 Instance Ram running in Las Vegas

$0.19

Storage PD Capacity in Las Vegas

$0.09

NAT Gateway: Uptime charge in Las Vegas

$0.10

NAT Gateway: Data processing charge in Las Vegas

($0.045 per GB) $0.03

Network Internet Egress from Las Vegas to Americas

($0.085 per GB) $0.01

Total

($23.10/month) $0.77

Benefits of the Cheap GKE Solution

OK, so you can run a genuine GKE cluster at minimal cost with the Cheap GKE Solution. What are some of the things that you can do with this cluster given that it has a nontrivial six core and 24GB of RAM?

  1. Run several microservices and replicate them. Experiment with advanced features of deployments such as anti-affinity rules.
  2. Run build pipelines on the cluster itself. You might consider trying Tekton for this purpose. It would be best to push images to Artifact Registry.
  3. Run a GitOps deployment tool. You might consider ArgoCD to deploy applications and configurations automatically from your Git repositories.
  4. Run an ingress gateway and experiment with API Gateway features. Gloo Edge, a free open source, Envoy-based, Kubernetes-native API gateway is already included in the Cheap GKE Solution.
  5. Run a service mesh. Here are instructions for installing Istio on GKE.
  6. Run a database. Here are instructions for running PostgreSQL on GKE with a regional persistent disk.
  7. Run services for machine learning. Kubeflow might be a good fit for this.

By having a larger cluster with more CPU and RAM, new doors open up to learners and tinkerers on workloads they can feasibly run on their Kubernetes cluster.

Drawbacks of the Cheap GKE Solution

Details on how the Cheap GKE Solution works are heavily documented in the GitHub repo. There are four primary drawbacks that you should remember:

  1. Only one free GKE Control Plane is allowed per GCP account. These are expensive at $72 per month. So, it’s advisable to only run one cluster at a time.
  2. The cluster is composed of three Spot VMs that have no SLAs and are a Beta feature of GKE. It’s possible that two of the three nodes could be replaced at the same time. For development workloads, this isn’t a big deal as the pods will spin up again on the new nodes. In the GitHub repo, there is detailed info on how to make your applications resilient to node replacement scenarios. From my experience, the GKE cluster nodes usually run for several days straight before being replaced.
  3. The Regional Cloud Load Balancer is a Beta Service that will likely incur a cost but is currently on a free promotion. I would expect the cost to eventually be a few dollars per month, but that’s just a guess.
  4. There are egress charges for data on a per GB basis from the get-go. For those simply learning Kubernetes, the cost impact is minimal as shown in the Cost Breakdown.

As I stated previously, the Cheap GKE Solution is primarily for learners and tinkerers of GKE. While the cost savings are great, there are significant drawbacks to keep in mind when operating the cluster.

Cheap GKE Solution Price Scaling

The provided Cheap GKE Solution has a scalable pricing model. You could, for example, run a six node, 24 core, 96GB RAM cluster for about $100 per month. The more nodes that you run, the less likely you will be severely impacted by concurrent node replacements. For a super-savvy startup that is great at building fault-tolerant applications, using the Spot VM nodes is very appealing. You can also combine with non-Spot VM node pools for handling stateful workloads. So, the Cheap GKE Solution may provide some compelling ideas for those under tight budget constraints that are willing to accept the risks.

Conclusion

Give the Cheap GKE Solution a try using the instructions in the GitHub repo. If you let it run for a few days in its own Google Cloud project, it will be easy to examine the cost of running the cluster. Provided that you only have one GKE cluster running, you can expect to have a great Kubernetes cluster for under $1 per day.

The New Stack is a wholly owned subsidiary of Insight Partners, an investor in the following companies mentioned in this article: Docker.