Menggunakan aplikasi yang ada di Cloud Code untuk Cloud Shell
Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Cloud Code memanfaatkan Skaffold di balik layar untuk menjalankan atau men-debug aplikasi Anda.
Jika memiliki aplikasi yang sudah dikonfigurasi dengan manifes Kubernetes dan Dockerfile untuk mem-build image, Anda dapat membuka dan menggunakannya dengan Cloud Code.
Satu-satunya konfigurasi tambahan yang diperlukan adalah konfigurasi skaffold
dan konfigurasi peluncuran
jenis cloudcode.kubernetes. Cloud Code akan memandu Anda membuat ini saat menjalankan atau men-debug aplikasi untuk pertama kalinya.
Menyiapkan konfigurasi
Jika aplikasi Anda memiliki Dockerfile, tetapi tidak memiliki konfigurasi peluncuran dan Skaffold yang diperlukan, selesaikan langkah-langkah berikut:
Di status bar Cloud Code, klik nama project yang aktif.
Di menu Pilih Cepat yang muncul, pilih Jalankan di Kubernetes atau Debug
di Kubernetes.
Pada dialog Run/Debug on Kubernetes, tentukan builder pilihan Anda
dan setelannya. Anda juga dapat menyesuaikan nama konfigurasi.
Klik Debug atau Run.
Konfigurasi peluncuran skaffold.yaml dan
cloudcode.kubernetes yang baru dibuat akan ditambahkan ke ruang kerja dan
aplikasi Anda berjalan atau siap untuk proses debug.
Menyiapkan konfigurasi untuk aplikasi yang sudah memiliki skaffold.yaml
Jika aplikasi Anda sudah memiliki file skaffold.yaml, ikuti langkah-langkah berikut:
Di status bar Cloud Code, klik nama project yang aktif.
Di menu Pilih Cepat yang muncul, pilih Jalankan di Kubernetes atau Debug
di Kubernetes.
Jika ada lebih dari satu file skaffold.yaml di ruang kerja, pilih file skaffold.yaml yang Anda inginkan.
Jika ada lebih dari satu
profil Skaffold dalam
file skaffold.yaml yang Anda pilih, pilih profil Skaffold yang diinginkan.
Konfigurasi peluncuran cloudcode.kubernetes yang baru dibuat ditambahkan ke
workstation Anda (di .vscode/launch.json) dan aplikasi Anda
berjalan atau siap untuk proses debug.
Membuat konfigurasi Skaffold secara manual
Anda mungkin ingin membuat konfigurasi Skaffold secara manual untuk menentukan opsi kustom. Cloud Code dilengkapi dengan template live untuk mendukung pembuatan konfigurasi Skaffold manual.
Untuk membuat konfigurasi Skaffold secara manual:
Buat file baru bernama skaffold.yaml di direktori utama ruang kerja Anda.
Dalam file, tekan Command/Ctrl+Space untuk melihat daftar saran cuplikan, lalu pilih cuplikan Skaffold - Getting-started.
Masukkan nama image project Anda di kolom image dan masukkan daftar resource Kubernetes yang akan di-deploy di kolom manifests.
Jika ingin menentukan konfigurasi build, pengujian, dan deployment untuk
konteks yang berbeda, Anda dapat memiliki profil Skaffold yang berbeda. Contoh
berikut menunjukkan profil Cloud Build untuk mengonfigurasi Cloud Code guna
mem-build image dengan Cloud Build:
profiles:
# use the cloudbuild profile to build images using Google Cloud Build
- name: cloudbuild
build:
googleCloudBuild: {}
[[["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 utilizes Skaffold for running and debugging applications, and it can be used with existing applications that are already configured with Kubernetes manifests and a Dockerfile.\u003c/p\u003e\n"],["\u003cp\u003eCloud Code guides users through the creation of the necessary \u003ccode\u003eskaffold.yaml\u003c/code\u003e and \u003ccode\u003ecloudcode.kubernetes\u003c/code\u003e launch configurations when running or debugging an application for the first time if they don't already exist.\u003c/p\u003e\n"],["\u003cp\u003eIf your application already has a \u003ccode\u003eskaffold.yaml\u003c/code\u003e file, Cloud Code allows you to select the file and profile to use when running or debugging.\u003c/p\u003e\n"],["\u003cp\u003eUsers can manually create a \u003ccode\u003eskaffold.yaml\u003c/code\u003e file for custom options, with Cloud Code offering live templating and snippet suggestions to aid in the configuration process.\u003c/p\u003e\n"],["\u003cp\u003eAfter configuration, users can leverage features like file sync and hot reloading to accelerate development and debug their applications directly within Cloud Code.\u003c/p\u003e\n"]]],[],null,["# Use an existing application in Cloud Code for Cloud Shell\n\nCloud Code leverages [Skaffold](/skaffold) under the hood to run\nor debug your application.\n\nIf you have an existing application already configured with Kubernetes manifests and a\nDockerfile to build your images, you can open and use it with Cloud Code.\n\nThe only additional configuration necessary is a [skaffold configuration](https://skaffold.dev/docs/references/yaml/)\nand a [launch configuration](https://code.visualstudio.com/docs/editor/debugging#_launch-configurations)\nof type `cloudcode.kubernetes`. Cloud Code guides you through creating these\nwhen you run or debug your application for the first time.\n\nSetting up configuration\n------------------------\n\n| **Note:** Automatic `skaffold.yaml` generation doesn't support projects without a Dockerfile. For these projects, [create a skaffold.yaml file manually](#manually_creating_a_skaffold_configuration).\n\nIf your application has a Dockerfile but doesn't have the necessary Skaffold and\nlaunch configurations, complete the following steps:\n\n1. In the Cloud Code status bar, click the active project name.\n\n2. In the Quick Pick menu that appears, select **Run on Kubernetes** or **Debug\n on Kubernetes**.\n\n3. In the Run/Debug on Kubernetes dialog, specify your preferred builder\n and its settings. You can also customize your configuration name.\n\n4. Click **Debug** or **Run**.\n\n The newly created `skaffold.yaml` and\n `cloudcode.kubernetes` launch configuration are added to your workspace and\n your app [runs](/code/docs/shell/run-application) or is ready for [debugging](/code/docs/shell/debug).\n\nSetting up configuration for applications that already have skaffold.yaml\n-------------------------------------------------------------------------\n\nIf your application already has a `skaffold.yaml` file, follow these steps:\n\n1. In the Cloud Code status bar, click the active project name.\n\n2. In the Quick Pick menu that appears, select **Run on Kubernetes** or **Debug\n on Kubernetes**.\n\n3. If more than one `skaffold.yaml` file exists in your workspace, select your\n preferred skaffold.yaml file.\n\n4. If more than one\n [Skaffold profile](https://skaffold.dev/docs/environment/profiles/) exists in\n the `skaffold.yaml` file you chose, select your preferred Skaffold profile.\n\n The newly created `cloudcode.kubernetes` launch configuration is added to\n your workspace (in .vscode/launch.json) and your app is\n [running](/code/docs/shell/run-application) or ready for [debugging](/code/docs/shell/debug).\n\nManually creating a Skaffold configuration\n------------------------------------------\n\nYou might want to manually create your Skaffold configuration to define custom\noptions. Cloud Code comes with live templating to support manual\nSkaffold configuration creation.\n\nTo manually create a Skaffold configuration:\n\n1. Create a new file named `skaffold.yaml` in the root directory of your\n workspace.\n\n2. In the file, press `Command/Ctrl+Space` to see a list of snippet suggestions\n and then select the **Skaffold - Getting-started** snippet.\n\n3. Enter your project image name in the `image` field and enter a list of the\n Kubernetes resources to deploy in the `manifests` field.\n\n Example for Dockerfile based builds: \n\n build:\n artifacts:\n - image: image_name\n deploy:\n kubectl:\n manifests:\n - k8s/web.yaml\n - k8s/backend.yaml\n\n If you'd like to define build, test and deployment configurations for\n different contexts, you can have different Skaffold profiles. The following\n sample shows a Cloud Build profile to configure Cloud Code to\n build images with Cloud Build: \n\n profiles:\n # use the cloudbuild profile to build images using Google Cloud Build\n - name: cloudbuild\n build:\n googleCloudBuild: {}\n\n For comprehensive schema details, see\n [the skaffold.yaml reference](https://skaffold.dev/docs/references/yaml).\n\nWhat's next\n-----------\n\n- Use [file sync and hot reloading](/code/docs/shell/speed-up-k8s-development#enable-skaffold-file-sync-and-hot-reloading) to speed up development.\n- [Debug your application in Cloud Code](/code/docs/shell/debug)."]]