GraalVM Tools for Micronaut Extension
The extension also enables the Micronaut Launch application that allows you to create Micronaut projects through an interface inside VS Code, in addition to using the console CLI.
There are, of course, other ways to create a new Micronaut application. If you provide a path to the Micronaut CLI installation, you can create a project using the
In combination with the GraalVM Tools for Java extension, you can run Micronaut projects on GraalVM, and debug them directly from the VS Code development environment with different debugging protocols enabled with the extension. This extension for Micronaut was also developed to help developers build native images right from VS Code.
Table of contents
Installation and Setup
Install the GraalVM Tools for Micronaut extension from the VS Code consolde by clicking on the Extensions icon in the Activity Bar (or invoke it with Ctrl+Shift+X). Search for "Micronaut" and install the package. Reload will be required.
When installed, the extension might check whether there is a registered GraalVM instance, and eventually request to download it or point to a local installation (see GraalVM Installation and Setup in VS Code).
Upon installation, the Micronaut Tools Page window opens, which provides you with shortcuts to:
The GraalVM Tools for Micronaut extension provides:
Micronaut VS Code Commands
To begin, invoke the Micronaut commands from View > Command Palette (Command Palette can be also opened by pressing F1, or the Ctrl+Shift+P hot keys combination for Linux, and Command+Shift+P for macOS):
The following commands are available for Micronaut project development:
This extension contributes the following settings:
Create Micronaut Project
The Create Micronaut Project command in VS Code supports generating Micronaut applications, CLI applications, and other types of applications that a regular Micronaut Launch application does. The wizard prompts users to:
Finally, you are asked to select the destination folder on your local disk and whether to open the created project in a new editor or add it to the current workspace.
The GUI part of the Micronaut extension adds a new view to the Explorer activity, which shows Micronaut projects in the current workspace.
Generate Native Images of Micronaut Projects
The Micronaut support for VS Code is integrated with GraalVM to get the most from the applications and provide you with rich Native Image capabilities.
Having set up GraalVM as the default runtime and debug environment in VS Code, invoke the "View > Command Palette > Micronaut: Build..." action, where you can select the build targets (e.g.,
For more details, continue reading to the Micronaut documentation.
Deploy Micronaut Projects to a Docker Registry
The Micronaut support in VS Code allows to build and deploy Docker images to a Docker registry. Use action View > Command Palette > Micronaut: Deploy... and select dockerPush to deploy a dockerized Micronaut application or dockerPushNative to build and push docker with a native executable of Micronaut application.
Besides that, you can also push a Micronaut application or a native executable to a Docker Registry from the VS Code Terminal window. A particular Docker Registry can be configured in the build, see the Micronaut Deploying Application documentation.
Deploy Micronaut Applications to Oracle Container Engine for Kubernetes
GraalVM Tools for Micronaut Extension added support for working with Kubernetes clusters based on Microsofts’s Visual Studio Code Kubernetes Tools. It is now possible to deploy, run and debug a Micronaut application in a Kubernetes cluster from VS Code.
This guide is focused on and tested with Oracle Container Engine for Kubernetes (OKE)](https://www.oracle.com/uk/cloud-native/container-engine-kubernetes/) and Oracle Container Registry, but Kubernetes features should work in other environments. OKE is a fully-managed, scalable, and highly available service that you can use to deploy your containerized applications to Oracle Cloud.
This guide will walk you through the process of deploying a Micronaut application to OKE from VS Code and debugging it.
Visual Studio Code Kubernetes Tools
GraalVM Tools for Micronaut Extension uses
Open Extensions tab, search for "Kubernetes" and install the one from Microsoft. Once installed, you should see the Kubernetes icon in the left sidebar:
Oracle Cloud Account
If you have not got an active Oracle Cloud account, create one by following this link.
Access to Oracle Container Engine for Kubernetes (OKE)
Supposedly, you have signed in to your Oracle Cloud account. To be able to deploy Docker images to Oracle Container Registry, you need to setup the access to Oracle Container Engine for Kubernetes (OKE).
Step 1: Create a Kubernetes cluster in OCI
Using the Oracle Cloud Console, create a Kubernetes cluster with default settings using the Quick Create workflow:
For more information, check this guide.
Step 2: Set up access to Kubernetes cluster
You can access your Kubernetes cluster and manage it using
See the Setting Up Local Access to Clusters guide for step-by-step instructions.
Log in to Docker
To be able to dockerize your Micronaut project, push and pull images on a local machine, and deploy to Oracle Container Registry, you will need Docker.
To check whether Docker is started and running on your computer, go to VS Code Terminal and type:
Next you need to login with Docker to your Oracle Container Registry. Prepare following Oracle Cloud account credentials:
From VS Code Terminal window, log in using the following command:
For example, if your OCI region is US East (Ashburn), then the key will be
This guide describes how to create a Docker registry secret and describes how to specify the image to pull from Oracle Cloud Infrastructure Registry (along with the Docker secret to use) during application deployment to a cluster you've created using OKE.
Specify the Location for Docker Image in Oracle Container Registry
The location where to push your Docker image in Oracle Container Registry should be specified in the project configuration file.
If you used Gradle to build your Micronaut project, open the gradle.build file and update image location:
See, for example, this example project configuration:
Deploy a Micronaut Application to OKE
To deploy, run and debug a Micronaut application in Oracle Container Engine for Kubernetes (OKE), the following quick actions for Micronaut are available:
You should start by creating a Kubernetes deployment file that will be applied at the deployment stage.
Now you are ready to deploy your Micronaut application to OKE.
When you hit this action, the project is packaged with Gradle/Maven to a runnable JAR file, built into a Docker image.
Then Docker pushes this image to the OKE repository (Oracle Container Registry), by applying the deploy.yaml script.
The Kubernetes extension starts port forwarding to connect to the server running in a Kubernetes cluster (
All this can be tracked in the Output window. If the deployment succeeds, you should see a similar status bar:
To otherwise check the deployment's status, run:
You can work on other projects, deploy them to another Kubernetes clusters, and they will all be deployed and running from Oracle Container Registry.
Debug Micronaut Applications in Remote Kubernetes Cluster
In addition to being able to deploy and run Micronaut applications in Kubernetes, you can also debug your Java application in a cluster directly from VS.
With the connection made to a local port (thanks to Kubernetes port forwarding feature), you can use your local workstation to debug the application that is running in the Pod. Having set some breakpoints in your applciation, do the following to start debugging:
The GraalVM Tools for Micronaut Extension extension 0.5.* is Technology Preview, meaning the functionality may not be complete.