[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["わかりにくい","hardToUnderstand","thumb-down"],["情報またはサンプルコードが不正確","incorrectInformationOrSampleCode","thumb-down"],["必要な情報 / サンプルがない","missingTheInformationSamplesINeed","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-02-17 UTC。"],[[["\u003cp\u003eCloud Code facilitates the creation of Kubernetes applications from existing templates or projects, offering a quick start with samples in languages like NodeJS, Go, Python, and Java.\u003c/p\u003e\n"],["\u003cp\u003eThe structure of sample applications includes key files like \u003ccode\u003elaunch.json\u003c/code\u003e for running/debugging, deployment YAML files in \u003ccode\u003ekubernetes-manifests\u003c/code\u003e, source code with \u003ccode\u003eDockerfiles\u003c/code\u003e in \u003ccode\u003esrc\u003c/code\u003e, and the \u003ccode\u003eskaffold.yaml\u003c/code\u003e for build and deployment configurations.\u003c/p\u003e\n"],["\u003cp\u003eCloud Code allows customization of the Kubernetes deployment through the \u003ccode\u003ecloudcode.kubernetes\u003c/code\u003e configuration, where users can define settings for build processes, such as using Docker, Jib, or Buildpacks, and configure the \u003ccode\u003eskaffold.yaml\u003c/code\u003e for application launches.\u003c/p\u003e\n"],["\u003cp\u003eApplications can be run on various Kubernetes clusters, including local setups and cloud-based services, with Cloud Code handling container building, pushing to a designated registry, and deploying configurations to the cluster.\u003c/p\u003e\n"],["\u003cp\u003eUsers can observe live logs directly in the terminal and access specific pod logs via the Kubernetes section, and also includes features for handling secret data, making changes, rebuilding the application, as well as viewing resource details in the Kubernetes section.\u003c/p\u003e\n"]]],[],null,["# Get started with Cloud Code for VS Code 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\n### Sample application structure\n\nAll language sample applications have nearly the same structure. This\nis not the only supported structure but is recommended when starting.\n\nFor example, the Node.js Guestbook application structure looks like: \n\n .\n |---- .vscode\n | └---- launch.json\n |---- kubernetes-manifests\n | |---- guestbook-backend.deployment.yaml\n | |---- guestbook-backend.service.yaml\n | |---- guestbook-frontend.deployment.yaml\n | |---- guestbook-frontend.service.yaml\n | |---- mongo.deployment.yaml\n | └---- mongo.service.yaml\n |---- src\n | |---- backend\n | | |---- Dockerfile\n | | |---- index.js\n | | |---- app.js\n | | └---- package.json\n | |---- frontend\n | |---- Dockerfile\n | |---- index.js\n | | |---- app.js\n | └---- package.json\n └---- skaffold.yaml\n\nTaking a closer look at this Kubernetes Guestbook Node.js sample app, here are\nsome key files and their uses:\n\n- .vscode\n - `extensions.json`: prompt requesting download of related extensions when opening this project\n - `launch.json`: launch configuration (of type `cloudcode.kubernetes`) to run or debug the Kubernetes application\n - `tasks.json`: configuration information for [Visual Studio Code Tasks](https://code.visualstudio.com/docs/editor/tasks)\n- kubernetes-manifests\n - `guestbook-backend.deployment.yaml`: Pod specification for the backend nodes\n - `guestbook-frontend.deployment.yaml`: Pod specification for the frontend nodes\n - `mongo.deployment.yaml`: Pod specification for the database\n- src\n - `(backend|frontend)/app.js`: Node.js code with the web server logic\n - `(backend|frontend)/Dockerfile`: used to build the container image for our program\n- `skaffold.yaml`: config file for [Skaffold](/skaffold), which Cloud Code uses to build, deploy and debug Kubernetes applications\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/vscode/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/vscode/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\nYou can also configure your launch by editing the `cloudcode.kubernetes`\nconfiguration in your `.vscode/launch.json` file.\n\nFor more information on customizing your launch configuration, see the\n[Kubernetes in Cloud Code](/code/docs/vscode/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 \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 section.\n\nTo view logs from a specific pod, follow these steps:\n\n1. In the Kubernetes section, 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/vscode/secret-manager).\n\nView resource details\n---------------------\n\nThe Kubernetes section 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 section, you can perform unique actions on some\nof these resources.\n\nSee the [Kubernetes overview](/code/docs/vscode/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/vscode/image-build-settings).\n- Use [file sync and hot reloading](/code/docs/vscode/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/vscode/yaml-editing) assistance.\n\nGet Support\n-----------\n\nTo send feedback, report issues on [GitHub](https://github.com/GoogleCloudPlatform/cloud-code-vscode/issues), or ask a question on [Stack Overflow](https://stackoverflow.com/questions/ask?tags=cloud-code-vscode)."]]