Autenticazione dell'interfaccia a riga di comando gcloud
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Questa pagina descrive in dettaglio come eseguire l'autenticazione con il provider di identità configurato e
ottenere un file kubeconfig per l'identità utente e il cluster.
Prima di iniziare
Prima di poter eseguire l'autenticazione con il tuo provider di identità e generare un file kubeconfig, assicurati di aver completato le seguenti operazioni:
Installa il plug-in di autenticazione, necessario per utilizzare un file kubeconfig generato:
gdcloudcomponentsinstallgdcloud-k8s-auth-plugin
Accedere con il provider di identità configurato
Accedi con il provider di identità configurato:
gdcloudauthlogin
Segui le istruzioni per l'autenticazione con il tuo IdP.
Tieni presente quanto segue quando utilizzi il comando gdcloud auth login:
Esegue l'autenticazione con l'organizzazione attuale. Esegui
il comando gdcloud auth login dopo aver cambiato organizzazione.
Richiede che il certificato dell'autorità di certificazione (CA)
per la configurazione di accesso sia installato nell'archivio dei certificati attendibili
del sistema. Se il certificato CA non è installato, utilizza
il flag --login-config-cert per specificare il percorso in cui trovare il certificato CA.
Richiede la presenza di un browser sul dispositivo. Utilizza il flag
--no-browser per accedere con un secondo dispositivo.
Recuperare un file kubeconfig
Dopo l'autenticazione con il provider di identità, ottieni un file kubeconfig con
la tua identità utente:
gdcloudclustersget-credentialsCLUSTER_NAME
In questo modo viene creato o aggiornato il file kubeconfig nel percorso predefinito
${HOME}/.kube/config con l'utente e il cluster autenticati.
Tieni presente quanto segue quando generi o aggiorni il file kubeconfig:
Specifica il percorso desiderato nel percorso dell'ambiente KUBECONFIG per salvarlo in
un percorso diverso.
Il file kubeconfig è un file di lunga durata, ma il token che autentica l'utente è di breve durata. Se un file kubeconfig smette di funzionare, esegui il comando
gdcloud auth login per eseguire nuovamente l'autenticazione.
[[["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-09-04 UTC."],[[["\u003cp\u003e\u003ccode\u003egdcloud auth login\u003c/code\u003e authenticates your user with the configured identity provider for your current organization.\u003c/p\u003e\n"],["\u003cp\u003eAfter authentication, use \u003ccode\u003egdcloud clusters get-credentials\u003c/code\u003e to generate or update a kubeconfig file for the cluster.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003egdcloud init\u003c/code\u003e command must be executed before attempting to authenticate with \u003ccode\u003egdcloud auth login\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe kubeconfig file's token is short-lived, requiring re-authentication with \u003ccode\u003egdcloud auth login\u003c/code\u003e if it expires.\u003c/p\u003e\n"],["\u003cp\u003eThe system's trusted certificates store must contain the certificate authority (CA) for the login config, or utilize the \u003ccode\u003e--login-config-cert\u003c/code\u003e flag.\u003c/p\u003e\n"]]],[],null,["# The gdcloud CLI authentication\n\nThis page details how to authenticate with your configured identity provider and\nget a kubeconfig file for your user identity and cluster.\n\nBefore you begin\n----------------\n\nBefore you can authenticate with your identity provider and generate a\nkubeconfig file, ensure you have completed the following:\n\n- Run the `gdcloud init` command. For more information, see the\n [Initialize gdcloud CLI default configuration](/distributed-cloud/hosted/docs/latest/appliance/resources/gdcloud-install#init-default-config)\n section.\n\n- Install the authentication plugin, which is required to use a generated\n kubeconfig file:\n\n gdcloud components install gdcloud-k8s-auth-plugin\n\nSign in with configured identity provider\n-----------------------------------------\n\nSign in with the configured identity provider: \n\n gdcloud auth login\n\nFollow the instructions to authenticate with your identity provider.\n\nConsider the following when using the `gdcloud auth login` command:\n\n- It authenticates with the current organization. Run the `gdcloud auth login` command after switching organizations.\n- It requires that the certificate authority (CA) certificate for the login config is installed in the system's trusted certificates store. If the CA certificate is not installed, use the `--login-config-cert` flag to specify the path to find the CA certificate.\n- It requires a browser to exist on the device. Use the `--no-browser` flag to log in with a second device.\n\nGet a kubeconfig file\n---------------------\n\nAfter authenticating with the identity provider, get a `kubeconfig` file with\nyour user identity: \n\n gdcloud clusters get-credentials \u003cvar translate=\"no\"\u003eCLUSTER_NAME\u003c/var\u003e\n\nThis creates or updates the kubeconfig file in the default path\n`${HOME}/.kube/config` with the authenticated user and cluster.\n\nConsider the following when generating or updating your kubeconfig file:\n\n- Specify the desired path in the `KUBECONFIG` environment path to save it to a different path.\n- The kubeconfig is a long-lived file, however the token authenticating the user is short-lived. If a kubeconfig file stops working, run the `gdcloud auth login` command to authenticate again."]]