Get started with Cloud Code for Cloud Shell for Kubernetes

Cloud Code lets you create a Kubernetes application based on asample or from an existing project.

Create an application from a template

Cloud Code comes with a collection ofcode sampletemplates to get you started quickly. To create a Kubernetes application usingan existing sample, follow these steps:

  1. Launch the Command Palette (pressCtrl/Cmd+Shift+P or clickView >Command Palette) and then runCloud Code: New Application.
  2. SelectKubernetes application for the type of sample.
  3. Select a sample based on the language you'd like to use from the availableoptions: NodeJS, Go, Python, Java.
  4. Choose a preferred application location on your local machine and then clickCreate new application to save.

    Cloud Code clones the sample you chose and opens your newproject for use.

Use your own application

For steps to use an existing project, seeuse Cloud Code with an existing Kubernetes application.

Note: For developing and testing an app, create and run the application on a non-production cluster.
For changes that will be rolled out to production, use an
automated CI/CD workflow.

Set your Kubernetes context

Before running your application, ensure you're set up to deploy your app toyour preferred Kubernetes context. You can specify this in yourconfiguration.

Configuration

When using theCloud Code: Develop on Kubernetes run configuration, you cancustomize your deployment by configuring available settings.

To add or edit configurations, go toRun >Open Configurations and thenedit or add configurations.

Build settings

Cloud Code supports Docker, Jib, and Buildpacks artifact types.Refer to theConfiguring container image build preferences guideto learn about how to set your preferred builder and its relevant settings.

Customize your launch configuration

To configure how your application is run, you can customize yourskaffold.yaml file.

For more information on customizing your launch configuration, see theKubernetes in Cloud Code.

Note: Cloud Code is built to work withCloud Build. To build an existing application usingGoogle Cloud infrastructure, see theSkaffold docs for Cloud Build.

Run your application

Once you have an application set up, you can run it on a Kubernetes cluster andview it live, by leveragingskaffold dev.You can run your application on a local cluster (like minikube or DockerDesktop), Google Kubernetes Engine, or any other Cloud provider.

Note: If you're working with a private Autopilot cluster, you might run into animage pull error when pulling an image outside of the image registryfor your project, such as by using Docker Hub. To resolve this issue, you caneither host the image onArtifact Registry or provideoutbound internet access for your private nodes.
  1. Open the Command Palette (pressCtrl/Cmd+Shift+P) and then run theCloud Code: Run on Kubernetes command.
  2. Confirm whether to use the currentKubernetes contextto run the app in (or switch to a preferred one). For more information aboutsetting up a Kubernetes context, seesetting up configuration.
  3. If you chose a remote cluster as the context, when prompted, choose an imageregistry to push the images to. If your project hasArtifact Registry API enabled and at least oneArtifact Registry repository, you canbrowse to and select an existing Artifact Registry repository.

    The following samples demonstrate how to specify where container images arestored for some common registries:

    Artifact RegistryREGION-docker.pkg.dev/PROJECT_ID/REPO_NAME
    Docker Hubdocker.io/ACCOUNT
    Make sure that you'reproperly authenticated if you're using a private Docker Hub repository.

    Cloud Code concatenates this image registry with the image namespecified in the Kubernetes manifests to generate the final image repositoryname.

    For more information, see theimage registry handling guide.

    This choice is stored in yourcloudcode.kubernetes launch configuration(found in .vscode/launch.json).

    Cloud Code builds your containers, pushes them to the registry,applies Kubernetes configurations to the cluster, and waits for the rollout.

View logs

In addition to seeing logs from running pods as a live stream in the terminaloutput as you're developing and running your application, you can view logs froma specific pod by navigating to the Kubernetes Explorer.

To view logs from a specific pod, follow these steps:

  1. In the Kubernetes Explorer, expandDeployments
  2. Right-click the pod you'd like to see logs from, and then clickView Logs.

    TheLogs viewer opens.

Make changes, rebuild, and clean up

If you've set watch mode tofalse in your launch configuration and you want tomake changes to your application and then rebuild and redeploy the application:

  1. Make and Save your changes.

  2. In the Debug Toolbar, clickPause (F6) and then clickRestart (Ctrl/Cmd + Shift + F5) to rebuild and redeploy theapplication.

  3. To stop running the application, in the Debug Toolbar, clickStop.

After you stop the application, all deployed Kubernetes resources are deleted from the cluster. You can change this behavior using thecleanUp flag in your launch configuration.

Store secrets

If your code includes potentially sensitive data like API keys, passwords, andcertificates, it is recommended you store them as secrets. WithCloud Code, you can securely store these secrets inSecret Manager and programmatically fetch them when you need them.

For a detailed look at how you can create and manage secrets withCloud Code, see theSecret Manager guide.

View resource details

The Kubernetes Explorer displays clusters, namespaces, nodes, workloads(such as deployments, replicasets, pods and containers), services and ingresses,configurations (such as secrets and config maps) and storage (such as volumes).Using the Kubernetes Explorer, you can perform unique actions on someof these resources.

See theKubernetes overview for moreinformation on viewing resource details.

What's next

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-15 UTC.