Si desarrollas aplicaciones para que se ejecuten en Google Kubernetes Engine, puedes usar un IDE y el complemento de Cloud Code para simplificar las tareas clave de desarrollo, como las pruebas y la depuración locales, y las implementaciones en una prueba clúster.
Objetivos
Aprende a realizar las siguientes tareas de desarrollo en el editor de Cloud Shell, un IDE de demostración en línea:
Crear una app de ejemplo de Kubernetes
Ejecuta, actualiza y visualiza los registros de la app en tu entorno de desarrollo.
Para generar una estimación de costos en función del uso previsto, usa la calculadora de precios.
Es posible que los usuarios nuevos de Google Cloud califiquen para obtener una prueba gratuita.
Cuando finalices las tareas que se describen en este documento, puedes borrar los recursos que creaste para evitar que continúe la facturación. Para obtener más información, consulta Cómo realizar una limpieza.
En la consola de Google Cloud, haz clic en terminalCloud Shell en la barra de tareas para abrir Cloud Shell.
Haz clic en Abrir editor.
Espera a que se inicialice el Editor de Cloud Shell.
En el Editor de Cloud Shell, haz clic en Ver > Paleta de comandos.
Busca la opción Cloud Code: Aplicación nueva y haz clic en ella.
Selecciona Aplicación de Kubernetes y, luego, Go: Hello World.
Cada framework de lenguaje proporciona experiencias un poco diferentes, y en este instructivo, se describen las funciones disponibles para Go.
En el diálogo Guardar, haz clic en Crear aplicación nueva.
El Editor de Cloud Shell vuelve a cargar y muestra los archivos fuente de tu app en la vista del Explorador.
La app incluye los siguientes archivos:
Una app web go-hello-world básica, main.go, que muestra una respuesta de plantilla “It's running!” para todas las solicitudes recibidas.
Una especificación de Deployment de Kubernetes, hello.deployment.yaml.
Una especificación de Service de Kubernetes que define un balanceador de cargas para la app, hello.service.yaml.
Un archivo Skaffold que controla el flujo de trabajo para compilar e implementar la app, skaffold.yaml.
Prueba la app en tu entorno de desarrollo
Cuando sea posible, ejecuta apps en tu entorno de desarrollo antes de implementarlas en GKE. Esto puede ayudarte a identificar cualquier problema potencial sin usar la cuota de Google Cloud.
Para ejecutar la app en tu entorno del editor de Cloud Shell, haz lo siguiente:
En el Editor de Cloud Shell, haz clic en Terminal > Nueva terminal.
Inicia un clúster ejecutando el siguiente comando:
minikubestart
minikube es una implementación básica de Kubernetes que crea una VM en su entorno local y, además, implementa un clúster simple que contiene solo un nodo.
La configuración del clúster de minikube puede tardar un minuto.
Si se te solicita que autorices a Cloud Shell a realizar llamadas a la API de Cloud,
haz clic en Autorizar.
Después de configurar tu clúster, aparecerá un mensaje similar al siguiente:
Done! kubectl is now configured touse "minikube" cluster...
Después de configurar minikube, compila y ejecuta tu app:
En la barra de estado del editor de Cloud Shell, haz clic en Cloud Code.
Selecciona Ejecutar en Kubernetes.
Si se te solicita, confirma que quieres usar el contexto actual de minikube.
El Editor de Cloud Shell compila tu app y la implementa en el clúster de minikube.
Mira el estado de la implementación en la vista Sesiones de desarrollo.
Cuando se complete la implementación, aparecerá una marca de verificación verde junto a URL de redirección de puertos. El ícono giratorio aparece junto a Transmitir registros de aplicaciones.
Para ver tu app, mira más abajo en el panel Sesiones de desarrollo y busca URL de redirección de puertos > service.
Mantén el puntero sobre go-hello-world-external y haz clic en open_in_newgo-hello-world-external.
Edita tu app
Cuando cambias un archivo de origen en tu app, el Editor de Cloud Shell compila e implementa automáticamente tu app en el clúster al que estás conectado en ese momento.
En este caso, se conectó a su clúster de minikube.
Para editar y volver a implementar la app en el clúster de minikube local, sigue estos pasos:
Modifica el archivo
main.go
para que muestre el mensaje “It's redeployed!”. El archivo se guardará automáticamente.
Mira la vista Sesiones de desarrollo mientras se vuelve a compilar e implementar tu app.
Visualiza la app que se volvió a implementar como lo hiciste antes:
En el panel Sesiones de desarrollo, busca URL de redirección de puertos > service.
Mantén el puntero sobre go-hello-world-external y haz clic en open_in_newgo-hello-world-external.
Consulta los registros de la app
En la barra de menú del Editor de Cloud Shell, selecciona Vista > Paleta de comandos.
Busca la opción Cloud Code: Ver registros y haz clic en ella.
Se abrirá el Visor de registros.
En Deployment, selecciona go-hello-world.
Esto filtra el Visor de registros para mostrar solo los registros de la app de go-hello-world.
Cambia a la pestaña de la app en la que se muestra el mensaje “It's redeployed!”. Vuelve a cargar
la página en el navegador y, luego, regresa a la pestaña de Cloud Shell.
Para ver los registros generados recientemente en el Visor de registros, haz clic en refreshActualizar.
Implementa la app en un clúster de GKE
Agrega tu clúster de GKE a la lista de clústeres en los que puedes implementar:
En la vista Kubernetes, haz clic en addAgregar un clúster a KubeConfig.
En el diálogo Choose a platform, haz clic en Google Kubernetes Engine.
Si se te solicita habilitar la API de Google Cloud, haz clic en Sí.
Espera a que el editor de Cloud Shell encuentre los clústeres en tu proyecto de Google Cloud.
En el cuadro de diálogo Crear o elegir un clúster de GKE, selecciona el nombre del clúster que creaste, hello-world-cluster.
En la barra de estado del editor de Cloud Shell, haz clic en Cloud Code y selecciona Ejecutar en Kubernetes.
Cuando se te solicite seleccionar un contexto para tu solicitud de implementación, elige Usar el contexto actual, que se establece como tu clúster de GKE.
En el diálogo Elige tu repositorio, selecciona gcr.io/PROJECT_NAME.
El Editor de Cloud Shell compila tu app en un contenedor y lo almacena en el repositorio que seleccionaste.
Mira la vista Sesiones de desarrollo mientras se vuelve a compilar e implementar tu app.
Para ver los mensajes de registro detallados a medida que se implementa tu app en GKE, haz clic en el nodo Implementar en clúster en la vista Sesiones de desarrollo.
Para ver la app en ejecución, haz lo siguiente:
Haz clic en el encabezado Sesiones de desarrollo para cerrar la vista.
Abre la vista Kubernetes.
Expande tu clúster de GKE.
Ve a Espacios de nombres > predeterminado > Services > go-hello-world-external > IP externas.
Mantén el puntero sobre la dirección IP y haz clic en open_in_newAbrir URL.
Creaste e implementaste correctamente una app de GKE desde un IDE.
Realiza una limpieza para evitar cargos de facturación
Si planeas realizar instructivos adicionales, espera hasta terminarlos antes de realizar una limpieza. Puedes usar el clúster de Kubernetes de muestra en la mayoría de los instructivos de GKE.
[[["Fácil de comprender","easyToUnderstand","thumb-up"],["Resolvió mi problema","solvedMyProblem","thumb-up"],["Otro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Información o código de muestra incorrectos","incorrectInformationOrSampleCode","thumb-down"],["Faltan la información o los ejemplos que necesito","missingTheInformationSamplesINeed","thumb-down"],["Problema de traducción","translationIssue","thumb-down"],["Otro","otherDown","thumb-down"]],["Última actualización: 2025-07-30 (UTC)"],[],[],null,["# Deploy and update from an IDE\n\n[Autopilot](/kubernetes-engine/docs/concepts/autopilot-overview)\n\n*** ** * ** ***\n\nIf you develop applications to run in Google Kubernetes Engine, you can use an IDE and the Cloud Code plugin to simplify key development tasks, such as testing and debugging locally and deploying to a test cluster.\n\n\u003cbr /\u003e\n\nObjectives\n----------\n\nLearn how to do the following development tasks in Cloud Shell Editor,\nan online demonstration IDE:\n\n1. Create a sample Kubernetes app.\n\n2. Run, update, and view logs for the app in your development environment.\n\n3. Deploy the app to a GKE cluster.\n\nYou can follow a similar process in your own IDE if you\n[install Cloud Code](/code/docs).\n\n*** ** * ** ***\n\nTo follow step-by-step guidance for this task directly in the\nGoogle Cloud console, click **Guide me**:\n\n[Guide me](https://console.cloud.google.com/freetrial?redirectPath=/kubernetes/list/overview?walkthrough_id=kubernetes--developer-workflow)\n\n*** ** * ** ***\n\nCosts\n-----\n\n\nIn this document, you use the following billable components of Google Cloud:\n\n\n- [GKE](/kubernetes-engine/pricing)\n\n\nTo generate a cost estimate based on your projected usage,\nuse the [pricing calculator](/products/calculator). \nNew Google Cloud users might be eligible for a [free trial](/free). \n\n\u003cbr /\u003e\n\nWhen you finish the tasks that are described in this document, you can avoid\ncontinued billing by deleting the resources that you created. For more information, see\n[Clean up](#clean-up).\n\nBefore you begin\n----------------\n\nCreate a Kubernetes cluster.\n[Create a cluster and deploy a workload](/kubernetes-engine/docs/quickstarts/create-cluster)\nshows you how. \n\nChoose a Google Cloud project and cluster\n-----------------------------------------\n\nWhen you deploy your app to GKE later on in this tutorial, you\nwill need to specify a Google Cloud project and a GKE cluster.\n\n1. Go to the GKE **Clusters** page.\n\n\n [Go to Clusters](https://console.cloud.google.com/kubernetes/list/overview)\n\n \u003cbr /\u003e\n\n2. Choose a project that contains a GKE cluster.\n\n \u003cbr /\u003e\n\n3. Note the name of the project and cluster.\n\n You'll need this information later.\n\nCreate an app in Cloud Shell Editor\n-----------------------------------\n\n1. In the Google Cloud console, open Cloud Shell\n by clicking terminal**Cloud Shell**\n in the task bar.\n\n2. Click\n **Open\n Editor**.\n\n3. Wait for Cloud Shell Editor to initialize.\n\n4. In Cloud Shell Editor, click **View** \\\u003e **Command Palette**.\n\n5. Search for **Cloud Code: New Application** and click it.\n\n6. Select **Kubernetes Application** , then select **Go: Hello World**.\n\n Each language framework provides slightly different experiences, and this\n tutorial describes the features available for Go.\n7. In the Save dialog, click **Create new application**.\n\n Cloud Shell Editor reloads and shows your app source files in the Explorer\n view.\n\nThe app consists of:\n\n- A basic `go-hello-world` web app,\n `main.go`,\n that returns a templated \"It's running!\" response to all received requests.\n\n- A Kubernetes Deployment specification,\n `hello.deployment.yaml`.\n\n- A Kubernetes Service specification that defines a load balancer for the app,\n `hello.service.yaml`.\n\n- A [Skaffold](https://skaffold.dev/) file that handles the workflow for\n building and deploying the app, `skaffold.yaml`.\n\nRun the app in your development environment\n-------------------------------------------\n\nWhen possible, run apps in your development environment before deploying\nto GKE. This can help you identify any potential issues without\nusing Google Cloud quota.\n\nTo run the app in your Cloud Shell Editor environment:\n\n1. In Cloud Shell Editor, click **Terminal** \\\u003e **New Terminal**.\n\n2. Start a cluster by running the following command:\n\n minikube start\n\n *minikube* is a lightweight Kubernetes implementation that creates a VM in\n your local environment and deploys a simple cluster containing only one node.\n\n It might take a minute to set up the minikube cluster.\n3. If prompted to authorize Cloud Shell to make Cloud API calls,\n click **Authorize**.\n\n After your minikube cluster is set up, a message similar to the following\n appears: \n\n Done! kubectl is now configured to\n use \"minikube\" cluster...\n\nAfter minikube is set up, build and run your app:\n\n1. In the Cloud Shell Editor status bar, click\n **Cloud\n Code**.\n\n2. Select **Run on Kubernetes**.\n\n3. If prompted, confirm that you want to use the current minikube context.\n\n Cloud Shell Editor builds your app and deploys it to the minikube cluster.\n4. Watch the deployment status in the\n **Development\n sessions** view.\n\n When the deployment is complete, a green check mark appears next to\n **Portforward URLs** . The spinning icon appears next to\n **Stream Application Logs**.\n5. To view your app, look further down the **Development sessions**\n pane and find **Port Forward URLs** \\\u003e **service**.\n\n6. Hold the pointer over\n **go-hello-world-external**\n and click open_in_new **Open URL**.\n\nEdit your app\n-------------\n\nWhen you change a source file in your app, Cloud Shell Editor automatically\nbuilds and deploys your app to the cluster that you're currently connected to.\nIn this case, you're connected to your minikube cluster.\n\nTo edit and redeploy the app to your local minikube cluster:\n\n1. Modify your\n `main.go`\n file to print \"It's redeployed!\". The file saves automatically.\n\n2. Watch the\n **Development\n sessions** view as your app is rebuilt and\n deployed.\n\n3. View your redeployed app as you did before:\n\n 1. In the **Development sessions**\n pane, find **Port Forward URLs** \\\u003e **service**.\n\n 2. Hold the pointer over\n **go-hello-world-external**\n and click open_in_new **Open URL**.\n\nView app logs\n-------------\n\n1. In the Cloud Shell Editor menu bar, select **View** \\\u003e **Command Palette**.\n\n2. Search for **Cloud Code: View Logs** and click it.\n\n The Logs Viewer opens.\n3. In\n **Deployment**,\n select `go-hello-world`.\n\n This filters the Logs Viewer to only display logs for your `go-hello-world` app.\n4. Switch to the tab with your app that shows \"It's redeployed!\" Reload the\n page in the browser and then switch back to the Cloud Shell tab.\n\n5. To view the newly generated logs in the Logs Viewer, click\n refresh\n **Refresh**.\n\nDeploy your app to a GKE cluster\n--------------------------------\n\n1. Add your GKE cluster to the list of clusters you can\n deploy to:\n\n 1. In the Kubernetes\n view, click add\n **Add a Cluster to the KubeConfig**.\n\n 2. In the **Choose a platform** dialog, click **Google Kubernetes Engine**.\n\n 3. If prompted to enable the Google Cloud API, click **Yes**.\n\n 4. Wait for Cloud Shell Editor to find the clusters in your\n Google Cloud project.\n\n 5. In the **Create or choose a GKE cluster** dialog, select\n the name of the cluster you created, **hello-world-cluster**.\n\n2. In the Cloud Shell Editor status bar, click\n **Cloud\n Code** and select **Run on Kubernetes**.\n\n3. When prompted to select a context for your deployment request, choose\n **Use current context**, which is set to your GKE cluster.\n\n4. In the **Choose image repository** dialog, select **gcr.io/\u003cvar translate=\"no\"\u003ePROJECT_NAME\u003c/var\u003e**.\n\n Cloud Shell Editor builds your app into a container and stores the container\n in the repository you selected.\n5. Watch the\n **Development\n sessions** view as your app is rebuilt and\n deployed.\n\n6. To view detailed log messages as your app is being deployed to GKE,\n click the **Deploy to Cluster** node in the **Development sessions** view.\n\n7. To view your running app:\n\n 1. Close the view by clicking the **Development sessions** heading.\n\n 2. Open the Kubernetes\n view.\n\n 3. Expand your GKE cluster.\n\n 4. Go to **Namespaces \\\u003e default \\\u003e Services \\\u003e go-hello-world-external \\\u003e External IPs**.\n\n 5. Hold the pointer over the IP address and click\n open_in_new **Open URL**.\n\nYou have successfully created and deployed a GKE app from an IDE.\n\nWhat's next\n-----------\n\n- [View code samples](/docs/samples) demonstrating the usage of\n Google Cloud products\n\n- [Install Cloud Code](/code/docs) in your IDE\n\n- [Clean up to avoid billing charges](/kubernetes-engine/docs/quickstarts/learning-path-cleanup).\n If you plan to take additional tutorials, wait until you finish those tutorials\n before you clean up. You can use the sample Kubernetes cluster in most\n GKE tutorials."]]