Creating a Cluster

This page explains how to create a cluster on Kubernetes Engine.

Overview

When you create a cluster, you specify the number and type of node instances to create in the cluster. The node instances initially created in a cluster become the cluster's default node pool.

When you create a cluster, Kubernetes Engine creates a cluster control plane and nodes of the number and type you specify. Kubernetes Engine creates a firewall and network routes for the nodes, so the nodes can communicate with one another.

Before you begin

To prepare for this task, perform the following steps:

  • Ensure that you have installed the Cloud SDK.
  • Set your default project ID:
    gcloud config set project [PROJECT_ID]
  • Set your default compute zone:
    gcloud config set compute/zone [COMPUTE_ZONE]
  • Update all gcloud commands to the latest version:
    gcloud components update

Creating a cluster

You can create a cluster using the gcloud command-line tool or GCP Console.

Console

To create a cluster using GCP Console, perform the following steps:

  1. Visit the Kubernetes Engine menu in GCP Console.

    Visit the Kubernetes Engine menu

  2. Click Create cluster. The following fields are required:

    • Name: The name you choose for the cluster. It must be unique within the project and the zone.
    • Zone: Compute Engine compute zone in which to create the cluster.
    • Cluster size: The number of nodes to create in the cluster. You must have available resource quota for the nodes and their resources (such as firewall routes).
    • Machine type: Compute Engine machine type to use for the instances. Each machine type is billed differently. The default machine type is n1-standard-1. For pricing information, refer to the price sheet.
  3. Click Create.

gcloud

To create a cluster with the gcloud command-line tool, use the gcloud container clusters command:

gcloud container clusters create [CLUSTER_NAME] [--zone [COMPUTE_ZONE]]

where [CLUSTER_NAME] is the name you choose for the cluster. The optional --zone flag overrides the default compute/zone property set by gcloud config set compute/zone.

Below are some optional flags that you can specify:

  • --additional-zones: The set of additional compute zones in which the cluster's node footprint should be replicated. All zones must be in the same region as the cluster's primary zone. The same node footprint is replicated in all zones, so a cluster with four nodes and two additional zones would have 12 nodes total (four in primary zone and four in each additional zone).
  • --cluster-version: The Kubernetes version to use for the control plane and nodes. Defaults to server-specified.
  • --enable-basic-auth: Enable basic (username/password) authentication for the cluster. This flag is an alias for --username=admin. --no-enable-basic-auth is an alias for --username="", which creates the cluster without basic HTTP authentication.
  • --image-type: The base node image that nodes in the cluster runs on. To see the default image type and the list of available image types, run gcloud container get-server-config.
  • --machine-type: Compute Engine machine type to use for nodes in the cluster. If omitted, the default machine type is n1-standard-1.
  • --num-nodes: The number of nodes to create in the cluster. You must have available resource quota for the nodes and their resources (such as firewall routes).

For the full list of optional flags, refer to the gcloud container clusters create documentation.

Viewing your clusters

Console

To view your clusters, visit the Kubernetes Engine menu in GCP Console.

Visit the Kubernetes Engine menu

To see more information about a cluster, select a cluster from the list.

gcloud

To view a specific cluster, run the following command:

gcloud container clusters describe [CLUSTER_NAME]

To view all clusters in a specific zone:

gcloud container clusters list

Setting the default cluster

If you have multiple clusters, you can set a default cluster for the kubectl command-line tool.

To learn more, refer to Setting a default cluster for kubectl commands.

Passing cluster credentials to kubectl

When you create a cluster using gcloud, the cluster's authentication credentials are added to the local kubeconfig file:

Creating cluster...done.
kubeconfig entry generated for cluster.

If you created a cluster using GCP Console or using gcloud on a different machine, you need to make the cluster's credentials available to kubectl in your current environment.

To learn more, refer to Generating a kubeconfig entry.

What's next

To learn more about clusters, refer to the following documentation:

Cluster features

Node features

Administering clusters

Cluster concepts

Was this page helpful? Let us know how we did:

Send feedback about...

Kubernetes Engine