Get started with Cloud Code for Cloud Shell for Kubernetes

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

Create an application from a template

Cloud Code comes with a collection of code sample templates to get you started quickly. To create a Kubernetes application using an existing sample, follow these steps:

  1. Launch the Command Palette (press Ctrl/Cmd+Shift+P or click View > Command Palette) and then run Cloud Code: New Application.
  2. Select Kubernetes application for the type of sample.
  3. Select a sample based on the language you'd like to use from the available options: NodeJS, Go, Python, Java.
  4. Choose a preferred application location on your local machine and then click Create new application to save.

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

Use your own application

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

Set your Kubernetes context

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


When using the Cloud Code: Develop on Kubernetes run configuration, you can customize your deployment by configuring available settings.

To add or edit configurations, go to Run > Open Configurations and then edit or add configurations.

Build settings

Cloud Code supports Docker, Jib, and Buildpacks artifact types. Refer to the Configuring container image build preferences guide to 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 your skaffold.yaml file.

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

Run your application

Once you have an application set up, you can run it on a Kubernetes cluster and view it live, by leveraging skaffold dev. You can run your application on a local cluster (like minikube or Docker Desktop), Google Kubernetes Engine, or any other Cloud provider.

  1. Open the Command Palette (press Ctrl/Cmd+Shift+P) and then run the Cloud Code: Run on Kubernetes command.
  2. Confirm whether to use the current Kubernetes 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.
  3. If you chose a remote cluster as the context, when prompted, choose an image registry to push the images to. If you're using Container Registry, you can browse to an existing registry or specify the name of a registry to create. If your project has Artifact Registry API enabled and at least one Artifact Registry repository, you can browse to and select an existing Artifact Registry repository.

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

    Artifact Registry {region}{project_id}/{repo-name}
    Container Registry{project_id}
    Docker Hub{account}
    Make sure that you're properly authenticated if you're using a private Docker Hub repository.

    Cloud Code concatenates this image registry with the image name specified in the Kubernetes manifests to generate the final image repository name.

    For more information, see the image registry handling guide.

    This choice is stored in your cloudcode.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 terminal output as you're developing and running your application, you can view logs from a specific pod by navigating to the Kubernetes Explorer.

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

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

    The Logs viewer opens.

Make changes, rebuild, and clean up

If 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:

  1. Make and Save your changes.

  2. In the Debug Toolbar, click Pause (F6) and then click Restart (Ctrl/Cmd + Shift + F5) to rebuild and redeploy the application.

  3. To stop running the application, in the Debug Toolbar, click Stop.

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

Store secrets

If your code includes potentially sensitive data like API keys, passwords, and certificates, it is recommended you store them as secrets. With Cloud Code, you can securely store these secrets in Secret Manager and programmatically fetch them when you need them.

For a detailed look at how you can create and manage secrets with Cloud Code, see the Secret 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 some of these resources.

See the Kubernetes overview for more information on viewing resource details.

What's next