Il prodotto descritto in questa documentazione, Anthos Clusters on AWS (generazione precedente), è ora in modalità di manutenzione. Tutte le nuove installazioni devono utilizzare l'attuale prodotto di generazione, Cluster Anthos on AWS.
Per connetterti alle risorse GKE su AWS, segui questi passaggi. Seleziona se hai già un VPC AWS (o una connessione diretta al tuo VPC) o se hai creato un VPC dedicato durante la creazione del servizio di gestione.
VPC esistente
Se hai una connessione diretta o VPN a un VPC esistente, ometti la rigaenv HTTP_PROXY=http://localhost:8118 dai comandi in questo argomento.
VPC dedicato
Quando crei un servizio di gestione in una VPC dedicata, GKE su AWS include un host bastion in una subnet pubblica.
Per aprire il tunnel, esegui lo script bastion-tunnel.sh. Il tunnel inoltra
a localhost:8118.
Per aprire un tunnel per l'bastion host, esegui il seguente comando:
./bastion-tunnel.sh-N
I messaggi del tunnel SSH vengono visualizzati in questa finestra. Quando è tutto pronto, chiudi la connessione interrompendo il processo con Ctrl+C o
chiudendo la finestra.
Apri un nuovo terminale e passa alla directory anthos-aws.
cd anthos-aws
Verifica di essere in grado di connetterti al cluster con kubectl.
L'output include l'URL del server dell'API del servizio di gestione.
I comandi nelle sezioni seguenti presuppongono che tu stia utilizzando questo bastion host.
Se non utilizzi l'bastion host, rimuovi le righe contenenti HTTP_PROXY.
Connessione al servizio di gestione con kubectl
Per connetterti al tuo servizio di gestione con lo strumento kubectl, svolgi i seguenti passaggi:
Dalla directory anthos-aws, utilizza
anthos-gke per cambiare contesto e passare al servizio di gestione.
cd anthos-aws
anthos-gke aws management get-credentials
Connessione ai cluster utente con kubectl
Per connetterti ai cluster di utenti con lo strumento kubectl, segui questi passaggi:
Dalla directory anthos-aws, utilizza
anthos-gke per cambiare contesto e passare al cluster di utenti.
cd anthos-aws
env HTTPS_PROXY=http://localhost:8118 \
anthos-gke aws clusters get-credentials CLUSTER_NAME
Sostituisci CLUSTER_NAME con il nome del cluster di utenti.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-07-14 UTC."],[],[],null,["# Connecting to your cluster with kubectl\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\nThe bastion host\n----------------\n\nTo connect to your GKE on AWS resources, perform the following\nsteps. Select if you have an existing AWS VPC (or direct connection to\nyour VPC) or created a dedicated VPC when creating your management service. \n\n### Existing VPC\n\nIf you have a direct or VPN connection to an existing VPC, omit the line\n`env HTTP_PROXY=http://localhost:8118` from commands in this topic.\n\n### Dedicated VPC\n\nWhen you create a management service in a dedicated VPC,\nGKE on AWS includes a\n[bastion](https://en.wikipedia.org/wiki/Bastion_host) host in a\npublic subnet.\n| **Important:** If you restart your terminal session or the SSH connection is lost, you need to re-launch the `bastion-tunnel.sh` script.\n\nTo connect to your management service, perform the following steps:\n\n1. Change to the directory with your GKE on AWS configuration.\n You created this directory when\n [Installing the management service](/kubernetes-engine/multi-cloud/docs/aws/previous-generation/how-to/installing-management).\n\n ```sh\n cd anthos-aws\n ```\n\n \u003cbr /\u003e\n\n2. To open the tunnel, run the `bastion-tunnel.sh` script. The tunnel forwards\n to `localhost:8118`.\n\n To open a tunnel to the bastion host, run the following command: \n\n ./bastion-tunnel.sh -N\n\n Messages from the SSH tunnel appear in this window. When you are ready to\n close the connection, stop the process by using \u003ckbd\u003eControl+C\u003c/kbd\u003e or\n closing the window.\n3. Open a new terminal and change into your `anthos-aws` directory.\n\n ```sh\n cd anthos-aws\n ```\n4. Check that you're able to connect to the cluster with `kubectl`.\n\n env HTTPS_PROXY=http://localhost:8118 \\\n kubectl cluster-info\n\n The output includes the URL for the management service API server.\n\nThe commands in the following sections assume you are using this bastion host.\nIf you are not using the bastion host, remove the lines containing `HTTP_PROXY`.\n\nConnecting to your management service with kubectl\n--------------------------------------------------\n\nTo connect to your management service with the `kubectl` tool, perform the\nfollowing steps:\n\nFrom your `anthos-aws` directory, use\n`anthos-gke` to switch context to your management service.\n\n```sh\ncd anthos-aws\nanthos-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\nConnecting to your user clusters with kubectl\n---------------------------------------------\n\nTo connect to your user clusters with the `kubectl` tool, perform the\nfollowing steps:\n\nFrom your `anthos-aws` directory, use\n`anthos-gke` to switch context to your user cluster.\n\n```sh\ncd anthos-aws\nenv HTTPS_PROXY=http://localhost:8118 \\\n anthos-gke aws clusters get-credentials CLUSTER_NAME\n```\nReplace \u003cvar translate=\"no\"\u003eCLUSTER_NAME\u003c/var\u003e with your user cluster name.\n\n\u003cbr /\u003e"]]