[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-09-04。"],[[["\u003cp\u003eCloud Code facilitates the creation of Kubernetes applications from existing templates or projects, offering a quick start with sample code.\u003c/p\u003e\n"],["\u003cp\u003eUsers can configure their Kubernetes deployment by customizing build settings, launch configurations, and selecting their preferred artifact type like Docker, Jib, or Buildpacks.\u003c/p\u003e\n"],["\u003cp\u003eCloud Code allows running applications on various Kubernetes environments, such as local clusters, Google Kubernetes Engine, or other cloud providers, via the \u003ccode\u003eskaffold dev\u003c/code\u003e workflow.\u003c/p\u003e\n"],["\u003cp\u003eCloud Code provides tools for managing secrets via Secret Manager, and monitoring application health and logs via the Kubernetes Explorer.\u003c/p\u003e\n"],["\u003cp\u003eIt's possible to make changes to your application and then rebuild and redeploy it by using the \u003cstrong\u003ePause\u003c/strong\u003e and then \u003cstrong\u003eRestart\u003c/strong\u003e options available on the Debug Toolbar.\u003c/p\u003e\n"]]],[],null,["# Get started with Cloud Code for Cloud Shell for Kubernetes\n\nCloud Code lets you create a Kubernetes application based on a\nsample or from an existing project.\n\nCreate an application from a template\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 Kubernetes application using\nan existing sample, follow these steps:\n\n1. Launch the Command Palette (press `Ctrl`/`Cmd`+`Shift`+`P` or click **View** \\\u003e **Command Palette** ) and then run **Cloud Code: New Application**.\n2. Select **Kubernetes application** for the type of sample.\n3. Select a sample based on the language you'd like to use from the available options: NodeJS, Go, Python, Java.\n4. Choose a preferred application location on your local machine and then click\n **Create new application** to save.\n\n Cloud Code clones the sample you chose and opens your new\n project for use.\n\nUse your own application\n------------------------\n\nFor steps to use an existing project, see\n[use Cloud Code with an existing Kubernetes application](/code/docs/shell/use-existing-app).\n| **Note:** For developing and testing an app, create and run the application on a non-production cluster. \n| For changes that will be rolled out to production, use an [automated CI/CD workflow](/docs/ci-cd).\n\nSet your Kubernetes context\n---------------------------\n\nBefore running your application, ensure you're set up to deploy your app to\nyour preferred Kubernetes context. You can specify this in your\n[configuration](#configuration).\n\nConfiguration\n-------------\n\nWhen using the **Cloud Code: Develop on Kubernetes** run configuration, you can\ncustomize your deployment by configuring available settings.\nTo add or edit configurations, go to **Run** \\\u003e **Open Configurations** and then edit or add configurations.\n\nBuild settings\n--------------\n\nCloud Code supports Docker, Jib, and Buildpacks artifact types.\nRefer to the [Configuring container image build preferences guide](/code/docs/shell/image-build-settings)\nto learn about how to set your preferred builder and its relevant settings.\n\nCustomize your launch configuration\n-----------------------------------\n\nTo configure how your application is run, you can customize your\n[`skaffold.yaml`](https://skaffold.dev/docs/references/yaml) file.\n\nFor more information on customizing your launch configuration, see the\n[Kubernetes in Cloud Code](/code/docs/shell/k8s-overview#customize_your_launch_configuration).\n| **Note:** Cloud Code is built to work with [Cloud Build](/build/docs). To build an existing application using Google Cloud infrastructure, see the [Skaffold docs for Cloud Build](https://skaffold.dev/docs/pipeline-stages/builders/docker/#dockerfile-remotely-with-google-cloud-build).\n\nRun your application\n--------------------\n\nOnce you have an application set up, you can run it on a Kubernetes cluster and\nview it live, by leveraging\n[`skaffold dev`](https://skaffold.dev/docs/workflows/dev).\nYou can run your application on a local cluster (like minikube or Docker\nDesktop), Google Kubernetes Engine, or any other Cloud provider.\n| **Note:** If you're working with a private Autopilot cluster, you might run into an image pull error when pulling an image outside of the image registry for your project, such as by using Docker Hub. To resolve this issue, you can either host the image on [Artifact Registry](/artifact-registry/docs/docker/pushing-and-pulling) or provide [outbound internet access for your private nodes](/nat/docs/gke-example#create-nat).\n\n1. Open the Command Palette (press `Ctrl`/`Cmd`+`Shift`+`P`) and then run the **Cloud Code: Run on Kubernetes** command.\n2. Confirm whether to use the current [Kubernetes context](https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/#context) to run the app in (or switch to a preferred one). For more information about setting up a Kubernetes context, see [setting up configuration](/code/docs/vscode/use-existing-app#setting_up_configuration).\n3. If you chose a remote cluster as the context, when prompted, choose an image\n registry to push the images to. If your project has\n [Artifact Registry API enabled](/artifact-registry/docs/enable-service) and at least one\n [Artifact Registry repository](/artifact-registry/docs/manage-repos), you can\n browse to and select an existing Artifact Registry repository.\n\n The following samples demonstrate how to specify where container images are\n stored for some common registries:\n\n \u003cbr /\u003e\n\n \u003cbr /\u003e\n\n \u003cbr /\u003e\n\n Cloud Code concatenates this image registry with the image name\n specified in the Kubernetes manifests to generate the final image repository\n name.\n\n For more information, see the\n [image registry handling guide](https://skaffold.dev/docs/environment/image-registries).\n\n This choice is stored in your `cloudcode.kubernetes` launch configuration\n (found in .vscode/launch.json).\n\n Cloud Code builds your containers, pushes them to the registry,\n applies Kubernetes configurations to the cluster, and waits for the rollout.\n\nView logs\n---------\n\nIn addition to seeing logs from running pods as a live stream 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. In the Kubernetes Explorer, expand **Deployments**\n2. Right-click the pod you'd like to see logs from, and then click\n **View Logs**.\n\n The **Logs viewer** opens.\n\nMake changes, rebuild, and clean up\n-----------------------------------\n\nIf you've set watch mode to `false` in your launch configuration and you want to make changes to your application and then rebuild and redeploy the application:\n\n\u003cbr /\u003e\n\n1. Make and Save your changes.\n\n2. In the Debug Toolbar, click **Pause** (`F6`) and then click\n **Restart** (`Ctrl/Cmd + Shift + F5`) to rebuild and redeploy the\n application.\n\n3. To stop running the application, in the Debug Toolbar, click **Stop**.\n\nAfter you stop the application, all deployed Kubernetes resources are\ndeleted from the cluster. You can change this behavior using the `cleanUp`\nflag in your launch configuration.\n\nStore secrets\n-------------\n\nIf your code includes potentially sensitive data like API keys, passwords, and\ncertificates, it is recommended you store them as secrets. With\nCloud Code, you can securely store these secrets in\nSecret Manager and programmatically fetch them when you need them.\n\nFor a detailed look at how you can create and manage secrets with\nCloud Code, see the\n[Secret Manager guide](/code/docs/shell/secret-manager).\n\nView resource details\n---------------------\n\nThe Kubernetes Explorer displays clusters, namespaces, nodes, workloads\n(such as deployments, replicasets, pods and containers), services and ingresses,\nconfigurations (such as secrets and config maps) and storage (such as volumes).\nUsing the Kubernetes Explorer, you can perform unique actions on some\nof these resources.\n\nSee the [Kubernetes overview](/code/docs/shell/k8s-overview#resource-specific_actions) for more\ninformation on viewing resource details.\n\nWhat's next\n-----------\n\n- [Explore your build options with buildpacks, Jib, or Docker](/code/docs/shell/image-build-settings).\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- Learn more about Cloud Code's [YAML editing](/code/docs/shell/yaml-editing) assistance."]]