Developing and deploying an application

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

Deployment

For regular deployment, you can use the Kubernetes run target, 'Kubernetes Deploy' 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

Click the run action for 'Kubernetes Continuous Deploy' 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

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.

Configuration

When using the 'Kubernetes Deploy' and 'Kubernetes Continuous Deploy' 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
    • Context - represents the context with which your application will be deployed. It defaults to your active context. If changed, it will change the active context on your system.
    • Namespace - displays the namespace associated with the selected context.
    • Delete deployments when finished - deletes Kubernetes deployments when the process is terminated. Only available for the 'Kubernetes Continuous Deploy' target. When running continuous deployment, this is default behavior. Alternatively, you can toggle this setting to prevent deployments from being deleted
    • Tail logs after deployment - tails container logs after deployment completes, if selected. Only available for the 'Kubernetes Deploy' target.
  • Image options

Getting Support

To send feedback, report issues on GitHub, or ask a question on Stack Overflow.
هل كانت هذه الصفحة مفيدة؟ يرجى تقييم أدائنا:

إرسال تعليقات حول...

Cloud Code for IntelliJ