Auf dieser Seite erfahren Sie, wie Sie ein Knoten-Image für Knoten in Clustern im GKE Standard-Modus (Google Kubernetes Engine) angeben. Informationen zur Funktionsweise von Knoten-Images und den verfügbaren Knoten-Image-Arten finden Sie unter Knoten-Images.
Wenn Sie die Google Cloud CLI für diese Aufgabe verwenden möchten, müssen Sie die gcloud CLI installieren und dann initialisieren. Wenn Sie die gcloud CLI bereits installiert haben, rufen Sie die neueste Version mit gcloud components update ab.
Knoten-Image angeben
Sie können das zu verwendende Knoten-Image auswählen, wenn Sie einen neuen Cluster erstellen. Sie haben auch die Möglichkeit, das Knoten-Image eines vorhandenen Clusters zu ändern.
Neuen Cluster erstellen
gcloud
Führen Sie den folgenden Befehl aus, um einen neuen Cluster mit einem bestimmten Knoten-Image zu erstellen:
Klicken Sie im Navigationsbereich unter Knotenpools auf Knoten.
Wählen Sie in der Drop-down-Liste Image-Typ das gewünschte Knoten-Image aus.
Klicken Sie auf Erstellen.
Terraform
Informationen zum Erstellen eines neuen Clusters mit einem bestimmten Knoten-Image mithilfe von Terraform finden Sie im folgenden Beispiel:
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 verwendet die ausgewählte Upgradestrategie und Konfiguration des Knotens, um das Image eines Knotens zu aktualisieren. Weitere Informationen zur Auswahl der optimalen Upgradestrategie und Konfiguration für den Knoten finden Sie unter Upgradestrategien für Knoten.
gcloud
Ein vorhandener Cluster lässt sich mit dem Befehl gcloud container clusters upgrade so aktualisieren, dass ein bestimmtes Knoten-Image verwendet wird. Sie können alle Knotenpools im Cluster aktualisieren oder einen bestimmten Knotenpool mithilfe von --node-pool angeben.
Führen Sie den folgenden Befehl aus, um einen vorhandenen Cluster für die Verwendung eines bestimmten Knoten-Images 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: 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)."]]