Vorhandene Anwendung in Cloud Code für Cloud Shell verwenden
Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Cloud Code nutzt Skaffold im Hintergrund, um Ihre Anwendung auszuführen oder Fehler zu beheben.
Wenn Sie schon eine Anwendung haben, die bereits mit Kubernetes-Manifesten und einem Dockerfile zum Erstellen Ihrer Images konfiguriert ist, können Sie diese mit Cloud Code öffnen und verwenden.
Die einzige zusätzliche Konfiguration ist eine Skaffold-Konfiguration und eine Startkonfiguration vom Typ cloudcode.kubernetes. Cloud Code führt Sie durch die Erstellung dieser Anwendung, wenn Sie die Anwendung zum ersten Mal ausführen oder Fehler beheben.
Konfiguration einrichten
Wenn Ihre Anwendung ein Dockerfile hat, aber nicht die erforderlichen Skaffold- und Startkonfigurationen hat, führen Sie die folgenden Schritte aus:
Klicken Sie in der Cloud Code-Statusleiste auf den Namen des aktiven Projekts.
Wählen Sie im angezeigten Menü „Schnellauswahl“ die Option In Kubernetes ausführen oder In Kubernetes debuggen aus.
Geben Sie im Dialogfeld "Run/Debug on Kubernetes" (Ausführung/Fehlerbehebung in Kubernetes) Ihren bevorzugten Builder und dessen Einstellungen an. Sie können den Konfigurationsnamen auch anpassen.
Klicken Sie auf Debuggen oder Ausführen.
Die neu erstellte skaffold.yaml- und cloudcode.kubernetes-Startkonfiguration werden Ihrem Arbeitsbereich hinzugefügt und Ihre Anwendung wird ausgeführt oder sie ist bereit für das Debugging.
Konfiguration für Anwendungen einrichten, die bereits skaffold.yaml haben
Wenn Ihre Anwendung bereits eine skaffold.yaml-Datei hat, gehen Sie so vor:
Klicken Sie in der Cloud Code-Statusleiste auf den Namen des aktiven Projekts.
Wählen Sie im angezeigten Menü „Schnellauswahl“ die Option In Kubernetes ausführen oder In Kubernetes debuggen aus.
Wenn in Ihrem Arbeitsbereich mehrere Dateien skaffold.yaml vorhanden sind, wählen Sie Ihre bevorzugte Datei skaffold.yaml aus.
Wenn in der ausgewählten Datei skaffold.yaml mehrere Skaffold-Profile vorhanden sind, wählen Sie Ihr bevorzugtes Skaffold-Profil aus.
Die neu erstellte cloudcode.kubernetes Startkonfiguration wird Ihrem Arbeitsbereich (in .vscode/launch.json) hinzugefügt und Ihre Anwendung wird ausgeführt oder sie ist bereit für die Fehlerbehebung.
Skaffold-Konfiguration manuell erstellen
Sie können Ihre Skaffold-Konfiguration manuell erstellen, um benutzerdefinierte Optionen festzulegen. Cloud Code enthält Live-Vorlagen, um die manuelle Erstellung von Skaffold zu unterstützen.
So erstellen Sie eine Skaffold-Konfiguration manuell:
Erstellen Sie im Stammverzeichnis Ihres Arbeitsbereichs eine neue Datei mit dem Namen skaffold.yaml.
Drücken Sie Command/Ctrl+Space in der Datei, um eine Liste mit Snippet-Vorschlägen aufzurufen, und wählen Sie das Snippet Skaffold – Erste Schritte aus.
Geben Sie den Namen des Projekt-Images in das Feld image ein und geben Sie eine Liste der Kubernetes-Ressourcen ein, die im Feld manifests bereitgestellt werden sollen.
Wenn Sie Build-, Test- und Deployment-Konfigurationen für verschiedene Kontexte definieren möchten, können Sie unterschiedliche Skaffold-Profile haben. Das folgende Beispiel zeigt ein Cloud Build-Profil zum Konfigurieren von Cloud Code, um Images mit Cloud Build zu erstellen:
profiles:
# use the cloudbuild profile to build images using Google Cloud Build
- name: cloudbuild
build:
googleCloudBuild: {}
[[["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 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)."]]