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. This page uses the Guestbook sample app to illustrate the running and developing on Kubernetes experience.

Choosing a run action

Run on Kubernetes

For a regular run of your application, 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.

Continuous development on Kubernetes

Click the run action for 'Develop on Kubernetes' run action icon to start the development cycle on your Kubernetes cluster. Once the development cycle initiates, Cloud Code, 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.

Starting the Kubernetes cluster development cycle

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

Previewing your deployed app

  1. Once you click the Run button on your preferred run action, you can view incoming application logs in the output window.

    After the deployment starts, you'll see the list of forwarded ports for your deployed application.

    Viewing streamed logs from the Kubernetes application

  2. Once the deployment is successful, you'll be prompted with a notification stating that your service is now accessible via local URLs. Click 'View' to open the Event Log.

    Notification stating the URL to access your live app is now available in the Event Log

    In the Event log, find the port where your application is being served. Click on the link to open your browser with your running application.

  3. View your newly deployed application!

    Running Guestbook app on localhost:8080

Viewing logs

While you can see a live stream of the logs from running pods within the terminal output as you are developing and running your application, 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

Adding new features when developing on Kubernetes

If you started a development iteration cycle with 'Develop on Kubernetes' and added more features to your project, you'll see how these changes get deployed to your Kubernetes cluster without stopping and removing the deployment, manually building and tagging the image, or updating the cluster.

If you're following along with the Guestbook app:

  1. 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);
     }
     ```
    
  2. Add in the necessary imports for the new annotations, RequestMapping and ResponseBody.

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

  4. Once you're finished, click the Stop button 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. Skaffold flags can also be configured as environment variables to be used in this field. Refer to the Skaffold CLI reference documentation for a comprehensive list of available Skaffold environment variables.
    • Verbosity - allows you to set your output verbosity level at trace, debug, info, warn, error, or fatal. The default verbosity level is warn.
  • 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 Run/Debug settings). 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
    • 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
  • Container image storage options
  • Build settings

Getting Support

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