Produk yang dijelaskan dalam dokumentasi ini, Cluster Anthos di AWS (generasi sebelumnya), kini berada dalam mode pemeliharaan. Semua penginstalan baru harus menggunakan produk generasi saat ini, cluster Anthos di AWS.
Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Untuk menyiapkan load balancer yang menghadap eksternal dengan GKE di AWS,
Anda harus memberi tag pada VPC dan subnet publik dengan ID cluster Anda. Jika Anda
telah memberi tag pada VPC dan subnet, lanjutkan ke
Mengaktifkan Ingress.
Sebelum memulai
Sebelum Anda mulai menggunakan GKE di AWS, pastikan Anda telah melakukan tugas berikut:
GKE on AWS memerlukan tag pada subnet yang berisi endpoint load balancer. GKE di AWS secara otomatis memberi tag pada semua subnet yang ditentukan di kolom
spec.Networking.ServiceLoadBalancerSubnetIDs
resource AWSCluster.
Jika Anda ingin menambahkan subnet tambahan ke cluster pengguna, atau jika Anda perlu menerapkan kembali tag ke subnet yang ada, lakukan langkah-langkah berikut.
Dari direktori anthos-aws, gunakan
anthos-gke untuk mengganti konteks ke layanan pengelolaan Anda.
cd anthos-aws
anthos-gke aws management get-credentials
Dapatkan ID VPC AWS cluster Anda dengan kubectl dan simpan sebagai variabel.
Output-nya adalah objek yang berisi ID subnet Anda. Mirip dengan
subnet-1234abcdefg. Anda dapat memeriksa variabel dengan echo:
echo $SUBNET_ID
Respons mencakup ID subnet Anda.
subnet-012345678abcdef
Beberapa subnet
Jika Anda menggunakan beberapa subnet untuk AWSNodePool (misalnya, jika Anda menggunakan beberapa zona ketersediaan), Anda harus memberi tag pada ID subnet secara terpisah.
Ambil daftar ID subnet Anda dengan aws ec2 describe-subnets.
Untuk mendapatkan daftar semua subnet publik, jalankan perintah berikut:
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 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`."]]