Diese Seite enthält eine Anleitung zum dynamischen Aktualisieren der Knotenlabels und Knotenmarkierungen eines vorhandenen Knotenpools in einem GKE-Standardcluster (Google Kubernetes Engine).
Knoten-Markierungen und Labels befinden sich in den Objektmetadaten von Kubernetes-Knoten. Labels werden verwendet, um Pods für bestimmte Knoten zu planen. Dabei können Markierungen verwendet werden, um Pods voneinander zu trennen.
Mit der Kubernetes Engine API können Sie Aktualisierungen auf den Knotenlabels und Knotenmarkierungen eines vorhandenen GKE-Knotenpools anwenden, ohne den Knotenpool neu erstellen oder laufende Arbeitslasten unterbrechen zu müssen. Die aktualisierte Knotenpoolkonfiguration wird in GKE beibehalten, sodass zukünftige Knotenpools und neue Knotenbereitstellungen im Knotenpool die neue Konfiguration verwenden.
Beschränkungen
Es gibt einige Einschränkungen bei der Verwendung der Kubernetes Engine API zum dynamischen Aktualisieren von Knotenpoolkonfigurationen:
Die Version für den Knotenpool muss mindestens 1.19.7-gke.1500 sein.
Die Version der Steuerungsebene des Clusters muss mindestens 1.23.4-gke.300 sein, um Aktualisierungen auf Knotenlabels oder Knotenmarkierungen auf vorhandene Knotenpools mit aktiviertem Cluster Autoscaler anzuwenden.
Für Cluster mit früheren Versionen können Sie die folgende Problemumgehung verwenden: Autoscaling deaktivieren für den Knotenpool und aktualisieren Sie dann die Knotenlabels und/oder Markierungen. Nachdem Sie die Updates angewendet haben, aktivieren Sie das Autoscaling wieder.
Knotenlabels aktualisieren
Verwenden Sie den folgenden Befehl, um Knotenlabels für einen Knotenpool zu aktualisieren:
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 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/)"]]