GCP DevOps Project

Sprint 02

Creating GKE cluster

In this guide, we’ll walk through creating your first Google Kubernetes Engine (GKE) cluster on Google Cloud Platform (GCP). You’ll learn how to enable the Kubernetes Engine API, compare Autopilot and Standard modes, configure node pools, networking, security, and inspect your new cluster.

1. Enable the Kubernetes Engine API

  1. Sign in to the GCP Console and search for GKE, then click Kubernetes Engine.
    The image shows the Google Cloud Platform console with a search for "GKE" displaying results related to Kubernetes Engine, including products, documentation, tutorials, and marketplace APIs.

Note

If you’re on a managed learning environment (e.g., KodeKloud), the Kubernetes Engine API is often pre-enabled.

  1. If prompted, click Enable to activate the Kubernetes Engine API.
    The image shows the Google Cloud Platform interface for the Kubernetes Engine API, with options to enable or try the API and details about its features and terms of service.

  2. After enabling, you’ll be redirected to the Kubernetes clusters dashboard.
    The image shows the Google Cloud Console interface for Kubernetes Engine, specifically the Kubernetes clusters section, with options to create, deploy a container, or take a quickstart.

2. Choose Cluster Type

Click Create on the Kubernetes clusters page. You’ll see two modes:

The image shows a Google Cloud Platform interface for creating a Kubernetes cluster, offering options for "Autopilot" and "Standard" cluster management.

Cluster ModeManagement ResponsibilityBest Use Case
AutopilotGCP manages nodes, upgrades, and scalingMinimal ops overhead and quick start
StandardYou manage node pools, upgrades, and autoscalingCustom machine types & security

For full control over node pools and configurations, select Standard, then click Configure.

3. Configure Your Standard Cluster

  1. Name your cluster (e.g., gcp-devops-project).
  2. Choose a Location type:
    • Regional spans multiple zones.
    • Zonal resides in a single zone (we’ll use Zonal here).
      The image shows a Google Cloud Platform interface for creating a Kubernetes cluster, with options for naming, location type, and region selection. It also displays an estimated monthly cost for the cluster.

3.1 Node Pools

A node pool is a set of VM instances with the same configuration. By default, you get one node pool—expand Node pools to adjust settings.
The image shows a Google Cloud Platform interface for creating a Kubernetes cluster, with options for naming, location, and control plane version. It also displays an estimated monthly cost for the cluster.

3.1.1 Select Image Type

Under Nodes, choose your node image: Container-Optimized OS, Ubuntu, or Windows. We’ll keep the default.
The image shows a Google Cloud Platform interface for configuring node settings in a Kubernetes cluster, including options for image type and machine configuration.

3.1.2 Machine Type & Boot Disk

  • Machine type defaults to e2-medium; adjust CPU and memory if needed.
  • Reduce the Boot disk to 16 GB for cost savings.

3.2 Networking

Leave the network defaults. Note that Maximum pods per node is set to 110 by default.
The image shows a Google Cloud Platform interface for creating a Kubernetes cluster, specifically focusing on node networking settings. It includes options for configuring the maximum number of pods per node and pod address ranges, with an estimated monthly cost displayed.

3.3 Security & Metadata

Add Kubernetes labels, taints, or custom GCE instance metadata. Enforce security policies here.
The image shows a Google Cloud Platform interface for creating a Kubernetes cluster, with options for configuring node metadata, Kubernetes labels, node taints, and GCE instance metadata. It also displays an estimated monthly cost for the cluster.

3.4 Autoscaling & Resource Management

Enable Node Pool Autoscaling or the Vertical Pod Autoscaler for dynamic scaling. The balanced policy distributes pods evenly across nodes.
The image shows a Google Cloud Platform interface for creating a Kubernetes cluster, with options for configuring machine type, boot disk, and encryption settings. The estimated monthly cost is displayed as $151.18.

When you’re satisfied with the configuration, click Create. Provisioning takes about 5–10 minutes.
The image shows a Google Cloud Platform (GCP) Kubernetes Engine interface where a cluster named "gcp-devops-project" is being configured, with progress at 30%. It includes details about the cluster's location, version, and automation settings.

Warning

Provisioning GKE clusters incurs charges. Review GKE pricing and delete unused clusters to avoid surprise costs.

4. Inspect Your Cluster

After provisioning completes (~10 minutes), click your cluster name to open the details page:
The image shows a Google Cloud Platform interface for configuring node settings in Kubernetes, including options for image type and machine configuration.

Here you can:

  • Add Node Pool: Create pools with different machine types or sizes.
  • Workloads: View running pods and deployments.
  • Maintenance: Set maintenance windows and policies (avoid “Any time” for production).

Node pools help you segregate workloads by resource requirements—run lightweight services on small VMs and high-memory jobs on larger ones.

5. Cleaning Up

To remove your cluster:

  1. Click Delete on the cluster details page.
  2. Confirm the cluster name.

In managed labs, simply shutting down the environment clears resources.


References

Watch Video

Watch video content

Previous
Kubernetes Refresher