This page shows you how to migrate your Google Kubernetes Engine (GKE) Standard cluster and node pools from Docker to node images that use the containerd container runtime.
Overview
Kubernetes nodes use the container runtime to launch, manage, and stop containers running in Pods. The containerd runtime is an industry-standard container runtime that's supported by GKE.
The containerd runtime provides the layering abstraction that allows for the implementation of a rich set of features like gVisor and Image streaming to extend GKE functionality. The containerd runtime is considered more resource efficient and secure than the Docker runtime.
To migrate your container runtime:
- Identify nodes that use the Docker runtime
- Verify the impact of migration
- Change the node image
Before you begin
Before you start, make sure you have performed the following tasks:
- Enable the Google Kubernetes Engine API. Enable Google Kubernetes Engine API
- If you want to use the Google Cloud CLI for this task,
install and then
initialize the
gcloud CLI. If you previously installed the gcloud CLI, get the latest
version by running
gcloud components update
.
Identify nodes that use the Docker runtime
You can check which nodes use Docker-based node images using the following methods:
- Use a script to iterate over all nodes in all GKE clusters across your Google Cloud project.
- Use the Google Cloud CLI,
kubectl
, or the Google Cloud console to identify node images. - Use deprecation insights and recommendations to identify clusters and nodes in specific zones or regions in a Google Cloud project.
We recommend that you use a script to quickly identify all the nodes that you need to migrate.
Use a script to identify Docker nodes
The following script iterates over every node in every cluster in your available projects and provides you with actionable recommendations, such as:
- Whether node auto-provisioning is configured for Docker images
- Suggested containerd node image equivalents for migration
- Suggested node image versions for migration
- Suggested commands to run to migrate the identified nodes and settings
The script ignores GKE Autopilot clusters, which use the Container-Optimized OS with containerd node image by default.
Run the following script:
Identify node images using Google Cloud
You can check the node images for existing nodes using the Google Cloud CLI,
kubectl
, or the Google Cloud console.
gcloud
Run the following command:
gcloud container node-pools list \
--cluster=CLUSTER_NAME \
--format="table(name,version,config.imageType)"
Replace CLUSTER_NAME
with the name of your cluster.
The output is similar to the following:
NAME NODE_VERSION IMAGE_TYPE
default-pool 1.19.6-gke.600 UBUNTU
Console
Go to the Google Kubernetes Engine page in the Google Cloud console.
In the cluster list, click the name of the cluster you want to verify.
Select the Nodes tab.
In the Node pools section, check the value in the Image type column.
kubectl
Run the following command:
kubectl get nodes -o wide
The output is similar to the following:
# For Docker runtime
NAME STATUS VERSION OS-IMAGE CONTAINER-RUNTIME
gke-node-1 Ready v1.16.15-gke.6000 Container-Optimized OS from Google docker://19.3.1
gke-node-2 Ready v1.16.15-gke.6000 Container-Optimized OS from Google docker://19.3.1
gke-node-3 Ready v1.16.15-gke.6000 Container-Optimized OS from Google docker://19.3.1
The value in the CONTAINER-RUNTIME
column shows the runtime and version.
Identify clusters using deprecation insights and recommendations
GKE detects the usage of some deprecated features and APIs, including Docker-based node images. To learn more, see GKE deprecations.
As part of detecting the usage of deprecations, GKE generates
insights and recommendations
which identify usage of Docker-based node images with the DEPRECATION_K8S_1_24_DOCKERSHIM
insight subtype.
One insight and recommendation pairing identifies a cluster that has nodes that are using Docker-based node images. Each insight and recommendation provides a list of the specific node pools in a cluster that are using Docker-based node images and must be migrated to containerd node images.
To get started, follow the instructions to view deprecation insights and recommendations. For the gcloud CLI commands, use the following flag to just see insights for this deprecation:
--filter="insightSubtype:DEPRECATION_K8S_1_24_DOCKERSHIM"
Once you've identified which cluster's node pools are using Docker-based node images, follow the instructions to change the node image to a containerd node image.
Verify the impact of migrating
Before you migrate your production clusters and node pools to node images that use containerd, we strongly recommend that you test the impact of the migration in a staging environment to minimize the risk of issues.
We recommend that when you migrate the nodes, you do so independently of upgrading the nodes, so that you can isolate variables when verifying the workloads function with the new configuration. Additionally, if you upgrade the node pool to version 1.24 at the same time, you cannot roll back the change as 1.24 does not support Docker nodes and you cannot downgrade minor versions.
Change the node image to a containerd image
If you used the script to identify your Docker nodes, you can use the suggested commands returned by the script to change your node auto-provisioning settings and your node images to the containerd equivalents.
You can also migrate nodes from a Docker image type to a containerd image type by updating the node pool and setting a different image using the gcloud CLI or the Google Cloud console.
GKE uses the selected node upgrade strategy and configuration to migrate a node's image. For this migration, we recommend that you use the blue-green upgrade strategy because if your workloads experience issues with the new node image during the upgrade, you can roll back to the previous environment with the original node image configuration.
gcloud
Run the following command:
gcloud container clusters upgrade CLUSTER_NAME \
--image-type=NODE_IMAGE \
--node-pool=POOL_NAME \
--cluster-version=NODE_VERSION
Replace the following:
NODE_IMAGE
: the node image that you want the nodes to use.POOL_NAME
: the name of the node pool to migrate.NODE_VERSION
: the existing version of the node pool. We recommend setting this flag because otherwise, GKE attempts to upgrade the version of the node pool to the control plane version and update the node image in the same operation. If the control plane is running 1.24, the command fails. If the control plane is running 1.23, the command succeeds, which prevents you from testing the two changes (version upgrade and image update) in isolation.
The output is similar to the following:
NAME NODE_VERSION IMAGE_TYPE
default-pool 1.23.6-gke.600 UBUNTU_CONTAINERD
Console
Go to the Google Kubernetes Engine page in the Google Cloud console.
In the cluster list, click the name of the cluster you want to verify.
Click the Nodes tab.
In the Node pools section, click the name of the node pool that you want to modify.
On the Node pool details page, click
Edit.In the Nodes section, under Image type, click Change.
Select one of the containerd image types.
Click Change.
Roll back to Docker node images
If your nodes were automatically or manually migrated to containerd nodes and you saw an issue with your workloads, perform the following steps to revert to Docker node images:
- Choose the following step depending on the state of the operation:
- If the operation is still in progress, you can cancel and roll back.
- If the operation is complete, see the previous section's steps and select the equivalent Docker image.
- Configure a maintenance exclusion to temporarily prevent GKE from retrying the migration.
- Investigate the root cause of the issue so that you can migrate from Docker and ensure that your cluster is running a supported version of GKE.
- Try again to change the node image to a containerd image. If you remove the maintenance exclusion, GKE will trigger the operation again.
Update Infrastructure as Code (IaC) tool configurations
If you use IaC tools such as Terraform, Ansible, or Pulumi to manage GKE clusters, ensure that you update your configurations to use containerd node images to prevent the tools from reconciling the previously desired state with the new actual state. For example, the GKE Terraform provider supports configurable image types.
Update any configurations so that the tool does not update the node image back to a Docker-based node image after you've migrated to containerd node images.
Change the default node image for node auto-provisioning
If you use node auto-provisioning in your cluster, change the default image type to a containerd node image. Changing the default image type only applies to new auto-provisioned node pools. You must manually change the node image for existing auto-provisioned node pools.
You can change the default node auto-provisioning image type using the gcloud CLI or a configuration file.
gcloud
Run the following command:
gcloud container clusters update CLUSTER_NAME \
--enable-autoprovisioning \
--autoprovisioning-image-type=IMAGE_TYPE
Replace the following:
CLUSTER_NAME
: the name of the cluster to update.IMAGE_TYPE
: the node image type, which can be one of the following:cos_containerd
ubuntu_containerd
File
You can use a YAML configuration file to change the default node image type for node auto-provisioning. When you use a file, you must also specify maximum values for CPU and memory resources.
Save the following YAML file:
resourceLimits: - resourceType: 'cpu' minimum: 4 maximum: 10 - resourceType: 'memory' maximum: 64 autoprovisioningNodePoolDefaults: imageType: 'IMAGE_TYPE'
Replace
IMAGE_TYPE
with the containerd image type.Apply the configuration:
gcloud container clusters update CLUSTER_NAME \ --enable-autoprovisioning \ --autoprovisioning-config-file=FILE_NAME
Replace
FILE_NAME
with the path to the configuration file.
Troubleshooting
For troubleshooting and for known issues with workarounds, refer to Troubleshooting the container runtime.