Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Halaman ini menunjukkan cara men-deploy layanan ke Cloud Run menggunakan
Cloud Code untuk VS Code.
Men-deploy layanan ke Cloud Run
Untuk men-deploy layanan Anda ke Cloud Run:
Buka palet perintah (tekan Ctrl/Cmd+Shift+P atau klik View >
Command Palette), lalu jalankan perintah
Deploy to Cloud Run.
Di panel Deploy to Cloud Run, tetapkan project Google Cloud Anda.
Pilih layanan yang sudah ada atau buat layanan baru.
Jika Anda membuat layanan baru, pilih preferensi platform Anda di bagian Platform Deployment, baik Cloud Run (terkelola sepenuhnya) atau Knative serving. Untuk mendapatkan bantuan dalam memilih opsi terbaik untuk
kebutuhan pengembangan Anda, lihat
Panduan memilih platform.
Jika Anda memilih Cloud Run (terkelola sepenuhnya), pilih
region tempat deployment akan dilakukan. Jika Anda memilih Knative serving,
konfigurasi informasi cluster Kubernetes.
(Opsional) Untuk menentukan setelan tambahan seperti akun layanan, variabel
lingkungan, dan koneksi SQL, luaskan bagian Setelan revisi lanjutan.
Variabel lingkungan berikut akan otomatis ditambahkan ke container yang berjalan:
Nama
Deskripsi
Contoh
PORT
Port yang akan diproses oleh server HTTP Anda.
8080
K_SERVICE
Nama layanan Cloud Run yang sedang dijalankan.
hello-world
K_REVISION
Nama revisi Cloud Run yang sedang dijalankan.
hello-world.1
K_CONFIGURATION
Nama konfigurasi Cloud Run yang membuat revisi.
hello-world
Di bagian Lingkungan build, tentukan apakah akan mem-build secara lokal atau menggunakan Cloud Build.
Tentukan builder (Docker atau Buildpack) dan setelannya.
Setelah Anda menentukan setelan pilihan, klik Deploy.
Cloud Code for VS Code akan membangun image Anda, mengirimkannya ke registry, lalu men-deploy layanan ke Cloud Run. Layanan Anda kini sudah aktif.
Lihat layanan yang berjalan dengan mengikuti URL yang ditampilkan di webview.
Anda juga dapat melihat detail layanan yang sedang berjalan dengan mengklik tombol
Show Detailed Logs dan melihat log verbose di
jendela output.
Setelah sesi Anda selesai, klik kanan untuk menggunakan perintah berikut:
Melihat Log: Buka log aplikasi deployment
tertentu dengan Cloud Code Logs Explorer
Buka URL: Buka URL layanan aplikasi dari layanan
tertentu di browser web
Jika Anda telah menonaktifkan mode lihat di konfigurasi peluncuran dan ingin
melakukan perubahan pada aplikasi, membangun ulang, dan men-deploy ulang aplikasi,
klik status bar Cloud Code, lalu klik
Turn on watch mode.
Dapatkan Dukungan
Untuk mengirim masukan, laporkan masalah di
GitHub,
atau ajukan pertanyaan di
Stack Overflow.
[[["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 details how to deploy a service to Cloud Run using Cloud Code for VS Code directly from the command palette.\u003c/p\u003e\n"],["\u003cp\u003eYou can choose between deploying to Cloud Run (fully managed) or Knative serving, each with their own configuration steps, such as selecting a region or configuring Kubernetes cluster details.\u003c/p\u003e\n"],["\u003cp\u003eDuring deployment, Cloud Code builds your image, pushes it to the registry, and makes your service live on Cloud Run, with options to use local or Cloud Build.\u003c/p\u003e\n"],["\u003cp\u003ePost-deployment, you can access your service's URL in the webview, view logs, and manage your application, including turning on or off watch mode for changes.\u003c/p\u003e\n"],["\u003cp\u003eThe running container will have access to the environment variables such as, the service's port, name, revision and configuration, to help maintain the application.\u003c/p\u003e\n"]]],[],null,["# Deploy a service in Cloud Code for VS Code\n\nThis page shows you how to deploy a service to Cloud Run using\nCloud Code for VS Code.\n\nDeploying a service to Cloud Run\n--------------------------------\n\nTo deploy your service to Cloud Run:\n\n1. Open the command palette (press `Ctrl`/`Cmd`+`Shift`+`P` or click **View** \\\u003e\n **Command Palette** ) and then run the\n **Deploy to Cloud Run** command.\n\n2. In the **Deploy to Cloud Run** pane, set your Google Cloud project.\n\n3. Select a preexisting service or create a new one.\n\n4. If you're creating a new service, choose your platform preferences\n under **Deployment Platform** , either\n **Cloud Run (fully managed)** or\n **Knative serving** . For help choosing the best option for\n your development needs, see the\n [Choosing your platform guide](/run/docs/choosing-a-platform).\n\n5. If you selected **Cloud Run (fully managed)** , choose\n a region to deploy to. If you selected **Knative serving**,\n configure the Kubernetes cluster information.\n\n | **Note:** Cloud Code can only deploy to Knative serving if Knative serving is enabled as a feature on the GKE cluster. It is not compatible with the newer version of Knative serving which is installed as an Anthos fleet component with Cloud Service Mesh. The free trial period for Knative serving ended on September 30, 2021. See the [GA version documentation](/anthos/run/docs/install) for details about installing Cloud Run for Anthos as an Anthos fleet component with Anthos Service Mesh. The [past version has been archived](/anthos/run/archive/docs) but the documentation remains available for existing users.\n6. (Optional) To specify additional settings like service account, environment\n variables, and SQL connections, expand the **Advanced revision settings**\n section.\n\n The following environment variables are automatically added to the running\n containers:\n\n \u003cbr /\u003e\n\n \u003cbr /\u003e\n\n7. Under Build environment, specify whether to build locally or using\n Cloud Build.\n\n8. Specify your builder (Docker or Buildpack) and its settings.\n\n9. After you define your preferred settings, click **Deploy**.\n\n Cloud Code for VS Code builds your image, pushes it to the registry, and\n deploys your service to Cloud Run. Your service is now live!\n10. View your running service by following the URL displayed in the **webview**.\n\n You can also view details of your running service by clicking the\n **Show Detailed Logs** button and looking through your verbose logs in the\n output window.\n\n11. After your session completes, right-click to use the following commands:\n\n - **View Logs:** Open the application logs of a specific deployment with the Cloud Code Logs Explorer\n - **Open URL:** Open the application service URL of a specific service in a web browser\n12. If you've turned off watch mode in your launch configuration and you want to\n make changes to your application and rebuild and redeploy the application,\n click the Cloud Code status bar and then click\n **Turn on watch mode**.\n\nGet Support\n-----------\n\nTo send feedback, report issues on [GitHub](https://github.com/GoogleCloudPlatform/cloud-code-vscode/issues), or ask a question on [Stack Overflow](https://stackoverflow.com/questions/ask?tags=cloud-code-vscode)."]]