Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
O Cloud Code usa o Skaffold em segundo plano para executar
ou depurar seu aplicativo.
Se você já tiver um aplicativo configurado com os manifestos do Kubernetes e um
Dockerfile para criar suas imagens, é possível abri-lo e usá-lo com o Cloud Code.
A única configuração extra necessária é uma configuração de skaffold e uma configuração de inicialização
do tipo cloudcode.kubernetes. O Cloud Code ajuda você a criá-los
ao executar ou depurar seu aplicativo pela primeira vez.
Como definir a configuração
Se o aplicativo tiver um Dockerfile, mas não tiver as configurações necessárias do Skaffold e
de inicialização, conclua as seguintes etapas:
Na barra de status do Cloud Code, clique no nome do projeto ativo.
No menu "Escolha rápida" que aparece, selecione Run on Kubernetes ou Debug
on Kubernetes.
Na caixa de diálogo Executar/Depurar no Kubernetes, especifique o builder e as configurações dele. Também é possível personalizar o nome da configuração.
Clique em Depurar ou Executar.
A configuração de inicialização skaffold.yaml e
cloudcode.kubernetes recém-criada é adicionada ao espaço de trabalho, e
o app é executado ou fica pronto para depuração.
Definição de configuração para aplicativos que já têm skaffold.yaml
Se o aplicativo já tiver um arquivo skaffold.yaml, siga estas etapas:
Na barra de status do Cloud Code, clique no nome do projeto ativo.
No menu "Escolha rápida" que aparece, selecione Run on Kubernetes ou Debug
on Kubernetes.
Se houver mais de um arquivo skaffold.yaml no seu espaço de trabalho, selecione o
arquivo skaffold.yaml de sua preferência.
Se houver mais de um
perfil do Skaffold no
arquivo skaffold.yaml escolhido, selecione o perfil preferido do Skaffold.
A configuração de inicialização cloudcode.kubernetes recém-criada é adicionada ao espaço de trabalho (em .vscode/launch.json), e o app está em execução ou pronto para depuração.
Como criar manualmente uma configuração do Skaffold
Talvez você queira criar manualmente sua configuração do Skaffold para definir opções personalizadas. O Cloud Code vem com modelos ativos para oferecer compatibilidade
com a criação manual de configurações do Skaffold
Para criar manualmente uma configuração do Skaffold:
Crie um novo arquivo chamado skaffold.yaml no diretório raiz do seu
espaço de trabalho.
No arquivo, pressione Command/Ctrl+Space para ver uma lista de sugestões de snippets e, em seguida, selecione o snippet Skaffold - Primeiros passos.
Digite o nome da imagem do projeto no campo image e uma lista de recursos do Kubernetes a serem implantados no campo manifests.
Se você quiser definir configurações de compilação, teste e implantação para diferentes contextos, é possível ter perfis diferentes do Skaffold. A amostra a seguir mostra um perfil do Cloud Build para configurar o Cloud Code para criar imagens com o Cloud Build:
profiles:
# use the cloudbuild profile to build images using Google Cloud Build
- name: cloudbuild
build:
googleCloudBuild: {}
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 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)."]]