Kubernetes-Anwendungen mit Cloud Code for IntelliJ debuggen
Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Mit Cloud Code for IntelliJ lassen sich mühelos Fehler in ihren auf einem Kubernetes-Cluster bereitgestellten Anwendungen beheben. Sie können in einer Anwendung Fehler auf einem lokalen Cluster (z. B. Minikube oder Docker Desktop), Google Kubernetes Engine oder einem anderen Cloud-Anbieter beheben.
Mit der Unterstützung für die Fehlerbehebung von Cloud Code überspringen Sie die manuelle Einrichtung wie die Einrichtung der Portweiterleitung, die Installation eines Debugging-Back-Ends oder das Einfügen von sprachspezifischen Debug-Argumenten. Sie benötigen lediglich eine Cloud Code-fähige Kubernetes-Anwendung, die eine skaffold.yaml-Konfigurationsdatei enthält.
In der folgenden Tabelle sind die Sprachen und IDEs aufgeführt, die von Cloud Code für das Debugging unterstützt werden. In der Tabelle sind gegebenenfalls auch die erforderlichen Plug-ins aufgeführt:
Mit Cloud Code können Sie Haltepunkte festlegen und Fehler in Remote-Anwendungen beheben, die in Containern für die folgenden Sprachen ausgeführt werden:
Java
Cloud Code fügt automatisch die Umgebungsvariable JAVA_TOOL_OPTIONS mit der entsprechenden JDWP-Konfiguration hinzu, um die Fehlerbehebung zu aktivieren. Wenn JAVA_TOOL_OPTIONS bereits vorhanden ist, verwendet Cloud Code die in JAVA_TOOL_OPTIONS angegebenen Einstellungen.
Node.js
Je nach Struktur Ihrer Anwendung und ihrer Image-Build-Konfiguration müssen Sie möglicherweise helfen, dass der Debugger Ihre lokalen Quellen den Remotequellen im Container zuordnet. Dadurch kann der Node.txt-Debugger Ihre Haltepunkte ordnungsgemäß verarbeiten.
Dies kann auf eine der folgenden Arten geschehen:
Manuelle Konfiguration
Wählen Sie im Drop-down-Menü Develop on Kubernetes die Option Konfigurationen bearbeiten aus. Konfigurieren Sie im Tab Debugging die Quellzuordnung von Ihrer lokalen Anwendungsquelle zum Quellspeicherort im Remote-Container.
Konfigurationsoptionen:
Datei/Verzeichnis: Die lokale Datei oder das lokale Verzeichnis Ihrer Anwendung, die auf Kubernetes ausgeführt wird.
Remote Path: Der Pfad zur Datei oder dem Verzeichnis, die im Container in Kubernetes ausgeführt werden.
Automatische Konfiguration
Sie können diese Zuordnung zu Cloud Code aufheben. Wenn Sie die Fehlerbehebungssitzung starten, versucht Cloud Code, diese Zuordnung automatisch abzuleiten. Die abgeleitete Zuordnung wird Ihnen in einem Dialogfeld angezeigt. Ein Dialogfeld für jedes Artefakt, das Sie debuggen.
Konfigurationsoptionen:
Lokaler Pfad: der lokale Pfad zum Stammverzeichnis des Artefakts, für das Sie eine Fehlerbehebung durchführen
Remote Path: Der Pfad zur Datei oder dem Verzeichnis, die im Container in Kubernetes ausgeführt werden. Sie können diese Einstellung mit einem eigenen Wert überschreiben. Wenn Sie auf Abbrechen klicken, wird keine Zuordnung angewendet.
Go
Um Ihre Anwendung für die Fehlerbehebung zu konfigurieren, muss Ihre Anwendung eine auf dem Go-Modul basierende Anwendung sein und als Go-basiert identifiziert werden, indem Sie eine der Standard-Umgebungsvariablen der Go-Laufzeit im Container einstellen, z. B. GODEBUG, GOGC, GOMAXPROCS oder GOTRACEBACK. GOTRACEBACK=single ist die Standardeinstellung für Go und GOTRACEBACK=all eine allgemeine nützliche Konfiguration.
Optional (aber empfohlen) sollte Ihre Anwendung mit den -gcflags='all=-N -l'-Optionen erstellt werden, um Optimierungen zu deaktivieren. Skaffold-Profile sind für diesen Zweck nützlich und können in Ihrer Ausführungskonfiguration auf dem Tab Build/Bereitstellen mit dem Feld Bereitstellungsprofil festgelegt werden.
Python
Um Ihre Anwendung für das Debugging zu konfigurieren, müssen die folgenden Voraussetzungen erfüllt sein:
IDE, Edition und Plug-in sind kompatibel
Kompatible IDEs, Versionen und Plug-ins finden Sie unter Unterstützte IDEs.
Skaffold-Version ist 1.25.0 oder höher
Sie können Cloud Code die Verwaltung Ihrer Abhängigkeiten erlauben oder auf eine lokale Skaffold-Installation verweisen. Weitere Informationen finden Sie unter Einstellungen > Tools > Cloud Code > Abhängigkeiten.
Python-Interpreter ist konfiguriert
Ohne einen in Ihrem Projekt konfigurierten Python-Interpreter funktioniert das Debugging nicht, da es keine Möglichkeit gibt, pydevd, den zugrunde liegenden Python-Debugger, auszuführen.
IDE
Konfiguration
IntelliJ IDEA
Für die Python-Fehlerbehebung mit Cloud Code muss ein Python-SDK für Ihr Projekt konfiguriert sein.
Rufen Sie Datei > Projektstruktur auf und fügen Sie auf dem Tab Projekt ein Python SDK hinzu. Falls keine vorhanden sind, fügen Sie auf dem Tab SDK eines hinzu.
PyCharm
Wählen Sie unter Datei > Einstellungen > Projekt > Python-Interpreter oder für Mac OS X PyCharm > Einstellungen > Projekt > Python-Interpreter einen Python-Interpreter aus.
Sie können jetzt die Aufgaben ausführen, die Sie normalerweise beim Debuggen von lokalem Code ausführen, z. B. das Festlegen von Haltepunkten und das Durchlaufen von Code in einem Live-Kubernetes-Cluster.
Klicken Sie zum Beenden der Debugging-Sitzung auf das Stopp-Symbol in der Ausführungskonfiguration für Auf Kubernetes entwickeln.
So senden Sie Feedback oder melden ein Problem in Ihrer IntelliJ-IDE: Tools > Cloud Code > Hilfe / Info > Feedback geben oder Problem melden, um ein Problem auf GitHub zu melden.
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-09-04 (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)."]]