Tetap teratur dengan koleksi Simpan dan kategorikan konten berdasarkan preferensi Anda.
Men-deploy aplikasi Kubernetes dengan Cloud Code for IntelliJ
Halaman ini menunjukkan cara memulai Cloud Code.
Dalam panduan memulai ini, Anda akan menyiapkan aplikasi Kubernetes baru menggunakan template pemicu Hello World, menjalankan aplikasi di cluster pilihan Anda, memulai pembuatan ulang berkelanjutan untuk mengembangkan aplikasi secara iteratif, men-debug kode yang berjalan, dan bersantai serta melihat log yang di-streaming dari aplikasi aktif Anda.
Atau, Anda dapat menggunakan cluster yang dihosting di platform cloud lain atau cluster Kubernetes lokal dengan alat seperti minikube dan Docker Desktop.
Instal Git agar Cloud Code dapat melakukan operasi Git, seperti meng-clone sampel.
Cloud Code dilengkapi dengan kumpulan template contoh kode untuk membantu Anda memulai dengan cepat. Untuk membuat aplikasi baru menggunakan contoh yang ada:
Di IDE, buka File > New Project, lalu pilih Cloud Code: Kubernetes.
Pilih template Hello World dari daftar aplikasi awal.
Pilih nama untuk project Anda.
Setelah Anda mengklik Finish, Cloud Code akan meng-clone template yang Anda pilih dan membuka project yang baru dibuat untuk digunakan.
Untuk template Java, Anda akan diminta untuk mengimpor project Maven yang diperlukan untuk menyinkronkan pom.xml. Klik Add as Maven project, lalu klik Import Changes.
Memilih cluster
Untuk mengembangkan aplikasi, Anda memerlukan cluster Kubernetes terkait (dihosting secara lokal dengan minikube atau menggunakan platform cloud, seperti cluster Google Kubernetes Engine).
Cluster lokal
Jika belum memiliki cluster yang akan digunakan untuk panduan memulai ini, Anda dapat memilih untuk menjalankan aplikasi dengan cluster minikube lokal yang dikelola Cloud Code. Cloud Code memulai cluster minikube untuk menjalankan aplikasi Anda dan menghentikan cluster saat deployment berhenti. Jika cluster minikube sudah berjalan, Cloud Code akan menggunakan kembali cluster minikube yang ada untuk deployment.
Anda dapat memilih untuk menggunakan cluster minikube yang dikelola Cloud Code ini di langkah berikutnya, mengembangkan aplikasi, dengan menetapkannya sebagai preferensi deployment.
Cluster berbasis platform cloud
Jika Anda sudah memiliki cluster yang dikonfigurasi untuk berfungsi dengan alat Kubernetes (seperti kubectl) yang dapat Anda gunakan untuk memulai cepat ini, Cloud Code akan men-deploynya secara otomatis. Anda dapat melanjutkan ke mengembangkan aplikasi tempat Anda dapat mengonfirmasi bahwa cluster pilihan Anda ditetapkan sebagai konteks saat ini.
Jika tidak, Anda dapat membuatnya menggunakan petunjuk khusus platform cloud Anda. Untuk GKE, Anda dapat mengikuti panduan Membuat cluster.
Mengembangkan aplikasi
Untuk memulai pengembangan aplikasi di Kubernetes:
Jika Anda login ke Google Cloud di IDE dan memiliki project default yang ditentukan, Cloud Code akan otomatis menggunakan repositori image container default (gcr.io/{project_id} dengan {project_id} mereferensikan project default Anda).
Pastikan konteks Kubernetes pilihan Anda telah ditetapkan. Hal ini dapat ditentukan dalam konfigurasi Develop on Kubernetes (dapat diakses melalui Run > Edit Configurations > Develop on Kubernetes), di tab Run dan di bagian Preferensi deployment.
Anda dapat memilih untuk men-deploy ke konteks saat ini (default), secara lokal ke cluster minikube, atau ke konteks lain yang tersedia.
Secara default, aplikasi Kubernetes Anda akan berjalan dalam Mode on demand dengan On demand dipilih. Jika ingin, Anda dapat memilih opsi Saat file disimpan.
Pilih target run Develop on Kubernetes dari pemilih konfigurasi Run/Debug di menu Navigation.
Hal ini memastikan setiap perubahan kode akan otomatis di-build, di-push, dan di-deploy ke versi baru aplikasi Anda.
Untuk memulai siklus pengembangan di cluster Kubernetes, klik tindakan jalankan untuk Develop on Kubernetes.
Di jendela output, pada tab Logs, lihat log aplikasi yang masuk.
Setelah deployment dimulai, Anda akan melihat daftar port yang diteruskan untuk aplikasi yang di-deploy.
Jika deployment berhasil, Anda akan diberi tahu bahwa URL layanan baru tersedia. Klik tab Service URLs untuk melihat URL, lalu klik link URL untuk membuka browser dengan aplikasi yang sedang berjalan.
Atau, Anda dapat membuka Log Peristiwa, lalu mengklik link untuk membuka browser dengan aplikasi yang sedang berjalan.
Panel Deployed Resources menampilkan apa yang Anda deploy selama sesi pengembangan.
Klik tindakan debug untuk Develop on Kubernetes guna memulai siklus pengembangan dalam mode debug di cluster Kubernetes Anda.
Cloud Code akan melampirkan sesi debug. Jika berhasil, jendela Alat Debug akan terbuka, yang mengonfirmasi koneksi (di tab Konsol).
Sekarang Anda dapat men-debug cluster Kubernetes aktif.
Klik gutter pada baris kode yang dapat dieksekusi tempat Anda ingin menambahkan titik henti sementara.
Lingkaran isi merah menunjukkan titik henti sementara aktif, sedangkan lingkaran kosong dengan garis batas merah menunjukkan titik henti sementara yang dinonaktifkan.
Saat Anda mengirim permintaan baru ke aplikasi, permintaan tersebut akan dijeda di baris yang diinginkan.
Untuk mengakhiri sesi proses debug, klik ikon berhenti di konfigurasi run Develop on Kubernetes.
Melihat log
Selain melihat live stream log dari pod yang berjalan di output terminal saat mengembangkan dan menjalankan aplikasi, Anda dapat melihat log dari pod tertentu dengan membuka Kubernetes Explorer.
Untuk melihat log dari pod tertentu, ikuti langkah-langkah berikut:
Buka Kubernetes Explorer. View Cluster Explorer dapat diakses dari panel samping di sebelah kanan atau menggunakan Tools > Cloud Code > Kubernetes > View Cluster Explorer.
Pilih pod yang log-nya ingin Anda lihat.
Klik kanan pod, lalu pilih Stream Logs. Atau, Anda dapat melakukan streaming log untuk setiap penampung yang berjalan di pod.
Tindakan ini akan menghasilkan log ke Konsol Kubernetes Explorer.
Pembersihan
Agar akun Google Cloud Anda tidak dikenai biaya untuk resource yang digunakan di halaman ini, ikuti langkah-langkah berikut.
[[["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\u003eThis guide provides instructions on how to deploy a Kubernetes application using Cloud Code for IntelliJ, covering setup, creating a new application, choosing a cluster, and developing.\u003c/p\u003e\n"],["\u003cp\u003eYou can use either a local minikube cluster managed by Cloud Code or a cluster hosted on a cloud platform like Google Kubernetes Engine (GKE) to deploy and run your application.\u003c/p\u003e\n"],["\u003cp\u003eCloud Code facilitates iterative development with continuous rebuilding, allowing you to automatically build, push, and deploy code changes to your Kubernetes cluster.\u003c/p\u003e\n"],["\u003cp\u003eThe guide demonstrates how to debug your application directly on your Kubernetes cluster using Cloud Code's debugging features, including setting breakpoints and viewing logs.\u003c/p\u003e\n"],["\u003cp\u003eYou can monitor your application's performance by streaming logs from individual pods via the Kubernetes Explorer, and can clean up the resources that are used to avoid incurring any charges.\u003c/p\u003e\n"]]],[],null,["# Quickstart: Deploy a Kubernetes app with Cloud Code for IntelliJ\n\nDeploy a Kubernetes app with Cloud Code for IntelliJ\n====================================================\n\nThis page shows you how to get started with Cloud Code.\n\nIn this quickstart, you'll set up a new Kubernetes application using a starter\nHello World template, run your app on a cluster of your choosing, kickstart\ncontinuous rebuilding to iteratively develop your app, debug your\nrunning code, and sit back and view logs streaming from your live application.\n\nBefore you begin\n----------------\n\n1. If you'd like to use Google Cloud, you'll need to\n [create or select a Google Cloud project](https://console.cloud.google.com/projectcreate)\n and [enable billing on your project](/billing/docs/how-to/modify-project).\n\n | **Note:** To get the most out of this quickstart, creating a Google Cloud project is recommended. This will allow you to easily create and work with a live GKE cluster, leverage Cloud Code's continuous delivery offering, and utilize its live debugging capabilities.\n\n Alternatively, you can use a cluster hosted on any other cloud platform or a\n local Kubernetes cluster with tools such as\n [minikube](https://kubernetes.io/docs/tasks/tools/install-minikube) and\n [Docker Desktop](https://www.docker.com/products/docker-desktop).\n2. Install [Git](https://git-scm.com/downloads) so that Cloud Code\n can perform Git operations, like cloning a sample.\n\n3. Install the [Cloud Code plugin](/code/docs/intellij/install#installing)\n if you haven't already.\n\nCreating an application\n-----------------------\n\nCloud Code comes with a collection of\n[code sample](https://github.com/GoogleCloudPlatform/cloud-code-samples#readme)\ntemplates to get you started quickly. To create a new application using an\nexisting sample:\n\n1. In your IDE, open **File** \\\u003e **New Project** and select\n **Cloud Code: Kubernetes**.\n\n2. Select a **Hello World** template from the list of starter applications.\n\n3. Pick a name for your project.\n\n After you click **Finish**, Cloud Code clones your chosen\n template and opens your newly created project for use.\n\n For **Java** templates, you're prompted to import required Maven projects to\n sync your pom.xml. Click **Add as Maven project** and then click **Import\n Changes**.\n\nChoosing a cluster\n------------------\n\nIn order to develop your application, you'll need an associated Kubernetes cluster\n(hosted either locally with minikube or using a cloud platform, like a\nGoogle Kubernetes Engine cluster).\n\n### Local cluster\n\nIf you don't already have a cluster to use for this quickstart, you can choose\nto run your application with a Cloud Code-managed local minikube cluster.\nCloud Code starts a minikube cluster to run your application and\nstops the cluster when deployment stops. If a minikube cluster is already\nrunning, Cloud Code reuses the existing minikube cluster for deployment.\n\nYou can choose to use this Cloud Code-managed minikube cluster in the\nnext step, [developing your application](#developing_your_application), by\nsetting it as your deployment preference.\n\n### Cloud platform-based cluster\n\nIf you already have a cluster configured to work with Kubernetes tools (like\nkubectl) that you can use for this quickstart, Cloud Code deploys\nto it automatically. You can move on to [developing your application](#developing_your_application)\nwhere you can confirm your preferred cluster is set as your current context.\n\nIf you don't, you can create one using your cloud platform-specific\ninstructions. For GKE, you can follow the\n[Creating a cluster](https://cloud.google.com/kubernetes-engine/docs/how-to/creating-a-cluster) guide.\n\nDeveloping your application\n---------------------------\n\nTo initiate development of your application on Kubernetes:\n\n1. If you're running on a cluster hosted on a cloud platform, ensure you have\n [defined where your container images are stored](/code/docs/intellij/configuring-container-image-settings#specifying_where_container_images_are_stored)\n for **Develop on Kubernetes**.\n\n If you're logged into Google Cloud in your IDE and you have a\n default project defined, Cloud Code automatically uses your\n default container image repository (gcr.io/{project_id} where {project_id}\n references your default project).\n2. Ensure your preferred Kubernetes context is set. This can be specified in\n your Develop on Kubernetes configuration (accessible through\n **Run** \\\u003e **Edit Configurations** \\\u003e **Develop on Kubernetes**), on the Run\n tab and in the Deployment preferences section.\n\n You can choose to deploy to a current context (default), locally to a\n minikube cluster, or to another available context.\n\n By default, your Kubernetes application will run in [On-demand mode](/code/docs/intellij/watch-modes)\n with **On demand** selected. If preferred, you can select the **On file save** option instead.\n3. Choose the **Develop on Kubernetes** run target from the Run/Debug\n configuration selector in the Navigation bar.\n\n This ensures any code changes to be automatically built, pushed, and deployed\n to a new version of your application.\n4. To start the development cycle on your Kubernetes cluster, click the run\n action for **Develop on Kubernetes**.\n\n5. In the **output window** , on the **Logs** tab, view incoming application\n logs.\n\n After the deployment has started, you'll see the list of forwarded ports for\n the deployed application.\n6. When the deployment is successful, you're notified that new service URLs are\n available. Click the **Service URLs** tab to view the URL(s), then click the\n URL link to open your browser with your running application.\n\n Alternatively, you can open the **Event Log** and then click the link to open\n your browser with your running application.\n\n The **Deployed Resources** pane shows what you deployed during the\n development session.\n\nDebugging your application\n--------------------------\n\n| **Note:** Debugging support is available for Java, Kotlin, Node.js, Go, and Python.\n\nCloud Code supports [applying changes while debugging](/code/docs/intellij/watch-modes#applying-changes-while-debugging).\n\nTo debug your application:\n\n1. Click the debug action\n for **Develop on Kubernetes** to start the development cycle in debug mode\n on your Kubernetes cluster.\n\n | **Note:** For Node.js apps, you will be prompted to help the debugger map your local sources to the remote sources in the container for each artifact you are debugging. This enables the Node debugger to correctly process your breakpoints. For more on how to configure this setting, refer to the [Debugging an app guide](/static/code/docs/intellij/debug#node.js).\n2. Cloud Code will attach a debug session. When successful, the\n Debug Tool window opens, confirming connection (on the Console tab).\n\n You can now debug against your live Kubernetes cluster.\n3. Click the gutter at the executable line of the code where you want to add\n a breakpoint.\n\n Red filled circles denote active breakpoints, while red-outlined hollow\n circles signify disabled breakpoints.\n4. When you send a new request to your application, it will pause at that\n desired line.\n\n5. To end the debugging session, click the stop icon on the\n `Develop on Kubernetes` run configuration.\n\nViewing logs\n------------\n\nIn addition to seeing a livestream of the logs from running pods in the terminal\noutput as you're developing and running your application, you can view logs from\na specific pod by navigating to the Kubernetes Explorer.\n\nTo view logs from a specific pod, follow these steps:\n\n1. Navigate to the Kubernetes Explorer. It can be\n accessed either from the side panel on the right or\n using **Tools** \\\u003e **Cloud Code** \\\u003e **Kubernetes** \\\u003e **View Cluster Explorer**.\n\n2. Select the pod you'd like to see logs from.\n\n3. Right-click the pod and then select **Stream Logs**. Alternatively, you can stream logs for individual containers running in pods.\n\n This outputs logs to the Kubernetes Explorer Console.\n\nClean up\n--------\n\n\nTo avoid incurring charges to your Google Cloud account for\nthe resources used on this page, follow these steps.\n\n1. Go to the Projects page in the Google Cloud console:\n\n [Go to the Projects page](https://console.cloud.google.com/project)\n2. Select the project you created for this Quickstart and click the trash can\n icon next to delete it.\n\n This shuts down the project and schedules it for deletion.\n\nWhat's next\n-----------\n\n- Consider importing an existing application, either a [Kubernetes](/code/docs/intellij/use-k8s-existing-app) or [App Engine](/code/docs/intellij/migrate) app, into your IDE and getting set up with Cloud Code.\n- Dive deeper into developing Kubernetes applications:\n - Tackle more advanced Google Cloud and Kubernetes configuration with Cloud Code's [YAML editing support](/code/docs/intellij/yaml-editing).\n - For better insight into and management of your Kubernetes resources, use [the Kubernetes Explorer](/code/docs/intellij/use-kubernetes-explorer).\n - [Deploy your applications to ARM64, AMD64, or mixed-architecture GKE clusters](/code/docs/intellij/deploy-to-arm-amd-mixed-arch).\n- Create, run, debug, and deploy an [App Engine app with Cloud Code](/code/docs/intellij/create-standard).\n- [Manage Cloud APIs and client libraries](/code/docs/intellij/client-libraries) from the comfort of your IDE.\n- [Explore your Cloud Storage content](/code/docs/intellij/gcs) within your IDE.\n- Add new projects to and check out existing ones from [Cloud Source Repositories\n with Cloud Code](/code/docs/intellij/vcs)."]]