Google Kubernetes Engine
This guide demonstrates how to create a GKE cluster using any of the following options:
- The Google Cloud Console (web interface at https://console.cloud.google.com/)
- The gcloud command-line tool
- Terraform
Create a GKE Cluster using The Google Cloud Console
The simplest way to create a GKE cluster is by using the Google Cloud Console, which acts as a web interface for GCP. Use the following steps to create a GKE cluster:
- Go to https://console.cloud.google.com/kubernetes/list
- Click CREATE CLUSTER
- Select a cluster name, and customize any other fields as needed (default options will work)
- Click CREATE
- The cluster creation process typically takes 5-10 minutes
Once the cluster is created:
- Go to https://console.cloud.google.com/kubernetes/list, click the 3 dots to the right of the newly created cluster, and select Connect
- Enable the Kubernetes API if not already enabled
- Copy the command-line access command and run it on a local terminal. This command will configure
kubectl config
to access the newly created cluster.
Create a GKE Cluster using The Gcloud Command-Line Tool
GKE Clusters can also be created using Google's gcloud CLI. The gcloud CLI is included in their SDK, which can be installed by following instructions in Google's SDK installation docs.
GKE clusters are organized within Google Cloud Projects. The project name is used in several spots, so for the sake of simplicity this demo sets a PROJECT_ID variable to the name of the project used.
This can be either an existing project or a new one. To create a new project, run the command below (the project name is set to "hello-kalm" in this example):
In order to create a Kubernetes cluster on GCP billing must be enabled for that project. By default, new projects will not have billing enabled.
Additionally, projects need to specifically enable the Kubernetes Engine API, which can be done using the command below:
With billing and engine API enabled, the following commands will provision a cluster with 4 nodes (modify the zone as needed):
It will take a few minutes to create the cluster. Once complete, configure kubectl to use the new cluster:
Verify the cluster is properly setup and accessible.
Terraform
Alternatively, the GKE Cluster can be created using Terraform. To use Terraform, first:
- Install The gcloud CLI.
- Install Terraform.
- Install kubectl
GKE clusters are organized within Google Cloud Projects. A new project can be created with:
Use the gcloud init
command and select the new (or existing) project (usage details here).
Terraform also requires access to the Application Default Credentials (ADC), which can be granted using the following command:
The Kubernetes Engine API will need to be enabled for the project as well, which can be done using the following command:
Clone the repository below to download Kalm's installation scripts for Terraform.
Open 'terraform.tfvars' in a text editor and specify the ID of the current Google Cloud project. The region can be specified as well.
With these settings configured, create the cluster by using the following commands:
Type yes
to confirm the installation.
The process should take around 5-10 minutes. Once complete, retrieve the name of the newly created cluster.
Configure kubectl to use the new cluster.
- Note - identify the project's zone either on gcloud console or using the CLI by entering:
gcloud info | grep "zone"
Verify the cluster is properly setup and accessible.
Next Step
To install Kalm onto the cluster, see Install Kalm Cloud.