Running and developing an application

Now that you're all set up, you can either opt for regular run of your application or start a development iteration cycle on your IDE to propagate any change made to your source and dependencies to your live application.

Running your application

For regular run, you can use the Kubernetes run target, 'Run on Kubernetes' run action icon, to build the image and deploy the project to your Kubernetes cluster. Your project sources and dependencies are not watched, and the Skaffold process finishes once the image and deployment are complete.

Regular deployment using the run action

For more information on customizing your deployment, refer to available configuration options.

Working with continuous development

Click the run action for 'Develop on Kubernetes' run action icon to start the development cycle on your Kubernetes cluster.

Starting the Kubernetes cluster development cycle

For more information on customizing your deployment, refer to available configuration options.

Once the development cycle initiates, the console window with the logs will open. The plugin, using Skaffold, builds an image for the project, and then tags it, pushes it to the configured repository, and uses kubectl to deploy the project Kubernetes manifests.

Building an image using Skaffold

As soon as the build completes, the image is pushed and deployment starts, and the console will begin streaming logs from your Kubernetes deployment.

Logs streamed on console

Previewing your deployed app

If you're following along with the Guestbook sample application, you'll notice that the Guestbook application has initialized and launched to the built-in web server. By default, the Guestbook web server uses port 8080 to serve content. You don't have to worry about accessing the deployment via a remote address - the plugin automatically port-forwards all declared container ports!

Automatic port forwarding delivering your content to port 8080

Navigate to localhost:<frontend-port> on your browser (or use the curl command) to access the Guestbook application running on your Kubernetes cluster. Be sure to replace <frontend-port> with the local port the plugin forwarded the frontend service to as displayed in your logs (and exemplified in the screenshot above).

Running Guestbook app on localhost:8080

You can check the details of the Kubernetes deployment and service using standard Kubernetes CLI commands (for example, kubectl get deploy) or by using Kubernetes dashboard for your Kubernetes cluster. The Kubernetes resources for the project are located in the k8s directory; there should be a set of deployment and service YAML files each for the frontend, backend and database.

Adding new features

If you add more features to the Guestbook project, you'll see how they get deployed to your Kubernetes cluster without stopping and removing the deployment, manually building and tagging the image, or updating the cluster.

Open the 'FrontendController.java' file from src/main/java/cloudcode/guestbook/frontend and add this new endpoint to the FrontendController class:

@RequestMapping("/greeting")
@ResponseBody
public String greeting(@RequestParam(value="name", defaultValue="World") String name) {
   return String.format("Hello from Kubernetes with IntelliJ, %s!", name);
}

Add in the necessary imports for the new annotations, RequestMapping and ResponseBody.

Save the changes (Ctrl/Cmd-S) or build the project (use Build > Build Project menu).

You can watch the progress and deployment logs in the console window. Once the changes are propagated, confirm the updates by visiting the new endpoint URL: localhost:8080/greeting.

Viewing the newly created endpoint in a browser

Once you're finished, click Stop to end the continuous development session. This action causes the plugin to delete all Kubernetes resources used for the development session.

Viewing resource details

For keeping track of the status of your Kubernetes resources, you can use the Kubernetes explorer, accessible from the side panel on the right. Alternatively, it can be accessed using Tools > Cloud Code > Kubernetes > View Cluster Explorer.

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

With the Kubernetes Explorer, you can access information about your clusters, nodes, workloads, and more, as well as set an active context, stream and view logs, and look up resource descriptions.

You can conveniently run a kubectl describe on your deployed resources to display its details by right-clicking its label within the Kubernetes explorer and choosing Describe.

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

Configuration

When using the 'Run on Kubernetes' and 'Develop on Kubernetes' Run Configurations, you can customize your deployment by configuring available settings. Access the configuration options by selecting the Run Configuration from the dropdown and selecting 'Edit Configurations'.

  • Skaffold options
    • Skaffold configuration - selects a 'skaffold.yaml' configuration file. Will be automatically detected if you have a 'skaffold.yaml' in your project.
    • Deployment profile - selects a profile from the available options configured in your 'skaffold.yaml' file.
    • Environment variables - allows you to configure additional environment variables to be passed to the Skaffold deployment process.
  • Kubernetes options
    • Deployment Context - represents the Kubernetes context with which your application will be deployed. The default behavior is deploying to your current system context. Alternatively, you can choose to deploy to a fixed context by selecting 'Switch context and deploy to' (under the Deployment section of Kubernetes options). This option will change the current context on your system to your specified context upon deployment. Selecting Kubernetes deployment context in a Cloud Code run configuration
    • Namespace - displays the namespace associated with the selected context.
    • Delete deployments when finished - deletes Kubernetes deployments when the process is terminated. This is default behavior. Alternatively, you can toggle this setting to prevent deployments from being deleted
  • Image options

Getting Support

To send feedback, report issues on GitHub, or ask a question on Stack Overflow.