Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Auf dieser Seite wird erläutert, wie Sie den IMDS-Emulator aktivieren, der den AWS-Instanzmetadatendienst (IMDS) emuliert. Sie können den Emulator als Sidecar ausführen, um die Ausführung älterer Arbeitslasten in GKE on AWS-Knotenpools zu ermöglichen. Wenn Sie ältere Arbeitslasten haben, die die Workload Identity Federation for GKE nicht direkt unterstützen, verwenden Sie diesen Emulator, um auf IMDS-Daten zuzugreifen.
Beschränkungen
Ihr Cluster muss die Kubernetes-Version 1.24 oder höher verwenden.
Der IMDS-Emulatorserver beantwortet nur Anmeldedatenanfragen (API_VERSION/meta-data/iam/security-credentials/). Bei allen anderen Metadatenanfragen wird der Fehler 404 zurückgegeben.
Für eine Sidecar-Bereitstellung muss der Init-Container die NET_ADMIN- und NET_RAW-Sicherheitskontextkapazitäten haben.
Wenn Sie sich nicht sicher sind, ob der Container diese Kontexte hat, wenden Sie sich an Ihr Sicherheitsteam.
Das AWS STS-Token kann eine Stunde lang gültig sein. Das Rollentoken aus den EC2-Metadaten kann 24 Stunden gültig sein. Dies sollte sich nicht auf die Nutzung des Emulators auswirken. Diese Informationen können jedoch bei einer Sicherheitsprüfung erforderlich sein.
Der IMDS-Emulator emuliert nur IMDSv1-Antworten. IMDSv2 wird nicht unterstützt.
Emulator aktivieren
Wenn Sie den IMDS-Emulator aktivieren möchten, fügen Sie den Metadaten für einen Pod ein Label und eine Anmerkung hinzu. Sie können den Emulator auch mit einem Deployment, DaemonSet oder einer anderen Ressource aktivieren, mit der Pods erstellt werden:
Fügen Sie dem Pod das folgende Label und den folgenden Wert hinzu:
Der einzige zulässige Wert für dieses Label ist True. Bei allen anderen Werten (einschließlich true mit einem Kleinbuchstaben t) wird der Emulator deaktiviert.
[[["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-07-31 (UTC)."],[],[],null,["# Enable the IMDS emulator\n\nThis page explains how you can enable the IMDS emulator, which emulates the AWS\ninstance metadata service (IMDS). You can run the\nemulator as a sidecar to enable legacy workloads to run in\nGKE on AWS node pools. If you have legacy workloads that don't\nsupport Workload Identity Federation for GKE directly, use this emulator to access IMDS data.\n\nLimitations\n-----------\n\n- Your cluster must use a Kubernetes version of 1.24 or later.\n- The emulator is not supported in the [previous generation](/kubernetes-engine/multi-cloud/docs/aws/previous-generation) of GKE on AWS.\n- The IMDS emulator server only serves credential requests (`API_VERSION/meta-data/iam/security-credentials/`). All other metadata requests return a 404 error.\n- A sidecar deployment requires the init container to have the `NET_ADMIN` and `NET_RAW` [security context capacities](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/). If you're not sure if the container has these contexts, consult your security team.\n- The AWS STS token can last for one hour. The role token from EC2 metadata can last for 24 hours. This shouldn't affect your usage of the emulator, but you might need to know this information during a security audit.\n- The IMDS emulator only emulates IMDSv1 responses. IMDSv2 is not supported.\n\nEnable the emulator\n-------------------\n\nTo enable the IMDS emulator, add a label and an annotation to metadata for a\nPod. You can also enable the emulator using a Deployment, DaemonSet, or any\nother resource that creates Pods:\n\n1. Add the following label and value to your Pod:\n\n gkemulticloud.googleapis.com/aws-imds-emulator-enabled: \"True\"\n\n The only acceptable value for this label is `True`. All other values\n (including `true` with a lowercase `t`) disable the emulator.\n2. Add the following annotation to your Pod:\n\n gkemulticloud.googleapis.com/aws-imds-emulator-role-arn: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eARN_ROLE\u003c/span\u003e\u003c/var\u003e\n\n Replace \u003cvar translate=\"no\"\u003eARN_ROLE\u003c/var\u003e with an Amazon Resource Name\n (ARN) that specifies the role that you want the resource to have.\n\n### Example\n\nThe following example is a Pod with the IMDS emulator enabled: \n\n apiVersion: v1\n kind: Pod\n metadata:\n name: nginx\n labels:\n gkemulticloud.googleapis.com/aws-imds-emulator-enabled: \"True\"\n annotations:\n gkemulticloud.googleapis.com/aws-imds-emulator-role-arn: \"arn:aws:iam::123456789012:role/my-example-role\"\n spec:\n serviceAccountName: my-sa\n containers:\n - name: nginx\n image: nginx"]]