Si vous y êtes invité, cliquez sur Ouvrir pour autoriser Cloud Code à ouvrir la consoleGoogle Cloud .
Dans la console Google Cloud , sélectionnez les options de configuration que vous souhaitez personnaliser, puis cliquez sur Créer.
Une fois le cluster créé, dans Cloud Code, cliquez sur l'icône Actualiser.
Lorsque le nom de votre nouveau cluster apparaît dans la liste, cliquez dessus. Votre nouveau cluster est ajouté à votre kubeconfig et défini comme contexte par défaut.
Conseil:Pour créer un cluster Kubernetes à l'aide de la palette de commandes, lancez la palette de commandes (appuyez sur Ctrl/Cmd+Shift+P ou cliquez sur Affichage > Palette de commandes), puis exécutez la commande Cloud Code: Create GKE cluster (Créer un cluster GKE).
Utiliser un cluster GKE existant
Si vous possédez un cluster GKE standard ou Autopilot, vous pouvez le définir comme cluster actif et l'utiliser avec Cloud Code.
Cliquez sur Cloud Code, puis développez la section Kubernetes.
Cliquez sur AjouterAjouter un cluster au fichier KubeConfig.
Cliquez sur Google Kubernetes Engine.
Cliquez sur le nom de votre cluster. Votre cluster est ajouté à KubeConfig.
Définir un cluster en tant que contexte par défaut
Le cluster actif est le cluster sur lequel votre application est déployée par défaut.
Cliquez sur Cloud Code, puis développez la section Kubernetes.
Effectuez un clic droit sur un cluster, puis cliquez sur Set as Active Cluster (Définir comme cluster actif).
Exécuter une application sur GKE
Pour exécuter ou déboguer une application sur GKE, vous devez définir le dépôt d'images de conteneurs de votre projet.
Une fois que vous avez supprimé un cluster de votre KubeConfig, il n'est plus possible d'effectuer un déploiement sur ce cluster.
Cliquez sur Cloud Code, puis développez la section Kubernetes.
Effectuez un clic droit sur un cluster, puis cliquez sur Remove Context Under Cluster (Supprimer le contexte sous le cluster).
Ouvrir un terminal interactif dans un conteneur
Cliquez sur Cloud Code, puis développez la section Kubernetes.
Développez votre cluster Minikube, développez Pods, puis développez Containers.
Effectuez un clic droit sur un conteneur, puis cliquez sur Get Terminal (Obtenir un terminal).
Ouvrir une adresse IP externe
Cliquez sur Cloud Code, puis développez la section Kubernetes.
Développez votre cluster Minikube, puis développez Services.
Développez External IPs (Adresses IP externes), faites un clic droit sur une adresse IP, puis cliquez sur Open Address (Ouvrir l'adresse).
Cliquez sur Ouvrir.
Créer et ajouter un cluster depuis un autre fournisseur cloud
Si vous utilisez un cluster sur site ou un cluster d'un autre fournisseur tel qu'Azure ou AWS, créez un cluster à l'aide des outils associés et ajoutez-le à votre KubeConfig.
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\u003eCloud Code allows you to create and manage Kubernetes clusters using Google Kubernetes Engine (GKE), including both Standard and Autopilot modes.\u003c/p\u003e\n"],["\u003cp\u003eYou can easily add existing GKE clusters to your KubeConfig in Cloud Code and set a preferred cluster as the default context for deployments.\u003c/p\u003e\n"],["\u003cp\u003eCloud Code provides tools to interact with your Kubernetes environment, such as opening an interactive terminal to a container and accessing external IP addresses.\u003c/p\u003e\n"],["\u003cp\u003eYou are able to remove clusters from the KubeConfig to prevent accidental deployment to them.\u003c/p\u003e\n"],["\u003cp\u003eCloud code also supports integrating on-premises clusters, or clusters from other providers like Azure or AWS.\u003c/p\u003e\n"]]],[],null,["# Create and configure a GKE cluster in Cloud Code for Cloud Shell\n\nWith Cloud Code, you can create a Kubernetes cluster with\nGoogle Kubernetes Engine (GKE).\n| **Note:** For developing and testing an app, create and run on a non-production cluster. For changes that will be rolled out to production, use an [automated CI/CD workflow](/docs/ci-cd).\n\nCreate a GKE cluster and add it to your KubeConfig\n--------------------------------------------------\n\nTo create a cluster:\n\n1. Click **Cloud Code** and then expand the **Kubernetes** section.\n2. Click add **Add a Cluster to the KubeConfig**.\n3. Select **Google Kubernetes Engine** and then select **Yes** to enable the Google Kubernetes Engine API in your project.\n4. Choose **Standard** or **Autopilot** . For more information, see [Comparing Autopilot and Standard modes](/kubernetes-engine/docs/concepts/autopilot-overview#comparison).\n5. If prompted, click **Open** to permit Cloud Code to open the Google Cloud console.\n6. In Google Cloud console, choose any configuration options that you want to customize and then click **Create**.\n7. After the cluster is created, in Cloud Code, click the **Refresh** icon.\n8. After the name of your new cluster appears in the list, click the cluster name. Your new cluster is added to your kubeconfig and set as the default context.\n\n**Tip:** To create a Kubernetes cluster using the command palette, launch the\ncommand palette (press `Ctrl`/`Cmd`+`Shift`+`P` or click **View** \\\u003e\n**Command Palette** ) and then run the **Cloud Code: Create GKE cluster**\ncommand.\n\nWork with an existing GKE cluster\n---------------------------------\n\nIf you have an existing Standard or Autopilot GKE cluster, you\ncan set it as your active cluster and work with it using\nCloud Code.\n\n1. Click **Cloud Code** and then expand the **Kubernetes** section.\n2. Click add **Add a Cluster to the KubeConfig**.\n3. Click **Google Kubernetes Engine**.\n4. Click your cluster name. Your cluster is added to the KubeConfig.\n\nSet a cluster as the default context\n------------------------------------\n\nThe active cluster is the cluster that your application is deployed to by\ndefault.\n\n1. Click **Cloud Code** and then expand the **Kubernetes** section.\n2. Right-click a cluster and then click **Set as Active Cluster**.\n\nRun an application on GKE\n-------------------------\n\nTo run or debug an application on GKE, you'll need to define\nthe container image repository for your project.\n\nTo learn more, see\n[get started with Cloud Code for Kubernetes](/code/docs/shell/get-started-k8s#run_your_application)\n\n\nRemove a cluster from your KubeConfig\n-------------------------------------\n\nAfter you remove a cluster from your KubeConfig, the cluster is not available\nto deploy to.\n\n1. Click **Cloud Code** and then expand the **Kubernetes** section.\n2. Right-click a cluster and then click **Remove Context Under Cluster**.\n\nOpen an interactive terminal to a container\n-------------------------------------------\n\n1. Click **Cloud Code** and then expand the **Kubernetes** section.\n2. Expand your minikube cluster, expand **Pods** , and then expand **Containers**.\n3. Right-click a container and then click **Get Terminal**.\n\nOpen an external IP address\n---------------------------\n\n1. Click **Cloud Code** and then expand the **Kubernetes** section.\n2. Expand your minikube cluster and then expand **Services**.\n3. Expand **External IPs** , right-click an IP address, and then click **Open Address**.\n4. Click **Open**.\n\nCreate and add a cluster from another cloud provider\n----------------------------------------------------\n\nIf you're using an on-premises cluster or a cluster from another provider such\nas Azure or AWS, use the provider's tools to create the cluster and add it to\nyour KubeConfig.\n\nWhat's next\n-----------\n\n- [Organize your cluster access using kubeconfig files](https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/).\n- Learn how to add, delete or switch between your [kubeconfig files in Cloud Code](/code/docs/shell/kubeconfigs).\n- [Develop and debug parts of a microservice application](/code/docs/shell/speed-up-k8s-development#develop_microservices_applications_using_skaffold_configurations) using Skaffold.\n- Use [file sync and hot reloading](/code/docs/shell/speed-up-k8s-development#enable-skaffold-file-sync-and-hot-reloading) to speed up development.\n- [Debug your application in Cloud Code](/code/docs/shell/debug)."]]