Managing clusters

This page shows you how to manage your clusters in Google Kubernetes Engine. To learn about how clusters work, refer to Cluster Architecture.

Before you begin

Before you start, make sure you have performed the following tasks:

Set up default gcloud settings using one of the following methods:

  • Using gcloud init, if you want to be walked through setting defaults.
  • Using gcloud config, to individually set your project ID, zone, and region.

Using gcloud init

  1. Run gcloud init and follow the directions:

    gcloud init

    If you are using SSH on a remote server, use the --console-only flag to prevent the command from launching a browser:

    gcloud init --console-only
  2. Follow the instructions to authorize gcloud to use your Google Cloud account.
  3. Create a new configuration or select an existing one.
  4. Choose a Google Cloud project.
  5. Choose a default Compute Engine zone.

Using gcloud config

  • Set your default project ID:
    gcloud config set project [PROJECT_ID]
  • If you are working with zonal clusters, set your default compute zone:
    gcloud config set compute/zone [COMPUTE_ZONE]
  • If you are working with regional clusters, set your default compute region:
    gcloud config set compute/region [COMPUTE_REGION]
  • Update gcloud to the latest version:
    gcloud components update

Viewing your clusters

gcloud

To view a specific cluster, run the following command:

gcloud container clusters describe [CLUSTER_NAME]

To view all clusters in your default zone:

gcloud container clusters list

Console

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

Visit the Google Kubernetes Engine menu

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

Setting a default cluster for kubectl

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.

Setting a default cluster for gcloud

gcloud

To set a default cluster for gcloud commands, run the following command:

gcloud config set container/cluster [CLUSTER_NAME]

Adding or removing zones

The following sections explain how to add or remove cluster zones.

Changing zones for zonal clusters

gcloud

To add or remove zones for a zonal cluster, use the gcloud container clusters update command:

gcloud container clusters update [CLUSTER_NAME] \
--zone [COMPUTE_ZONE] \
--node-locations [[COMPUTE_ZONE],[COMPUTE_ZONE],...]

where:

  • [CLUSTER_NAME] is the name you choose for the cluster
  • [COMPUTE_ZONE] is the zone for the cluster control plane
  • [[COMPUTE_ZONE],[COMPUTE_ZONE]...] is all of the desired zones. Include the cluster control plane's zone.

For example, example-cluster runs in us-central1-a. To add two more zones to the cluster, you'd run the following command:

gcloud container clusters update example-cluster \
--zone us-central1-a
--node-locations us-central1-a,us-central1-b,us-central1-c

As another example, example-cluster runs in us-central1-a, us-central1-b and us-central1-c. If you only want the cluster to run in us-central1-a and us-central1-b, you'd run the following command:

gcloud container clusters update example-cluster \
--zone us-central1-a \
--node-locations us-central1-a,us-central1-b

Console

To add or remove zones in an existing cluster, perform the following steps:

  1. Visit the Google Kubernetes Engine menu in Cloud Console.

    Visit the Google Kubernetes Engine menu

  2. Click the cluster's Edit button, which looks like a pencil.

  3. From the Additional zones section, select the desired zones.

  4. Click Save.

Changing zones for regional clusters

Currently, it is only possible to change the zones for existing regional clusters using the gcloud command.

gcloud

To add or remove zones for a regional cluster, use the gcloud container clusters update command with the --region flag:

gcloud container clusters update [CLUSTER_NAME] \
--region [REGION] \
--node-locations [COMPUTE_ZONE,COMPUTE_ZONE,...]

where:

  • [CLUSTER_NAME] is the name of the cluster.
  • [REGION] is the region in which the cluster runs.
  • [[COMPUTE_ZONE],[COMPUTE_ZONE],...] is all of the desired zones.

For example, example-cluster runs in us-central1-a and us-central1-b. To add us-central1-c, you'd run the following command:

gcloud container clusters update example-cluster \
--region us-central1 \
--node-locations us-central1-a,us-central1-b,us-central1-c

As another example, example-cluster runs in us-central1-a, us-central1-b and us-central1-c. If you only want the cluster to run in us-central1-a and us-central1-b, you'd run the following command:

gcloud container clusters update example-cluster \
--region us-central1 \
--node-locations us-central1-a,us-central1-b

What's next