Containers & Kubernetes

GKE best practices: Create a cost-optimized cluster in just a few clicks


No one wants to spend more on compute infrastructure than they have to—and that includes your Kubernetes platform. With Google Kubernetes Engine (GKE), the easiest way to stand up a cost-optimized cluster is to choose GKE Autopilot. However, some organizations may not be ready to use Autopilot yet. For them, there’s our guide, Best practices for running cost-optimized Kubernetes applications on GKE, which details GKE’s core cost-optimization capabilities and organizational considerations for getting them implemented. And now, to make it much easier to apply those learnings, we’re introducing the built-in GKE cost-optimized cluster setup guide.

With the new cluster setup guide, you can set up a cost-optimized Kubernetes cluster in a couple of clicks, and effortlessly learn about GKE’s top cost optimization capabilities without ever leaving your cluster creation workflow. This setup guide is a great resource for:

  • The user that only wants to provide the size of the cluster, and let Google guide them through setting up the most cost optimal cluster 

  • The seasoned GKE operator who wants  a quick walkthrough of GKE’s latest cost-optimization features

  • The developer who wants an environment with a good balance between cost and performance

  • Or, those just getting started on their GKE journey.

Behind the scenes, the setup guide suggests intelligent defaults for configuring your cluster. This will simplify the following decisions and bring your GKE Standard setup closer to the best practices implemented in GKE Autopilot.

Using the GKE cost-optimized setup guide

You can access the setup guide right out of the GKE cluster creation option in the Cloud Console.

1 cost-optimized.jpg

All you have to do is:

  • Name your cluster, select your region and preferred release channel

  • Specify your desired cluster-size range, in number of CPUs

  • Point to your GKE usage metering data export location

...and GKE does the rest for you. While you advance through the guide, we walk you through the exact settings of the cluster as it’s being configured. If all this sounds simple, it’s because it is!

What’s going on under the hood?

The setup guide makes it easy to set up a cost-optimized cluster, but behind the scenes, there’s a lot going on..

The first step to a cost-optimal cluster is the cluster’s size. In this step, we enable node auto-provisioning. All you have to do is enter the minimum and maximum number of CPUs, and we’ll suggest the right memory ratio for your cluster.

2 cost-optimized.jpg

The next step lets you verify the machine type. This solves a very common question: “What machine size should I use for my default node pool?”

3 cost-optimized.jpg

Beyond your workloads, GKE runs components such as agents and proxies on a cluster’s nodes, so it’s important to strike the right balance between VM size for the best balance between cost and  performance. We achieve this by proposing a machine type and size based on the minimum and maximum size of the cluster that was specified in the previous step. Again—you retain full control over your final choice. By default, we select the cost-optimized general purpose machine type.

The next step takes us to the advanced settings, where we preconfigure a number of important settings for you. We don’t expect you to change any of these (even though you can).

4 cost-optimized.jpg

For instance, we set the cluster autoscaling profile to optimize utilization—this optimizes for utilization over keeping spare resources in the cluster. When selected, the cluster autoscaler scales down the cluster more aggressively: it can remove more nodes, and remove nodes faster. 

Additionally, we enable cluster autoscaler just for the default pool, allowing you to keep the default node pool within the specified boundaries. 

We also activate vertical pod autoscaling by default, making sure the cluster is ready to provide recommendations for your workload if needed. This setting is non-disruptive to your cluster or workloads.

Finally, you can’t optimize what you don’t measure. Observing and measuring your cluster usage is a core way to understand and improve your cluster utilization at any point in its life cycle. To help with that, we activate GKE usage metering by default. All you have to do is choose the BigQuery dataset to export the data to. As with everything in the setup guide, you can skip this step.

5 cost-optimized.jpg

That’s it—your new, cost optimized cluster is ready to go! 

Pro tip - select the “Make changes” option to apply the setup guide settings to the main cluster creation flow, and continue editing your cluster!

6 cost-optimized.jpg

While your cluster is spinning up, take some time and check the next steps you would want to take beyond infrastructure optimization.

7 cost-optimized.jpg

Our best practices guide will give you more insights on how to optimize beyond infrastructure, and how to approach workload-level optimization for when your cluster is up and running. 

You should also check out our collection of advanced GKE cost optimization materials and video series. Share them with your team and become a true GKE cost optimization hero!