En esta página, verás cómo especificar una imagen de nodo en los clústeres del modo Standard de Google Kubernetes Engine (GKE). Para obtener información sobre cómo funcionan las imágenes de nodo y los tipos de imágenes de nodo disponibles, consulta Imágenes de nodo.
Si deseas usar Google Cloud CLI para esta tarea, instala y, luego, inicializa gcloud CLI. Si ya instalaste gcloud CLI, ejecuta gcloud components update para obtener la versión más reciente.
Especifica una imagen de nodo
Puedes seleccionar la imagen de nodo que desees usar cuando crees un clúster nuevo o puedes modificarla en un clúster existente.
Crea un clúster nuevo
gcloud
Para crear un clúster nuevo con una imagen de nodo específica, ejecuta el siguiente comando:
En el panel de navegación, en Grupos de nodos, haz clic en Nodos.
En la lista desplegable Tipo de imagen, selecciona la imagen de nodo deseada.
Haz clic en Crear.
Terraform
Para crear un clúster nuevo con una imagen de nodo específica con Terraform, consulta
el siguiente ejemplo:
resource "google_container_cluster" "default" {
name = "gke-standard-zonal-node-image"
initial_node_count = 2
node_config {
image_type = "cos_containerd"
}
# Set `deletion_protection` to `true` will ensure that one cannot
# accidentally delete this instance by use of Terraform.
deletion_protection = false
}
GKE usa la estrategia de actualización de nodos y la configuración seleccionadas para actualizar la imagen de un nodo. Si deseas obtener más información sobre cómo elegir la estrategia de actualización de grupos de nodos óptima y la configuración para tu entorno, consulta las estrategias de actualización de grupos de nodos.
gcloud
Puedes actualizar un clúster existente para usar una imagen de nodo específica mediante el comando gcloud container clusters upgrade. Puedes actualizar todos los grupos de nodos en el clúster o puedes especificar un grupo de nodos específico con --node-pool.
Si deseas actualizar un clúster existente para que use una imagen de nodo específica, ejecuta el comando siguiente:
[[["Fácil de comprender","easyToUnderstand","thumb-up"],["Resolvió mi problema","solvedMyProblem","thumb-up"],["Otro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Información o código de muestra incorrectos","incorrectInformationOrSampleCode","thumb-down"],["Faltan la información o los ejemplos que necesito","missingTheInformationSamplesINeed","thumb-down"],["Problema de traducción","translationIssue","thumb-down"],["Otro","otherDown","thumb-down"]],["Última actualización: 2024-11-21 (UTC)"],[],[],null,["# Specify a node image\n\n[Standard](/kubernetes-engine/docs/concepts/choose-cluster-mode)\n\n*** ** * ** ***\n\nThis page shows you how to specify a node image for nodes in\nGoogle Kubernetes Engine (GKE) Standard mode clusters. To learn about how node images work, and the types of node images that are\navailable, see [Node images](/kubernetes-engine/docs/concepts/node-images).\n\nNodes in GKE Autopilot clusters always use the\n[Container-Optimized OS with containerd](/kubernetes-engine/docs/concepts/using-containerd#about_containerd)\n(`cos_containerd`) node image. You can't specify a different node image in\nAutopilot mode.\n\nBefore you begin\n----------------\n\nBefore you start, make sure that you have performed the following tasks:\n\n- Enable the Google Kubernetes Engine API.\n[Enable Google Kubernetes Engine API](https://console.cloud.google.com/flows/enableapi?apiid=container.googleapis.com)\n- If you want to use the Google Cloud CLI for this task, [install](/sdk/docs/install) and then [initialize](/sdk/docs/initializing) the gcloud CLI. If you previously installed the gcloud CLI, get the latest version by running `gcloud components update`. **Note:** For existing gcloud CLI installations, make sure to set the `compute/region` [property](/sdk/docs/properties#setting_properties). If you use primarily zonal clusters, set the `compute/zone` instead. By setting a default location, you can avoid errors in the gcloud CLI like the following: `One of [--zone, --region] must be supplied: Please specify location`. You might need to specify the location in certain commands if the location of your cluster differs from the default that you set.\n\nSpecifying a node image\n-----------------------\n\nYou can select the node image you want to use when you create a new cluster, or\nyou can change the node image for an existing cluster.\n| **Note:** Starting with GKE node version 1.19, the default node image for Linux nodes is the Container-Optimized OS with Containerd (`cos_containerd`) variant instead of the Container-Optimized OS with Docker (`cos`) variant.\n| **Warning:** In GKE version 1.24 and later, Docker-based node image types are not supported. In GKE version 1.23, you also cannot create new node pools with Docker node image types. You must migrate to a containerd node image type. To learn more about this change, see [About the Docker node image deprecation](/kubernetes-engine/docs/deprecations/docker-containerd).\n\n### Creating a new cluster\n\n### gcloud\n\nTo create a new cluster with a specific node image, run the following command: \n\n gcloud container clusters create \u003cvar translate=\"no\"\u003eCLUSTER_NAME\u003c/var\u003e --image-type \u003cvar translate=\"no\"\u003eIMAGE_TYPE\u003c/var\u003e\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eCLUSTER_NAME\u003c/var\u003e: the name you choose for the cluster.\n- \u003cvar translate=\"no\"\u003eIMAGE_TYPE\u003c/var\u003e: the name of your [node image type](/kubernetes-engine/docs/concepts/node-images#available_node_images).\n\n### Console\n\n1.\n\n\n In the Google Cloud console, go to the **Create a Kubernetes cluster** page.\n\n [Go to Create a Kubernetes cluster](https://console.cloud.google.com/kubernetes/add)\n\n \u003cbr /\u003e\n\n2. Configure your cluster as desired.\n\n3. From the navigation pane, under **Node Pools** , click **Nodes**.\n\n4. In the **Image type** drop-down list, select the desired [node image](/kubernetes-engine/docs/concepts/node-images).\n\n5. Click **Create**.\n\n### Terraform\n\nTo create a new cluster with a specific node image using Terraform, refer\nto the following example: \n\n resource \"google_container_cluster\" \"default\" {\n name = \"gke-standard-zonal-node-image\"\n initial_node_count = 2\n\n node_config {\n image_type = \"cos_containerd\"\n }\n }\n\nTo learn more about using Terraform, see\n[Terraform support for GKE](/kubernetes-engine/docs/resources/use-terraform-gke).\n\n### Upgrading an existing cluster\n\n| **Warning:** In GKE version 1.24 and later, Docker-based node image types are not supported. In GKE version 1.23, you also cannot create new node pools with Docker node image types. You must migrate to a containerd node image type. To learn more about this change, see [About the Docker node image deprecation](/kubernetes-engine/docs/deprecations/docker-containerd).\n\nThis change requires recreating the nodes, which can cause disruption to your\nrunning workloads. For details about this specific change, find the\ncorresponding row in the [manual changes that recreate the nodes using a node\nupgrade strategy without respecting maintenance\npolicies](/kubernetes-engine/docs/concepts/managing-clusters#manual-changes-strategy-but-no-respect-policies)\ntable. To learn more about node updates, see [Planning for node update\ndisruptions](/kubernetes-engine/docs/concepts/managing-clusters#plan-node-disruption).\n| **Caution:** GKE immediately begins recreating the nodes for this change using the node upgrade strategy, regardless of active maintenance policies. GKE depends on [resource\n| availability](/kubernetes-engine/docs/how-to/node-upgrades-quota) for the change. Disabling node auto-upgrades [doesn't prevent this\nchange](/kubernetes-engine/docs/how-to/node-auto-upgrades#disable-only-versions). Ensure that your workloads running on the nodes are prepared for disruption before you initiate this change. \n\n### gcloud\n\nYou can upgrade an existing cluster to use a specific node image by using\nthe `gcloud container clusters upgrade` command. You can upgrade all node\npools in the cluster, or you can specify specific a node pool using\n`--node-pool`.\n\nTo upgrade an existing cluster to use a specific node image, run the\nfollowing command: \n\n gcloud container clusters upgrade \u003cvar translate=\"no\"\u003eCLUSTER_NAME\u003c/var\u003e --image-type \u003cvar translate=\"no\"\u003eIMAGE_TYPE\u003c/var\u003e \\\n [--node-pool \u003cvar translate=\"no\"\u003ePOOL_NAME\u003c/var\u003e]\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eCLUSTER_NAME\u003c/var\u003e: the name of your existing cluster.\n- \u003cvar translate=\"no\"\u003ePOOL_NAME\u003c/var\u003e: the name of the node pool you want to update.\n- \u003cvar translate=\"no\"\u003eIMAGE_TYPE\u003c/var\u003e: the name of your [node image type](/kubernetes-engine/docs/concepts/node-images#available_node_images).\n\n### Console\n\n1. Go to the **Google Kubernetes Engine** page in the Google Cloud console.\n\n [Go to Google Kubernetes Engine](https://console.cloud.google.com/kubernetes/list)\n2. In the cluster list, click the name of the cluster you want to modify.\n\n3. Click the **Nodes** tab.\n\n4. Under **Node Pools**, click the name of the node pool you want to upgrade.\n\n5. On the **Node pool details** page, click *edit* **Edit**.\n\n6. Under **Node version** , click **Change**.\n\n7. Select the desired [node version](/kubernetes-engine/versioning#versioning) and click **Change** to start the upgrade.\n\nWhat's next\n-----------\n\n- [Learn more about node images](/kubernetes-engine/docs/concepts/node-images).\n- [Learn more about node pools](/kubernetes-engine/docs/concepts/node-pools)."]]