Das in dieser Dokumentation beschriebene Produkt Anthos-Cluster in AWS (vorherige Generation) befindet sich jetzt im Wartungsmodus. Alle neuen Installationen müssen Anthos-Cluster in AWS der aktuellen Generation verwenden.
Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Wenn Sie einen externen Load-Balancer mit GKE on AWS einrichten möchten, müssen Sie Ihre VPC und das öffentliche Subnetz mit Ihrer Cluster-ID taggen. Wenn Sie Ihre VPC und Ihr Subnetz bereits getaggt haben, fahren Sie mit Eingehenden Traffic aktivieren fort.
Hinweis
Bevor Sie GKE on AWS verwenden, müssen die folgenden Bedingungen erfüllt sein:
GKE on AWS erfordert Tags in Subnetzen, die Load-Balancer-Endpunkte enthalten. GKE on AWS taggt automatisch alle im Feld spec.Networking.ServiceLoadBalancerSubnetIDs der AWSCluster-Ressource angegebenen Subnetze.
Wenn Sie Ihrem Nutzercluster weitere Subnetze hinzufügen oder Tags auf vorhandene Subnetze anwenden möchten, führen Sie die folgenden Schritte aus:
Verwenden Sie anthos-gke im Verzeichnis anthos-aws, um den Kontext zu Ihrem Verwaltungsdienst zu wechseln.
cd anthos-aws
anthos-gke aws management get-credentials
Rufen Sie die ID der AWS-VPC des Clusters mit kubectl ab und speichern Sie sie als Variable.
Die Ausgabe ist ein Objekt, das Ihre Subnetz-ID enthält. Sie ähnelt subnet-1234abcdefg. Sie können die Variable mit echo prüfen:
echo $SUBNET_ID
Die Antwort enthält Ihre Subnetz-ID.
subnet-012345678abcdef
Mehrere Subnetze
Wenn Sie mehrere Subnetze für Ihre AWSNodePools nutzen, z. B. wenn Sie mehrere Verfügbarkeitszonen verwenden, müssen Sie Ihre Subnetz-IDs einzeln taggen.
Rufen Sie die Liste der Subnetz-IDs mit aws ec2 describe-subnets ab.
Führen Sie den folgenden Befehl aus, um eine Liste aller öffentlichen Subnetze abzurufen:
Ersetzen Sie subnet-ids durch die durch Leerzeichen getrennte Liste der Subnetz-IDs. Beispiel: subnet-012345678abcdef subnet-abcdef123456789 subnet-123456789abcdef
[[["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-22 (UTC)."],[],[],null,["# Preparing AWS networking\n\nTo set up an externally facing load balancer with GKE on AWS,\nyou need to tag your VPC and public subnet with your cluster ID. If you\nhave already tagged your VPC and subnet, skip to\n[Enabling Ingress](/kubernetes-engine/multi-cloud/docs/aws/previous-generation/how-to/ingress).\n\nBefore you begin\n----------------\n\n\nBefore you start using GKE on AWS, make sure you have performed the following tasks:\n\n- Complete the [Prerequisites](/kubernetes-engine/multi-cloud/docs/aws/previous-generation/how-to/prerequisites).\n\n\u003c!-- --\u003e\n\n- Install a [management service](/kubernetes-engine/multi-cloud/docs/aws/previous-generation/how-to/installing-management).\n- Create a [user cluster](/kubernetes-engine/multi-cloud/docs/aws/previous-generation/how-to/creating-user-cluster).\n\nGKE on AWS requires tags on subnets that contain load balancer\nendpoints. GKE on AWS automatically tags all subnets specified in the\n[`spec.Networking.ServiceLoadBalancerSubnetIDs`](/kubernetes-engine/multi-cloud/docs/aws/previous-generation/reference/awscluster#specnetworking)\nfield of the `AWSCluster` resource.\n\nIf you would like to add additional subnets to your user cluster, or if you need\nto re-apply tags to existing subnets, perform the following steps.\n\n1. From your `anthos-aws` directory, use\n `anthos-gke` to switch context to your management service.\n\n ```sh\n cd anthos-aws\n anthos-gke aws management get-credentials\n ```\n | **Note:** `anthos-gke` uses the credentials you specified when you ran `aws configure`.\n\n \u003cbr /\u003e\n\n2. Get the ID of your cluster's AWS VPC with `kubectl` and store it as a\n variable.\n\n export VPC_ID=$(\\\n env HTTPS_PROXY=http://localhost:8118 \\\n kubectl get awscluster cluster-0 -o jsonpath='{.spec.networking.vpcID}')\n\n3. Check the variables content with `echo`. The output\n resembles `vpc-12345678abcdef0`.\n\n echo $VPC_ID\n\n4. Save your cluster ID into an environment variable.\n\n export CLUSTER_ID=$(\\\n env HTTPS_PROXY=http://localhost:8118 \\\n kubectl get awscluster cluster-0 -o jsonpath='{.status.clusterID}')\n\n You can check the variable with `echo`: \n\n echo $CLUSTER_ID\n\n The response includes your cluster ID. \n\n gke-12345678\n\n5. If you installed GKE on AWS into a dedicated VPC, you can use\n the `aws` command-line tool to retrieve the subnet ID.\n\n Select from the following options:\n - Public, if you want to expose Services on your public subnet.\n - Private, if you want to expose Services on your private subnet.\n - Multiple subnets, if you want to expose Services on multiple subnets.\n\n ### Public\n\n export SUBNET_ID=$(aws ec2 describe-subnets \\\n --filters \"Name=vpc-id,Values=$VPC_ID\" \"Name=tag:Name,Values=*public*\" \\\n --query \"Subnets[*].SubnetId\" \\\n --output text)\n\n The output is an object that contains your subnet ID. It resembles\n `subnet-1234abcdefg`. You can check the variable with `echo`: \n\n echo $SUBNET_ID\n\n The response includes your subnet ID. \n\n subnet-012345678abcdef\n\n ### Private\n\n export SUBNET_ID=$(aws ec2 describe-subnets \\\n --filters \"Name=vpc-id,Values=$VPC_ID\" \"Name=tag:Name,Values=*private*\" \\\n --query \"Subnets[*].SubnetId\" \\\n --output text)\n\n The output is an object that contains your subnet ID. It resembles\n `subnet-1234abcdefg`. You can check the variable with `echo`: \n\n echo $SUBNET_ID\n\n The response includes your subnet ID. \n\n subnet-012345678abcdef\n\n ### Multiple subnets\n\n If you are using multiple subnets for your AWSNodePools\n (for example, if you use multiple availability zones), you need to\n tag your subnet IDs individually.\n | **Note:** The following commands assume your subnets have `public` or `private` in their name. If your subnets do not include this text, change the parameters of the `--filters` flag. See [Using filtering](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Filtering.html) for more information.\n\n Retrieve your list of subnet IDs with `aws ec2 describe-subnets`.\n\n To get a list of all public subnets, run the following command: \n\n aws ec2 describe-subnets \\\n --filters \"Name=vpc-id,Values=$VPC_ID\" \"Name=tag:Name,Values=*public*\" \\\n --query \"Subnets[*].SubnetId\" \\\n --output text\n\n To get a list of all private subnets, run the following command: \n\n aws ec2 describe-subnets \\\n --filters \"Name=vpc-id,Values=$VPC_ID\" \"Name=tag:Name,Values=*private*\" \\\n --query \"Subnets[*].SubnetId\" \\\n --output text\n\n The response includes your subnet IDs. \n\n subnet-012345678abcdef\n subnet-abcdef123456789\n subnet-123456789abcdef\n\n6. Tag your subnet with your cluster ID. If you have multiple subnets,\n select Multiple subnets.\n\n ### Single subnet\n\n aws ec2 create-tags \\\n --resources $SUBNET_ID \\\n --tags Key=kubernetes.io/cluster/$CLUSTER_ID,Value=shared\n\n ### Multiple subnets\n\n For each of your subnets, run the following command: \n\n aws ec2 create-tags \\\n --resources \u003cvar translate=\"no\"\u003esubnet-ids\u003c/var\u003e \\\n --tags Key=kubernetes.io/cluster/$CLUSTER_ID,Value=shared\n\n Replace \u003cvar translate=\"no\"\u003esubnet-ids\u003c/var\u003e with the list of subnet IDs, separated by\n spaces. For example,\n `subnet-012345678abcdef subnet-abcdef123456789 subnet-123456789abcdef`."]]