This page explains how to create a cluster on Kubernetes Engine.
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 enabled the Kubernetes Engine API. Enable Kubernetes Engine API
- 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
gcloudcommands to the latest version:
gcloud components update
Creating a cluster
You can create a cluster using the
gcloud command-line tool or
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]]
[CLUSTER_NAME] is the name you choose for the cluster. The optional
--zone flag overrides the default
compute/zone property set by
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
--no-enable-basic-authis 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
--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
To create a cluster using GCP Console, perform the following steps:
Visit the Kubernetes Engine menu in GCP Console.
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.
Viewing your clusters
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
To view your clusters, visit the Kubernetes Engine menu in GCP Console.
To see more information about a cluster, select a cluster from the 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
Passing cluster credentials to
When you create a cluster using
gcloud, the cluster's authentication
credentials are added to the local
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
To learn more about clusters, refer to the following documentation:
- Learn about autoscaling your clusters.
- Learn how to set up multi-zone clusters.
- Learn how to create regional clusters.
- Learn how to label your clusters.
- Read about Node Auto-Upgrades.
- Read about Node Auto-Repair.
- Learn about preemptible VMs.
- Learn about using local SSDs.