Auto-upgrading nodes

This page shows you how to configure node auto-upgrades in Google Kubernetes Engine.

Overview

Node auto-upgrades help you keep the nodes in your cluster up to date with the cluster master version when your master is updated on your behalf. When you create a new cluster or node pool with Google Cloud Console or the gcloud command, node auto-upgrade is enabled by default.

You can learn more about cluster and node upgrades.

Node auto-upgrades provide several benefits:

  • Lower management overhead: You don't have to manually track and update your nodes when the master is upgraded on your behalf.
  • Better security: Sometimes new binaries are released to fix a security issue. With auto-upgrades, GKE automatically ensures that security updates are applied and kept up to date.
  • Ease of use: Provides a simple way to keep your nodes up to date with the latest Kubernetes features.

Node pools with auto-upgrades enabled are automatically scheduled for upgrades soon after a cluster's masters are upgraded. When the upgrade is performed, nodes are drained and re-created to match the current cluster master version. Modifications on the boot disk of a node VM do not persist across node re-creations. To preserve modifications across node re-creation, use a DaemonSet.

Node auto-upgrade is not available for Alpha Clusters.

Enabling node auto-upgrades for an existing node pool

When you create a new cluster with Google Cloud Console or the gcloud command, node auto-upgrade is enabled by default.

You can enable node auto-upgrade if it is currently disabled.

gcloud

To enable auto-upgrades for an existing node pool, run the following command:

gcloud container node-pools update [NODE_POOL] --cluster [CLUSTER_NAME] \
    --zone [COMPUTE_ZONE] --enable-autoupgrade

Console

To enable auto-upgrades for an existing node pool, 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. In the Node pools section, click the Advanced edit button for the node pool you want to modify.

  4. Select Enable auto-upgrade.

  5. Click Save to exit the Advanced edit overlay.

  6. Click Save again to modify the cluster.

For more control over when nodes can be auto-upgraded, consider configuring maintenance windows and exclusions.

Disabling node auto-upgrades for an existing node pool

You can disable node auto-upgrade for an existing node pool. If you do so, you are responsible for ensuring that the cluster's nodes run a version compatible the cluster's version.

gcloud

To disable auto-upgrades for an existing node pool, run the following command:

gcloud container node-pools update [NODE_POOL] --cluster [CLUSTER_NAME] \
    --zone [COMPUTE_ZONE] --no-enable-autoupgrade

Console

To disable auto-upgrades for an existing node pool, 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. In the Node pools section, click the Advanced edit button for the node pool you want to modify.

  4. Deselect Enable auto-upgrade.

  5. Click Save to exit the Advanced edit overlay.

  6. Click Save again to modify the cluster.

Creating a cluster or node pool with node auto-upgrades enabled

gcloud

To create a cluster with auto-upgrades enabled for the default node pool, specify the --enable-autoupgrade flag in the gcloud container clusters create command:

gcloud container clusters create [CLUSTER_NAME] --zone [COMPUTE_ZONE] \
    --enable-autoupgrade

To create a node pool with auto-upgrade enabled:

gcloud container node-pools create [NODE_POOL] --cluster [CLUSTER_NAME] \
    --zone [COMPUTE_ZONE] --enable-autoupgrade

Console

Clusters and node pools created with Cloud Console have auto-upgrades enabled by default. Visit Creating a Cluster or the Adding and Managing Node Pools for instructions to create clusters and node pools.

You can disable auto-upgrades for new clusters or node pools. To do so, click Advanced edit, then deselect Enable auto-upgrade while configuring the cluster or node pool.

Changing surge upgrade parameters

Surge Upgrades allow you to change the number of nodes GKE upgrades at one time and the amount of disruption an upgrade makes on your workloads.

The max-surge-upgrade and max-unavailable-upgrade flags are defined for each node pool.

You can change these settings when creating a cluster or node pool.

Creating a cluster with different surge parameters

To create a cluster with different settings for surge upgrades, use the max-surge-upgrade and max-unavailable-upgrade flags.
gcloud beta container clusters create [CLUSTER_NAME] \
  --max-surge-upgrade=[SURGE_NODES] --max-unavailable-upgrade=[UNAVAILABLE_NODES]

Creating a cluster with surge upgrade disabled

To create a cluster without surge upgrades, set the max-surge-upgrade flag to 0.
gcloud beta container clusters create [CLUSTER_NAME] \
  --max-surge-upgrade=0 --max-unavailable-upgrade=1

Creating a node pool with different surge parameters

To create a node pool in an existing cluster with different settings for surge upgrades, use the max-surge-upgrade and max-unavailable-upgrade flags.
gcloud beta container node-pools create [NODE_POOL_NAME] \
  --num-nodes=[NUMBER_NODES] --cluster=[CLUSTER_NAME] \
  --max-surge-upgrade=[SURGE_NODES] --max-unavailable-upgrade=[UNAVAILABLE_NODES]

Checking if surge upgrades are enabled on a node pool

To see if surge upgrades are enabled on a node pool, use gcloud to describe the cluster's parameters.
gcloud beta container node-pools describe [NODE_POOL_NAME] \
--cluster=[CLUSTER_NAME]

What's next

หน้านี้มีประโยชน์ไหม โปรดแสดงความคิดเห็น

ส่งความคิดเห็นเกี่ยวกับ...