Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Cette page explique comment vous authentifier auprès de votre fournisseur d'identité configuré et obtenir un fichier kubeconfig pour votre identité et votre cluster d'utilisateur.
Avant de commencer
Avant de pouvoir vous authentifier auprès de votre fournisseur d'identité et générer un fichier kubeconfig, assurez-vous d'avoir effectué les opérations suivantes :
Installez le plug-in d'authentification, qui est nécessaire pour utiliser un fichier kubeconfig généré :
gdcloudcomponentsinstallgdcloud-k8s-auth-plugin
Se connecter avec le fournisseur d'identité configuré
Connectez-vous avec le fournisseur d'identité configuré :
gdcloudauthlogin
Suivez les instructions pour vous authentifier auprès de votre fournisseur d'identité.
Tenez compte des points suivants lorsque vous utilisez la commande gdcloud auth login :
Il s'authentifie auprès de l'organisation actuelle. Exécutez la commande gdcloud auth login après avoir changé d'organisation.
Il nécessite que le certificat de l'autorité de certification (CA) pour la configuration de connexion soit installé dans le magasin de certificats de confiance du système. Si le certificat de l'autorité de certification n'est pas installé, utilisez l'option --login-config-cert pour spécifier le chemin d'accès au certificat de l'autorité de certification. Pour en savoir plus, consultez Récupérer les bundles de confiance GDC.
Un navigateur doit être installé sur l'appareil. Utilisez l'option --no-browser pour vous connecter avec un deuxième appareil.
Obtenir un fichier kubeconfig
Après l'authentification auprès du fournisseur d'identité, obtenez un fichier kubeconfig avec l'identité de votre utilisateur :
gdcloudclustersget-credentialsCLUSTER_NAME
Cette commande crée ou met à jour le fichier kubeconfig dans le chemin d'accès par défaut ${HOME}/.kube/config avec l'utilisateur et le cluster authentifiés.
Tenez compte des points suivants lorsque vous générez ou mettez à jour votre fichier kubeconfig :
Spécifiez le chemin d'accès souhaité dans le chemin d'environnement KUBECONFIG pour l'enregistrer dans un autre chemin d'accès.
Le fichier kubeconfig est un fichier à longue durée de vie, mais le jeton qui authentifie l'utilisateur est éphémère. Si un fichier kubeconfig cesse de fonctionner, exécutez la commande gdcloud auth
login pour vous authentifier à nouveau.
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/09/04 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Difficile à comprendre","hardToUnderstand","thumb-down"],["Informations ou exemple de code incorrects","incorrectInformationOrSampleCode","thumb-down"],["Il n'y a pas l'information/les exemples dont j'ai besoin","missingTheInformationSamplesINeed","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 2025/09/04 (UTC)."],[[["\u003cp\u003eThis guide explains the process of authenticating with your identity provider and obtaining a kubeconfig file for cluster access.\u003c/p\u003e\n"],["\u003cp\u003eBefore starting, you must run \u003ccode\u003egdcloud init\u003c/code\u003e and install the \u003ccode\u003egdcloud-k8s-auth-plugin\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eUse the \u003ccode\u003egdcloud auth login\u003c/code\u003e command to sign in, considering the need for an installed CA certificate or a browser.\u003c/p\u003e\n"],["\u003cp\u003eAfter authenticating, run \u003ccode\u003egdcloud clusters get-credentials CLUSTER_NAME\u003c/code\u003e to generate or update your kubeconfig file.\u003c/p\u003e\n"],["\u003cp\u003eThe kubeconfig file contains a short-lived token, so you may need to re-run \u003ccode\u003egdcloud auth login\u003c/code\u003e if it expires.\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/gdch/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. For more information, see [Fetch GDC trust bundles](/distributed-cloud/hosted/docs/latest/gdch/platform/pa-user/pki/fetch-trust-bundles).\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\n login` command to authenticate again."]]