Specifying a node image

This page shows you how to specify a node image for your nodes in Google Kubernetes Engine (GKE).

To learn about how node images work, refer to Node Images.

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

Specifying a node image

You can select the node image you want to use when you create a new cluster, or you can change the node image for an existing cluster.

Creating a new cluster

gcloud

Container-Optimized OS is the default option for a cluster node image. You can specify the Ubuntu node image by including the --image-type option when you use the gcloud container clusters create command.

To create a new cluster with Container-Optimized OS as the node image:

gcloud container clusters create cluster-name

where cluster-name is the name you choose for the cluster.

To create a new cluster with Ubuntu as the node image:

gcloud container clusters create cluster-name --image-type ubuntu

Console

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

    Visit the Google Kubernetes Engine menu

  2. Click the Create cluster button.

  3. Configure your cluster as desired.

  4. From the navigation pane, under Node Pools, click Nodes.

  5. In the Image type drop-down list, select the desired node image.

  6. Click Create.

Upgrading an existing cluster

gcloud

You can upgrade an existing cluster to use the Container-Optimized OS or Ubuntu node images by using the gcloud container clusters upgrade command. You can upgrade all node pools in the cluster, or you can specify specific a node pool using --node-pool.

To upgrade an existing cluster to use the Container-Optimized OS node image:

gcloud container clusters upgrade --image-type cos cluster-name \
    [--node-pool pool-name]

To upgrade an existing cluster to use the Ubuntu node image:

gcloud container clusters upgrade --image-type ubuntu cluster-name \
    [--node-pool pool-name]

Console

  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 Node pools, select the desired node pool. The Node pools details page opens.

  4. In this page, click Edit.

  5. From the Image type section, click Change.

  6. Select the desired node image.

  7. Click Change.

  8. Wait for the nodes to upgrade.

What's next