En esta página, se proporcionan instrucciones sobre cómo actualizar de forma dinámica las etiquetas de nodos y los taints de nodos de un grupo de nodos existente en un clúster Standard de Google Kubernetes Engine (GKE).
Los taints y las etiquetas de nodo se encuentran en los metadatos de objetos de los nodos de Kubernetes. Las etiquetas se usan para programar los Pods en nodos específicos, en los que se pueden usar taints para desviar Pods de los nodos.
Con la API de Kubernetes Engine, puedes aplicar actualizaciones en las etiquetas de nodo y los taints de nodo de un grupo de nodos existente de GKE sin necesidad de recrear el grupo de nodos ni interrumpir las cargas de trabajo en ejecución. La configuración actualizada del grupo de nodos se conserva en GKE, por lo que las futuras actualizaciones del grupo de nodos y los aprovisionamientos de nodos nuevos en el grupo de nodos usarán la configuración nueva.
Limitaciones
Existen algunas limitaciones para usar la API de Kubernetes Engine a fin de actualizar de forma dinámica la configuración del grupo de nodos:
La versión para el grupo de nodos debe ser 1.19.7-gke.1500 o una versión posterior.
La versión del plano de control del clúster debe ser 1.23.4-gke.300 o posterior a fin de aplicar actualizaciones a las etiquetas de nodo o los taints de nodo para los grupos de nodos existentes con el escalador automático de clúster habilitado.
Para los clústeres en versiones anteriores, puedes usar la siguiente solución alternativa: Inhabilita el ajuste de escala automático en el grupo de nodos y, luego, actualiza las etiquetas o los taints del nodo. Después de aplicar las actualizaciones, vuelve a habilitar el ajuste de escala automático.
Actualiza las etiquetas de nodo
A fin de actualizar las etiquetas de nodo para un grupo de nodos, usa el siguiente comando:
[[["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: 2025-04-03 (UTC)"],[],[],null,["# Update node labels and taints for existing node pools\n\n[Standard](/kubernetes-engine/docs/concepts/choose-cluster-mode)\n\n*** ** * ** ***\n\nThis page provides instructions on how to dynamically update the\nnode labels and node taints of an existing node pool in a\nGoogle Kubernetes Engine (GKE) Standard cluster.\n\nYou can also dynamically apply and update [network tags](/vpc/docs/add-remove-network-tags)\nin GKE Autopilot or Standard clusters. For\ninstructions, refer to [Use network tags to apply firewall rules to nodes](/kubernetes-engine/docs/how-to/autopilot-network-tags).\n\nOverview\n--------\n\nNode [taints](https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/)\nand [labels](https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/)\nare in the object metadata of Kubernetes nodes. Labels are used to schedule Pods\non particular nodes, where taints can be used to steer Pods away from them.\n\nUsing the GKE API, you can apply updates on the node\nlabels, and node taints of an existing GKE node pool without\nneeding to recreate the node pool or disrupt running workloads. The updated node\npool configuration is preserved in GKE, so that future node pool\nupgrades and new node provisions in the node pool will use the new configuration.\n| **Warning:** Dynamic configuration changes are limited to these fields: resource manager tags, network tags, node labels and node taints. Any other field changes in the [UpdateNodePool\n| API](/kubernetes-engine/docs/reference/rest/v1/projects.locations.clusters.nodePools/update) will not occur dynamically, and will result in node recreation.\n\nLimitations\n-----------\n\nThere are some limitations for using the GKE API to dynamically\nupdate node pool configurations:\n\n- The version for the node pool must be 1.19.7-gke.1500 or later.\n- The version for the cluster's control plane must be 1.23.4-gke.300 or later to apply updates to node labels or node taints for existing node pools with [cluster autoscaler enabled](/kubernetes-engine/docs/how-to/cluster-autoscaler). For clusters on earlier versions, you can use the following workaround: [Disable autoscaling](/kubernetes-engine/docs/how-to/cluster-autoscaler#disable_autoscaling) on the node pool, and then update the node labels and/or taints. After the updates have been applied, [re-enable autoscaling](/kubernetes-engine/docs/how-to/cluster-autoscaler#enabling_autoscaling_for_an_existing_node_pool).\n\nUpdating node labels\n--------------------\n\nTo update node labels for a node pool, use the following command: \n\n gcloud container node-pools update \u003cvar translate=\"no\"\u003eNODEPOOL_NAME\u003c/var\u003e \\\n --node-labels=\u003cvar translate=\"no\"\u003e[\u003c/var\u003eNODE_LABEL,...] \\\n --cluster=\u003cvar translate=\"no\"\u003eCLUSTER_NAME\u003c/var\u003e\n --location=\u003cvar translate=\"no\"\u003eCONTROL_PLANE_LOCATION\u003c/var\u003e\n [GCLOUD_WIDE_FLAG ...]\n\n| **Warning:** This update overwrites any previous user-specified values.\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eNODEPOOL_NAME\u003c/var\u003e: the name of the node pool to update.\n- \u003cvar translate=\"no\"\u003e[NODE_LABEL,...]\u003c/var\u003e: the desired new node labels (for example, `label1=value1,label2=value2`).\n- \u003cvar translate=\"no\"\u003eCLUSTER_NAME\u003c/var\u003e: the name of the cluster.\n- \u003cvar translate=\"no\"\u003eCONTROL_PLANE_LOCATION\u003c/var\u003e: the Compute Engine [location](/compute/docs/regions-zones#available) of the control plane of your cluster. Provide a region for regional clusters, or a zone for zonal clusters.\n\nUpdating node taints\n--------------------\n\nTo update node taints for a node pool, use the following command: \n\n gcloud container node-pools update \u003cvar translate=\"no\"\u003eNODEPOOL_NAME\u003c/var\u003e \\\n --node-taints=\u003cvar translate=\"no\"\u003e[\u003c/var\u003eNODE_TAINT,...] \\\n --cluster=\u003cvar translate=\"no\"\u003eCLUSTER_NAME\u003c/var\u003e\n --location=\u003cvar translate=\"no\"\u003eCONTROL_PLANE_LOCATION\u003c/var\u003e\n [GCLOUD_WIDE_FLAG ...]\n\n| **Warning:** This update overwrites any previous user-specified values.\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eNODEPOOL_NAME\u003c/var\u003e: the name of the node pool to update.\n- \u003cvar translate=\"no\"\u003e[NODE_TAINT,...]\u003c/var\u003e: the desired new node taints (for example, `key1=val1:NoSchedule,key2=val2:PreferNoSchedule`).\n- \u003cvar translate=\"no\"\u003eCLUSTER_NAME\u003c/var\u003e: the name of the cluster.\n- \u003cvar translate=\"no\"\u003eCONTROL_PLANE_LOCATION\u003c/var\u003e: the Compute Engine [location](/compute/docs/regions-zones#available) of the control plane of your cluster. Provide a region for regional clusters, or a zone for zonal clusters.\n\nWhat's next\n-----------\n\n- Learn about [node taints to control scheduling.](/kubernetes-engine/docs/how-to/node-taints)\n- [Learn about Network tags](/vpc/docs/add-remove-network-tags).\n- [Learn about labels](https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/)"]]