Men-debug aplikasi Kubernetes dengan Cloud Code untuk IntelliJ
Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Cloud Code for IntelliJ memungkinkan Anda men-debug aplikasi yang di-deploy ke cluster Kubernetes dengan mudah. Anda dapat men-debug aplikasi di cluster lokal (seperti minikube atau Docker Desktop), Google Kubernetes Engine, atau penyedia Cloud lainnya.
Dengan dukungan proses debug Cloud Code, Anda dapat melewati penyiapan manual seperti
menyiapkan penerusan port, menginstal backend proses debug, atau menyuntikkan
argumen proses debug khusus bahasa dengan cara yang benar. Yang Anda butuhkan hanyalah aplikasi Kubernetes yang siap untuk Cloud Code yang menyertakan file konfigurasi skaffold.yaml.
Dengan Cloud Code, Anda dapat menyetel titik henti sementara dan
men-debug aplikasi jarak jauh yang berjalan dalam container untuk bahasa berikut:
Java
Cloud Code otomatis menambahkan variabel lingkungan,
JAVA_TOOL_OPTIONS, dengan konfigurasi JDWP yang sesuai untuk
mengaktifkan proses debug. Jika JAVA_TOOL_OPTIONS sudah ada, Cloud Code menggunakan setelan yang ada yang ditentukan dalam JAVA_TOOL_OPTIONS.
Node.js
Bergantung pada struktur aplikasi dan konfigurasi build image-nya, Anda mungkin harus membantu debugger memetakan sumber lokal ke sumber jarak jauh dalam container. Hal ini memungkinkan debugger Node memproses titik henti sementara Anda dengan benar.
Anda dapat mengonfigurasi ini dengan salah satu cara berikut:
Konfigurasi manual
Pilih Konfigurasi Run Develop on Kubernetes dari dropdown
lalu klik Edit Configurations. Di tab Debug, konfigurasi
pemetaan sumber dari sumber aplikasi lokal Anda ke lokasi sumber
di container jarak jauh.
Opsi konfigurasi:
File/direktori - file atau direktori lokal aplikasi Anda yang
berjalan di Kubernetes.
Jalur jarak jauh - jalur ke file atau direktori yang berjalan di
container di Kubernetes.
Konfigurasi otomatis
Anda dapat memilih untuk menunda pemetaan ini ke Cloud Code. Saat Anda
memulai sesi debug, Cloud Code akan mencoba menyimpulkan
pemetaan ini secara otomatis. Pemetaan yang disimpulkan ditampilkan kepada Anda dalam dialog; satu dialog untuk setiap artefak yang Anda debug.
Opsi konfigurasi:
Jalur lokal - jalur lokal ke root artefak yang
sedang Anda debug.
Jalur jarak jauh - jalur ke file atau direktori yang berjalan di
container di Kubernetes. Anda dapat memilih untuk
mengganti nilai ini dengan nilai Anda sendiri. Jika Anda mengklik
Batal, tidak ada pemetaan yang diterapkan.
Go
Untuk mengonfigurasi aplikasi Anda untuk proses debug, aplikasi Anda harus berupa aplikasi berbasis Go Module dan diidentifikasi sebagai berbasis Go dengan menyetel salah satu variabel lingkungan runtime Go standar di penampung, seperti GODEBUG, GOGC, GOMAXPROCS, atau GOTRACEBACK. GOTRACEBACK=single adalah setelan default untuk Go
dan GOTRACEBACK=all adalah konfigurasi yang umumnya berguna.
Secara opsional (tetapi direkomendasikan), aplikasi Anda harus dibangun dengan opsi -gcflags='all=-N -l' untuk menonaktifkan pengoptimalan. Profil Skaffold adalah opsi yang berguna untuk tujuan ini dan dapat disetel dengan kolom Deployment Profile di konfigurasi Run pada tab Build/Deploy.
Python
Untuk mengonfigurasi aplikasi Anda untuk proses debug, pastikan Anda memenuhi prasyarat berikut:
IDE, edisi, dan plugin kompatibel
Untuk mengetahui IDE, edisi, dan plugin yang kompatibel, lihat
IDE yang didukung.
Versi Skaffold adalah 1.25.0 atau yang lebih baru
Anda dapat mengizinkan Cloud Code untuk mengelola dependensi Anda,
atau mengarah ke penginstalan Skaffold lokal. Lihat Preferences > Tools >
Cloud Code > Dependencies.
Interpreter Python dikonfigurasi
Tanpa penafsir Python yang dikonfigurasi di project Anda, proses debug tidak akan berfungsi karena tidak ada cara untuk menjalankan pydevd, debugger Python yang mendasarinya.
IDE
Cara mengonfigurasi
IntelliJ IDEA
Pen-debug-an Python dengan Cloud Code memerlukan
Python SDK yang dikonfigurasi untuk project Anda.
Buka File
> Project Structure dan tambahkan Python SDK di tab Project. Jika tidak ada, tambahkan satu di tab SDK.
PyCharm
Buka File > Settings > Project > Python Interpreter atau
untuk Mac OS X, PyCharm > Preferences > Project > Python
Interpreter, lalu tambahkan interpreter Python.
Sekarang Anda dapat melakukan tugas yang biasanya Anda lakukan saat men-debug kode lokal, seperti menyetel titik henti sementara dan menelusuri kode, terhadap cluster Kubernetes aktif.
Untuk mengakhiri sesi pen-debug-an, klik ikon berhenti di Konfigurasi Run
Develop on Kubernetes.
Untuk mengirimkan masukan atau melaporkan masalah di IDE IntelliJ, buka
Tools > Cloud Code > Help / About > Submit
feedback or report an issue untuk melaporkan masalah di GitHub.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 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)."]]