Services

Open source

EN

How to create a Managed Kubernetes in 5 minutes with Google GKE

Why create a managed cluster and how to easily set up your lab for testing. (Part 3)

CTO

João Brito

Why use Kubernetes?

In the midst of 2024, it is almost certain that you have already heard of Kubernetes. If you are starting out now, this article is perfect for you! We will guide you through the first steps with Kubernetes in a simple and direct way.

You will learn not only how to set up your own Kubernetes cluster, but also understand the benefits it brings to your projects, as well as important tips to avoid common pitfalls.

This is a series of articles, covering each of the Cloud Providers. So, don't miss any of them on our blog.

What are the benefits of using Kubernetes in your environments?

Scalability: Kubernetes simplifies the scalability of your applications, allowing you to scale them with ease as your demand grows.

Resilience: With Kubernetes, your applications are highly resilient. It automatically detects and replaces failed containers or nodes, keeping your applications running reliably.

Portability: Kubernetes is an open-source platform and can be run in virtually any environment, whether locally, in public, or private clouds. This gives you the flexibility to move your applications between different cloud providers without major modifications.

Automation: With Kubernetes, you can automate application deployment, updating, and scaling tasks, saving time and reducing human error.

Giant Ecosystem: Kubernetes has a vast ecosystem of tools and services, making it easy to integrate with other technologies and accelerating application development.

Brief History

Here are some of the most important moments in the history of Google Kubernetes Engine (GKE):

  • 2015: GKE becomes generally available, offering Kubernetes as a managed service on Google Cloud Platform (GCP).

  • 2016: GKE adds support for Ingress, making it easier to manage incoming traffic to services.

  • 2017: Introduction of regional clusters in GKE, increasing high availability and resilience.

  • 2018: Launch of GKE Autopilot, a managed option that automates Kubernetes operations, allowing developers to focus on applications and not worry about repetitive operations tasks.

  • 2019: Google announces Anthos, a hybrid and multi-cloud platform that includes GKE, allowing the unified running of Kubernetes on-premises and across multiple public clouds.

  • 2021: Introduction of the GKE Gateway Controller, making it easier to configure and manage API gateways for Kubernetes services.

  • 2023: Launch of cost optimization tools in GKE, allowing better financial management and visibility of resources in Kubernetes.

Hands-on

So, this is the time to get this Kubernetes thing up and running.

As this is a very direct-to-the-point article, we will create a cluster using Google's native tool, "gcloud", which could be the simplest alternative to clickops, and I plan to write more about this in the future.

Installing the "gcloud" CLI on Linux (others: here)
curl -O https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-cli-478.0.0-linux-x86_64.tar.gz
tar -xf google-cloud-cli-478.0.0-linux-x86_64.tar.gz
./google-cloud-sdk/install.sh
./google-cloud-sdk/bin/gcloud init
Creating a cluster

To avoid creating a cluster with very large machines from the start, we will use the option “n1-standard-1”:

Before creating the cluster itself, you need to log in with the CLI:

1- Initializing and logging in with the CLI

gcloud init
gcloud auth login

2- Define your GCP project ID:

gcloud projects list
gcloud config set project PROJECT_ID

3- Define the zone where the cluster will be created:

gcloud config set compute/zone us-central1-a

4- Create a minimal cluster with the basic machine n1-standard-1

gcloud container clusters create cluster-basico --num-nodes=1 --zone us-central1-a --machine-type n1-standard-1

Don't forget to delete this test cluster 

gcloud container clusters delete cluster-basico --zone us-central1-a

PS: with a standard Google account, you can sign up for GCP and start your labs with free credits, allowing you to practice a lot!

Banner
Exclusive benefits

Despite being considered the "father" of Kubernetes, GCP remains in third place in the cloud providers race, but this by no means represents that its services have lower quality or fewer features. On the contrary, experience shows us that most new features adopted in Kubernetes are released first for GKE, and its integration is more stable from the start.

A highlight in Kubernetes-related services on Google that I would like to list here is GKE's “AutoPilot” mode. This mode provides you with greater automation from Google, as it will take more "intrusive" actions on the cluster aimed, of course, at stability. However, like any service, it has pros and cons, and the con here is that once a cluster is created in the "Autopilot" option, it cannot be undone—a new cluster will need to be created. Nevertheless, a benefit is that the main cost in cloud providers lies in computational resources, or machines, and this model will take care of resource scaling for you, following your workloads.

Costs

The GKE service alone has an average direct monthly cost of $73, and in addition to this, you must take into account the costs of each node or instances, storage costs, and networking costs among others. Since this can vary widely, you can evaluate it beforehand in the GCP calculator.

There are some rarely mentioned trade-offs regarding cost optimization where resilience and availability can be compromised. Have a cost-reduction mindset, but understand that the service still has its price.

Tips to watch out for
  • Before creating your GKE, create a large VPC, but with subnets large enough for services, pods, and nodes; this will save you future work;

  • As for using spot or preemptive nodes (which lowers costs by up to 70% compared to on-demand), go ahead and use them extensively, but use taints for applications that can be deallocated at any time, as this will happen frequently.

  • In a scenario using spot/preemptive machines, adjust the kube-dns-autoscaler and have at least one on-demand nodepool for critical GKE apps;

  • We do not recommend using cloud logging and cloud monitoring—they come enabled by default if you don't turn them off, and they are expensive and limited;

  • To save on outbound network traffic, prefer single-zone clusters, and all other GCP resources in that same zone;

  • Don't forget to configure a maintenance window compatible with your business, as GCP will interact with your nodes and masters, for example;

  • We do not recommend using the GKE Backup service as it is quite expensive. By using Velero, for example, you will only have storage costs, and this is a widely adopted project;

  • We recommend configuring your cluster with an "external endpoint" but as a "private cluster," and using integration resources with Google Workspace to grant access to those who really can and need to access your GKE;

  • Finally, save money with the “AutoscalingProfile” option set to “optimize-utilization”. It will scale nodes up and down more quickly, avoiding the cost of idle machines for 10 minutes in a highly dynamic elasticity scenario.

Next steps

Simply having a Kubernetes cluster is not enough. Kubernetes covers a wide range of infrastructure, including networking, storage, processing, and more. This results in a massive cognitive load, making it almost impossible to master every necessary detail, especially considering a new version is released every 4 months. Your cloud-native journey with Kubernetes is just beginning, and you will certainly encounter an entire ecosystem of tools, such as monitoring, centralized logging, CI/CD, and, of course, your own applications.

So, don't miss our next content here on the blog, and also follow Kubicast, where you can listen to experiences, cases, and learn a lot about the cloud-native world.

See you next time with a new cloud provider!



Newsletter Getup.

Atualizações sobre Kubernetes e Software Supply Chain Security todos os meses.

Operating Kubernetes in production for more than 13 years. With Quor, this experience extends to software supply chain security as well.