Déboguer des applications Kubernetes avec Cloud Code pour IntelliJ
Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Cloud Code pour IntelliJ vous permet de déboguer facilement vos applications déployées sur un cluster Kubernetes. Vous pouvez déboguer une application sur un cluster local (Minikube ou Docker Desktop, par exemple), Google Kubernetes Engine ou tout autre fournisseur cloud.
Grâce à l'assistance au débogage proposée par Cloud Code, vous pouvez ignorer les étapes de configuration manuelle, comme la configuration du transfert de port, l'installation d'un backend de débogage ou l'injection correcte d'arguments de débogage spécifiques à un langage. Vous avez seulement besoin d'une application Kubernetes compatible avec Cloud Code et comprenant un fichier de configuration skaffold.yaml.
Le tableau suivant répertorie les langages et les IDE compatibles avec Cloud Code pour le débogage. Le tableau liste également les plug-ins requis, le cas échéant :
Avec Cloud Code, vous pouvez définir des points d'arrêt et déboguer les applications distantes exécutées dans des conteneurs pour les langages suivants :
Java
Cloud Code ajoute automatiquement une variable d'environnement, JAVA_TOOL_OPTIONS, avec la configuration JDWP appropriée pour permettre le débogage. Si JAVA_TOOL_OPTIONS est déjà présent, Cloud Code utilise les paramètres existants spécifiés dans JAVA_TOOL_OPTIONS.
Node.js
Selon la structure de votre application et sa configuration de compilation d'images, vous devrez peut-être aider le débogueur à mapper vos sources locales avec les sources distantes du conteneur. Cela permet au débogueur de nœud de traiter correctement vos points d'arrêt.
Pour ce faire, procédez de l'une des façons suivantes :
Configuration manuelle
Sélectionnez la configuration d'exécution Develop on Kubernetes (Développer sur Kubernetes) dans la liste déroulante, puis cliquez sur Edit Configurations (Modifier les configurations). Dans l'onglet Débogage, configurez le mappage de source de votre source d'application locale avec l'emplacement source dans le conteneur distant.
Options de configuration :
File/Directory (Fichier/Répertoire) : fichier ou répertoire local de votre application s'exécutant sur Kubernetes.
Remote Path (Chemin d'accès à distance) : chemin d'accès au fichier ou au répertoire exécuté dans le conteneur sur Kubernetes.
Configuration automatique
Vous pouvez choisir de déléguer ce mappage à Cloud Code. Lorsque vous démarrez votre session de débogage, Cloud Code tente de déduire automatiquement ce mappage. Le mappage déduit vous sera présenté dans une boîte de dialogue (une boîte de dialogue pour chaque artefact que vous déboguez).
Options de configuration :
Local path (Chemin d'accès local) : chemin d'accès local à la racine de l'artefact que vous déboguez.
Remote Path (Chemin d'accès à distance) : chemin d'accès au fichier ou au répertoire exécuté dans le conteneur sur Kubernetes. Vous pouvez choisir de remplacer ce paramètre par votre propre valeur. Si vous cliquez sur Annuler, aucun mappage n'est appliqué.
Go
Pour configurer votre application pour le débogage, elle doit être une application à base de Modules Go et être identifiée en tant que telle en définissant l'une des Variables d'environnement d'exécution Go standard dans le conteneur, par exemple GODEBUG, GOGC, GOMAXPROCS ouGOTRACEBACK. GOTRACEBACK=single est le paramètre par défaut pour Go, et GOTRACEBACK=all est une configuration généralement utile.
Si possible (mais recommandé), votre application doit être créée avec les options -gcflags='all=-N -l' pour désactiver les optimisations. Les profils Skaffold sont une option utile à cette fin. Ils peuvent être définis à l'aide du champ Deployment Profile (Profil de déploiement) de votre configuration d'exécution dans l'onglet Build/Deploy (Compilation/Déploiement).
Python
Pour configurer votre application pour le débogage, assurez-vous de remplir les conditions préalables suivantes :
IDE, édition et plug-in compatibles
Pour connaître les IDE, les éditions et les plug-ins compatibles, consultez la section IDE compatibles.
Version Skaffold 1.25.0 ou ultérieure
Vous pouvez autoriser Cloud Code à gérer vos dépendances ou pointer vers une installation Skaffold locale. Consultez la section Préférences > Outils > Cloud Code > Dépendances.
L'interpréteur Python est configuré
Sans interpréteur Python configuré dans votre projet, le débogage ne fonctionne pas car il n'existe aucun moyen d'exécuter pydevd, le débogueur Python sous-jacent.
IDE
Procédure de configuration
IntelliJ IDEA
Le débogage Python avec Cloud Code nécessite la configuration d'un SDK Python pour votre projet.
Accédez à Fichier > Structure du projet et ajoutez un SDK Python dans l'onglet Projet. S'il n'en existe pas, ajoutez-en un dans l'onglet SDK.
PyCharm
Accédez à Fichier > Paramètres > Projet > Interpréteur Python ou pour macOS X, PyCharm > Préférences > Projet > Interpréteur Python, puis ajoutez un interpréteur Python.
Pour démarrer le cycle de développement en mode de débogage sur votre cluster Kubernetes, cliquez sur l'action de débogage pour Développer sur Kubernetes.
Vous pouvez désormais effectuer vos tâches habituelles de débogage de code local, telles que la définition de points d'arrêt et le passage en revue du code, sur un cluster Kubernetes en service.
Pour mettre fin à la session de débogage, cliquez sur l'icône d'arrêt dans la configuration d'exécution Develop on Kubernetes (Développer sur Kubernetes).
Pour envoyer des commentaires ou signaler un problème dans votre IDE IntelliJ, accédez à Outils > Cloud Code > Aide / À propos > Envoyer des commentaires ou signaler un problème pour signaler un problème sur GitHub.
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/08/11 (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/08/11 (UTC)."],[[["\u003cp\u003eCloud Code for IntelliJ enables debugging of applications deployed to Kubernetes clusters, including local clusters, Google Kubernetes Engine, or other cloud providers.\u003c/p\u003e\n"],["\u003cp\u003eDebugging support in Cloud Code eliminates the need for manual setup, such as port forwarding, debugging backend installation, or language-specific debug argument injection, for supported languages.\u003c/p\u003e\n"],["\u003cp\u003eCloud Code allows for debugging while actively making changes and iterating on the source code of an application.\u003c/p\u003e\n"],["\u003cp\u003eSupported languages for debugging include Java, Kotlin, Node.js, Go, and Python, with specific IDE and plugin requirements for each.\u003c/p\u003e\n"],["\u003cp\u003eCloud Code offers both manual and automatic configurations for mapping local source code to remote sources in containers for Node.js applications, and it also has specific configurations needed for Go and Python apps.\u003c/p\u003e\n"]]],[],null,["# Debug Kubernetes applications with Cloud Code for IntelliJ\n\n| **Note:** Debugging support is available for Java, Kotlin, Node.js, Go, and Python.\n\nCloud Code for IntelliJ allows you to easily debug your applications deployed to a\nKubernetes cluster. You can debug an application on a local cluster (like\nminikube or Docker Desktop), Google Kubernetes Engine, or any other Cloud provider.\n\nWith Cloud Code's debugging support, you skip manual setup like\nsetting up port forwarding, installing a debugging backend, or injecting\nlanguage-specific debug arguments in the right way. All you need is a\nCloud Code-ready Kubernetes application that includes a\n`skaffold.yaml` configuration file.\n\nCloud Code also enables you to [debug an application while making\nchanges to, and iterating on, source code](/code/docs/intellij/watch-modes#applying-changes-while-debugging).\n\nSupported IDEs\n--------------\n\nThe following table lists the languages and IDEs that Cloud Code supports for\ndebugging. The table also lists the required plugins, where applicable:\n\nFor more information about IDE support, see\n[Supported JetBrains IDEs](/code/docs/intellij/ides).\n\nWith Cloud Code, you can set breakpoints and\ndebug remote applications running in containers for the following languages: \n\n### Java\n\nCloud Code automatically adds an environment variable,\n`JAVA_TOOL_OPTIONS`, with the appropriate JDWP configuration to\nenable debugging. If `JAVA_TOOL_OPTIONS` is already present,\nCloud Code uses existing settings specified in\n`JAVA_TOOL_OPTIONS`.\n\n### Node.js\n\nDepending on the structure of your application and its image build\nconfiguration, you might have to help the debugger map your local sources\nto the remote sources in the container. This enables the Node debugger\nto correctly process your breakpoints.\n\nYou can configure this in one of the following ways:\n\n- **Manual configuration**\n\n Select the **Develop on Kubernetes** Run Configuration from the dropdown\n and then click **Edit Configurations** . On the **Debug** tab, configure the\n source mapping from your local application source to the source\n location in the remote container.\n\n Configuration options:\n - **File/directory** - the local file or directory of your application running on Kubernetes.\n - **Remote path** - the path to the file or directory running in the container on Kubernetes.\n- **Automatic configuration**\n\n You can choose to defer this mapping to Cloud Code. When you\n start your debug session, Cloud Code attempts to infer\n this mapping automatically. The inferred mapping is presented to you in a\n dialog; one dialog for each artifact you are debugging.\n\n Configuration options:\n - **Local path** - the local path to the root of the artifact you are debugging.\n - **Remote path** - the path to the file or directory running in the container on Kubernetes. You can choose to override this with your own value. If you click **Cancel**, no mapping is applied.\n\n | **Note:** Automatic mapping is a best effort guess based on heuristics.\n\n### Go\n\nTo configure your application for debugging, your app must be a\n[Go Module](https://blog.golang.org/using-go-modules)-based application\nand be identified as being Go-based by setting one of the\n[standard Go runtime environment variables](https://godoc.org/runtime)\nin the container, such as `GODEBUG`, `GOGC`, `GOMAXPROCS`, or\n`GOTRACEBACK`. `GOTRACEBACK=single` is the default setting for Go\nand `GOTRACEBACK=all` is a generally useful configuration.\n\nOptionally (but recommended), your app should be built with the\n`-gcflags='all=-N -l'` options to disable optimizations. Skaffold\n[Profiles](https://skaffold.dev/docs/environment/profiles/) are a useful\noption for this purpose and can be set with the **Deployment Profile**\nfield in your Run configuration on the **Build/Deploy** tab.\n\n### Python\n\nTo configure your application for debugging, ensure you meet the following\nprerequisites:\n\n- **IDE, edition, and plugin are compatible**\n\n For compatible IDEs, editions, and plugins, see\n [Supported IDEs](#supported_ides).\n- **Skaffold version is 1.25.0 or greater**\n\n You can allow Cloud Code to [manage your dependencies](/code/docs/intellij/install#managed_dependencies),\n or point to a local Skaffold installation. See **Preferences \\\u003e Tools \\\u003e\n Cloud Code \\\u003e Dependencies**.\n- **Python interpreter is configured**\n\n Without a Python interpreter configured in your project,\n debugging won't work, as there is no way to run `pydevd`, the\n underlying Python debugger.\n\n \u003cbr /\u003e\n\n \u003cbr /\u003e\n\nFor more information, see the [Skaffold debug\ndocumentation](https://skaffold.dev/docs/workflows/debug/).\n\nDebug an application\n--------------------\n\n1. To start the development cycle in debug mode on your Kubernetes cluster,\n click the debug action for\n **Develop on Kubernetes**.\n\n The [continuous development cycle](/code/docs/intellij/speed-up-k8s-development#continuous_development_on_kubernetes)\n initiates in debug mode.\n\n Cloud Code attaches a debug session:\n\n2. You can now perform the tasks you normally do when debugging local code,\n like setting breakpoints and stepping through code, against a live\n Kubernetes cluster.\n\n3. To end the debugging session, click the stop icon on the\n **Develop on Kubernetes** Run Configuration.\n\nWhat's next\n-----------\n\n- Use [file sync and hot reloading](/code/docs/intellij/speed-up-k8s-development#enable-skaffold-file-sync-and-hot-reloading) to speed up development.\n- Set up a [continuous development](/code/docs/intellij/speed-up-k8s-development#continuous_development_on_kubernetes) environment in Cloud Code.\n- [View Kubernetes logs](/code/docs/intellij/view-logs) in Cloud Code.\n\nGet support\n-----------\n\nTo submit feedback or report an issue in your IntelliJ IDE, go to **Tools** \\\u003e **Cloud Code** \\\u003e **Help / About** \\\u003e **Submit\nfeedback or report an issue** to report an issue on [GitHub](https://github.com/GoogleCloudPlatform/cloud-code-intellij/issues)."]]