This page shows you how to get started with Cloud Code using your own Kubernetes project or using the sample Hello World application.

Before you begin

The following tools are expected to be installed and setup on your system and available on the PATH of your machine:

Installing the plugin

To install the Cloud Code plugin:

  • Open IntelliJ IDEA (or any supported JetBrains IDE).
  • From your plugins marketplace (File > Settings > Plugins or for Mac OS X, IntelliJ IDEA > Preferences > Plugins), search for the 'Cloud Code' plugin and install it. You may be prompted to restart your IDE to activate the plugin.

Adding Cloud Code support to your existing Kubernetes projects

For existing Kubernetes projects, follow these steps to add Cloud Code support:

  • If your project has a Dockerfile and Kubernetes resources, Cloud Code will prompt you with a notification to automatically create necessary configuration files and run targets.

    Create Kubernetes targets notification

    Once created, your project is ready to use the Cloud Code's continuous development and deployment features.

  • Alternatively, use Tools > Cloud Code > Kubernetes > Add Kubernetes Support to analyze the project's Kubernetes resources, generate a Skaffold configuration, and add two run configurations for deployment and continuous deployment to a Kubernetes cluster.

Creating an application

To create an application using an existing sample:

  • Clone the Cloud Code samples GitHub repository.

    git clone https://github.com/GoogleCloudPlatform/cloud-code-samples.git

    This repository contains the Hello World samples (available in Java, Node, Python, and Go). You can choose any sample to get started.

    For the purposes of this quickstart, the Java sample will be used to demonstrate the steps you need to take to create an application. Note, you'll need to use Java 8 or higher to work with this sample.

  • Within IntelliJ IDEA, open the 'java-hello-world' project (from the cloud-code-samples/java/ directory).

  • You'll be prompted to import Maven projects to sync your pom.xml.

    Click 'Import Changes' to continue.

    Import Maven changes notification

  • You'll also be prompted to automatically create Kubernetes deployment and continuous development IDE run targets for the project with a notification.

    Click 'Create Cloud Code Kubernetes Run Configurations'.

    Create Kubernetes targets notification

  • Optional: Alternatively, you can manually create run targets.

    • Select the 'Run Configuration' drop down, and click 'Edit Configurations'.
    • Click the '+' Add New Configuration button to add a new Run Configuration.
    • Browse to 'Cloud Code: Kubernetes' and select either 'Kubernetes Continuous Deploy' or 'Kubernetes Deploy'.

      Cloud Code: Kubernetes option in menu

    • Fill in a name for your new Configuration.

    • Click 'OK' to create your run target.

Deploying your application

To deploy an application:

  • Make sure you have access to a container image repository used by the project.

    To replace the project image repository, specify it using the Run/Debug configurations dialog on the top taskbar under Edit Configurations... > Kubernetes Deploy / Continuous Deploy > Image options > Default image repository.

    For example, for Docker Hub, use 'docker.io/{account}'.

  • Now that your application is ready for deployment, choose Kubernetes Deploy from the Run/Debug configurations dialog on the top taskbar to deploy the application.

    Kubernetes deployment run configurations

Initiating continuous deployment

To initiate continuous deployment for your application:

  • Choose the Kubernetes Continuous Deploy run target from the Run/Debug configurations dialog on the top taskbar to continuously redeploy changes and watch application logs.

    Any changes to your code will automatically be built, pushed, and deployed to a new version of your application.

  • View application logs in the output window. Once the deployment has started, you'll see the list of forwarded ports for the deployed application.

  • Access your application locally using one of the listed ports.

    Viewing streamed logs from the Kubernetes application

Debugging your application

To debug your application:

  • Click the debug action for Kubernetes Continuous Deploy to start the development cycle in debug mode on your Kubernetes cluster.

    Starting the Kubernetes cluster development cycle in debug mode

  • Cloud Code will attach a debug session.

    You can now perform all the tasks you normally do when debugging local code, like setting breakpoints and stepping through code, except with the added advantage of debugging against a live Kubernetes cluster.

What's Next

Getting Support

To send feedback, report issues on GitHub, or ask a question on Stack Overflow.
Was this page helpful? Let us know how we did:

Send feedback about...

Cloud Code for IntelliJ