This page shows you how to get started with Cloud Code.

You can use your own Kubernetes project or choose from one of the built-in sample applications.

In this quickstart, you'll set up your application with Cloud Code, create a cluster, run your app on this cluster, kickstart continuous rebuilding to iteratively develop your app, debug your running code, and sit back and view logs streaming from your live application.

Before you begin

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

  • JetBrains IDE version 2019.1+ (such as IntelliJ Ultimate/Community, PyCharm Professional/Community, WebStorm, GoLand)
  • Docker client (authenticated with your Docker registry)

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 or is configured for Jib, and has 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:

  1. Open File > New Project and select Cloud Code: Kubernetes.
  2. Select a template from the list of starter applications. List of templates available: Python, Go, NodeJS, Java hello world and guestbook applications
  3. Pick a name for your project. Once you click Finish, Cloud Code will clone your chosen template and open your newly created project for use.

    For Java templates, you'll be prompted to import Maven projects to sync your pom.xml. Click 'Import Changes' to continue.

    Import Maven changes notification

  4. 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

Creating a cluster

To run your application, you'll need an associated Kubernetes cluster (hosted either locally with Minikube or using a Cloud Platform, like a Google Kubernetes Engine cluster).

If you don't yet have an available cluster, you can create a new cluster on GKE, either from your terminal or the Cloud Console.

  • To create a cluster using the terminal (accessible within your IDE, using the bottom taskbar), run,

    gcloud containers cluster create [CLUSTER_NAME] --zone [COMPUTE_ZONE]
  • To create a cluster using the Cloud Console, visit the Google Kubernetes Engine menu and click Create cluster.

    Visit the Google Kubernetes Engine menu

    Refer to the GKE guide for more details on field customization.

After you create a cluster, you need to add it to your local kubeconfig file. To do so, run:

gcloud container clusters get-credentials [CLUSTER_NAME]

This also sets your specified cluster to the active context.

Running your application

To run an application on Kubernetes:

  • 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 or the top-level main menu, Run > Edit Configurations... > Run / Develop on Kubernetes > Image options > Default image repository.

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

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

    Kubernetes deployment run configurations

Developing your application

To initiate development of your application on Kubernetes:

  • Choose the Develop on Kubernetes run target from the Run/Debug configurations dialog on the top taskbar to continuously re-build and re-run changes and watch application logs.

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

    Kubernetes deployment run configurations

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

    Viewing streamed logs from the Kubernetes application

  • Access your application services locally using one of the ports listed in the IDE Event log.

    Using event log to find port-forwarded services

Debugging your application

To debug your application:

  • Click the debug action for Develop on Kubernetes 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.

Viewing logs

While you can see a live stream of the logs from running pods within the terminal output from your continuous deployment, you can also view logs from a specific pod by navigating to the Kubernetes explorer.

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

  1. Navigate to the Kubernetes Explorer. It can be accessed either from the side panel on the right or using Tools > Cloud Code > Kubernetes > View Cluster Explorer.

    Kubernetes Explorer panel open using the tab on the right side taskbar

  2. Select the pod you'd like to see logs from.

  3. Right click the pod and select Stream Logs. Alternatively, you can stream logs for individual containers running in pods.

    This will output logs to the Kubernetes Explorer Console.

    Streaming logs from a pod using its right-click menu to output logs into the Kubernetes Explorer Console

Additionally, you can check up on the status of your deployment in the following ways:

  • Pod, deployment and node statuses: These Kubernetes resources will have colored status marks next to their labels; red for failed state, yellow for starting/terminating/warning, and green for healthy, desired state.

    Pod status is healthy as observed by the green check mark next to the pod label

  • Deployed resource descriptions: You can run a kubectl describe on your deployed resources to display its details by right-clicking and choosing Describe.

    Describe option available when right-clicking an appropriate resource within the Kubernetes Explorer panel and choosing Describe

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