Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Implantar um app do Kubernetes com o Cloud Code para IntelliJ
Veja nesta página como começar a usar o Cloud Code.
Neste guia de início rápido, você irá configurar um novo aplicativo do Kubernetes usando um modelo inicial
Hello World, executar o aplicativo em um cluster de sua escolha, iniciar
a recriação contínua para desenvolver iterativamente seu aplicativo, depurar seu
código aberto e veja os registros sendo transmitidos do aplicativo.
Como alternativa, use um cluster hospedado em qualquer outra plataforma da nuvem ou em um cluster local do Kubernetes, com ferramentas como o Minikube ou o Docker Desktop.
Instale o Git para que o Cloud Code
possa realizar operações do Git, como clonar uma amostra.
O Cloud Code vem com uma coleção de modelos de
exemplo de código
para você começar rapidamente. Para criar um novo aplicativo usando uma
amostra existente:
No seu IDE, abra Arquivo e Novo projeto e selecione Cloud Code: Kubernetes.
Selecione um modelo "Hello World" na lista de aplicativos iniciais.
Escolha um nome para seu projeto.
Depois de clicar em Concluir, o Cloud Code clonará o modelo escolhido e abrirá o projeto recém-criado para uso.
Para modelos Java, você precisa importar os projetos Maven necessários para
sincronizar seu pom.xml. Clique em Adicionar como projeto Maven e em Importar
alterações.
Como escolher um cluster
Para desenvolver seu aplicativo, você precisará de um cluster do Kubernetes associado, hospedado localmente com o minikube ou uma plataforma de nuvem, como um cluster do Google Kubernetes Engine.
Cluster local
Se você ainda não tiver um cluster para usar neste guia de início rápido, poderá executar o aplicativo com um cluster minikube local gerenciado pelo Cloud Code.
O Cloud Code inicia um cluster minikube para executar seu aplicativo e o interrompe quando a implantação é interrompida. Se um cluster do minikube já estiver em execução, o Cloud Code reutilizará esse cluster para implantação.
Você pode optar por usar esse cluster do Cloud Code gerenciado pelo Cloud Code na próxima etapa, o desenvolvimento do aplicativo, definindo-o como sua preferência de implantação.
Cluster baseado no Cloud Platform
Se você já tiver um cluster configurado para trabalhar com ferramentas do Kubernetes (como o kubectl) que possam ser usadas neste guia de início rápido, o Cloud Code implantará nele automaticamente. Prossiga para o desenvolvimento do aplicativo para confirmar que o cluster de sua preferência está definido como o contexto atual.
Se não tiver, crie uma usando as instruções específicas da plataforma da nuvem. Para o GKE, siga o guia Como criar um cluster.
Desenvolver um aplicativo
Para iniciar o desenvolvimento do aplicativo no Kubernetes:
Se você tiver feito login em Google Cloud no seu ambiente de desenvolvimento integrado e tiver um
projeto padrão definido, o Cloud Code usará automaticamente o
repositório de imagens de contêiner padrão (gcr.io/{project_id}, em que {project_id}
faz referência ao projeto padrão).
Verifique se o contexto preferencial do Kubernetes está definido. Isso pode ser especificado na
configuração do Develop no Kubernetes (acessível em
Executar > Editar configurações > Desenvolver no Kubernetes). na guia "Executar"
e na seção "Preferências de implantação".
É possível implantar em um contexto atual (padrão), localmente em um
cluster minikube ou em outro contexto disponível.
Por padrão, o aplicativo Kubernetes é executado no modo sob demanda com a opção Sob demanda selecionada. Se preferir, você pode selecionar a opção Salvar no arquivo.
Escolha o destino de execução Develop on Kubernetes no seletor de configuração
Run/Debug na barra de navegação.
Isso garante que todas as alterações de código sejam criadas, enviadas e implantadas automaticamente em uma nova versão do aplicativo.
Para iniciar o ciclo de desenvolvimento no cluster do Kubernetes, clique na ação de execução
Desenvolver no Kubernetes.
Na guia Registros da janela de saída, veja os registros de aplicativos
recebidos.
Depois que a implantação for iniciada, você verá a lista de portas encaminhadas para o aplicativo implantado.
Quando a implantação for bem-sucedida, você receberá uma notificação de que novos URLs de serviço estarão disponíveis. Clique na guia URLs do serviço para visualizar os URLs e, em seguida, clique no link do URL para abrir o navegador com o aplicativo em execução.
Como alternativa, é possível abrir o Log de eventos e clicar no link para abrir o navegador com o aplicativo em execução.
O painel Recursos implantados mostra o que você implantou durante a
sessão de desenvolvimento.
Clique na ação de depuração
para Desenvolver no Kubernetes e iniciar o ciclo de desenvolvimento no modo de depuração
no cluster do Kubernetes.
O Cloud Code anexará uma sessão de depuração. Quando a operação for concluída, a
janela da ferramenta de depuração será aberta, confirmando a conexão (na guia "Console").
Agora é possível depurar no cluster ativo do Kubernetes.
Clique na divisão na linha executável do código em que você quer adicionar um ponto de interrupção.
Os círculos preenchidos em vermelho indicam pontos de interrupção ativos, enquanto os círculos vazios destacados em vermelho indicam pontos de interrupção desativados.
Quando você envia uma nova solicitação ao aplicativo, ela é interrompida nessa linha escolhida.
Para encerrar a sessão de depuração, clique no ícone de parada na configuração de execução do Develop on Kubernetes.
Como ver registros
Além de conferir uma transmissão ao vivo dos registros de pods em execução na saída do terminal
enquanto você desenvolve e executa o aplicativo, é possível conferir os registros de
um pod específico navegando até o Kubernetes Explorer.
Para ver os registros de um pod específico, siga estas etapas:
Navegue até o Kubernetes Explorer. Ele pode ser acessado no painel lateral à direita ou usando Ferramentas > Cloud Code > Kubernetes > Visualizar o Cluster Explorer.
Selecione o pod do qual você quer ver os registros.
Clique com o botão direito do mouse no pod e selecione Registros de stream. Como alternativa, é possível transmitir registros de contêineres individuais executados em pods.
Isso gera registros para o console do Kubernetes Explorer.
Limpar
Para evitar cobranças na conta do Google Cloud pelos recursos usados nesta página, siga estas etapas.
Acesse a página "Projetos" no console Google Cloud :
Selecione o projeto que você criou neste guia de início rápido e clique no ícone de lixeira ao lado para excluí-lo.
Isso encerrará o projeto e programará a remoção dele.
A seguir
Considere importar um aplicativo existente, um aplicativo do Kubernetes ou do App Engine, para o ambiente de desenvolvimento integrado e configurar o Cloud Code.
Saiba mais sobre o desenvolvimento de aplicativos do Kubernetes:
Lide com a configuração mais avançada Google Cloud e do Kubernetes com o suporte de edição YAML do Cloud Code.
Para entender melhor e gerenciar os recursos do Kubernetes, use o Kubernetes Explorer.
[[["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-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)."]]