# Tutorial: deploy your application to a minikube cluster

In this tutorial, you will learn how to start a local Kubernetes cluster with [minikube](https://minikube.sigs.k8s.io/docs/) directly from IntelliJ IDEA and deploy a sample application to it. As part of this process, you will build the application, create a Docker image, and deploy it to minikube.

Running Kubernetes locally is especially useful for prototyping, testing deployments, and learning Kubernetes workflows. Using the Docker and Kubernetes support available in IntelliJ IDEA, you will be able to start the cluster, deploy resources, and inspect your application without leaving the IDE.

## Before you start

Before you start, make sure that you have the following installed and configured:

* [Java JDK 17](sdk.html#jdk)

* [Docker Desktop](https://docs.docker.com/get-started/introduction/get-docker-desktop/) running

* [minikube](https://minikube.sigs.k8s.io/docs/start/?arch=%2Fmacos%2Farm64%2Fstable%2Fbinary+download)

### Enable required plugins

The functionality used in this tutorial relies on the following plugins:

* [Kubernetes](https://plugins.jetbrains.com/plugin/10485-kubernetes)

* [Gradle](https://plugins.jetbrains.com/plugin/13112-gradle)

* [Gradle for Java](https://plugins.jetbrains.com/plugin/27367-gradle-for-java)

* [Spring](https://plugins.jetbrains.com/plugin/20221-spring)

The plugins are bundled and enabled in IntelliJ IDEA by default. If the relevant features are not available, make sure that you did not disable any of the plugins.

Procedure:

1. Press `Ctrl+Alt+S` (Windows), `⌘ Comma` (macOS), `⌘ Comma` (IntelliJ IDEA Classic (macOS)), `⌘ Comma` (macOS System Shortcuts), `Ctrl+Alt+S` (XWin), `Ctrl+Alt+S` (GNOME), `Ctrl+Alt+S` (KDE), `Ctrl+Alt+S` (Emacs), `Ctrl+Alt+S` (Sublime Text), `⌘ Comma` (Sublime Text (macOS)), `Ctrl+Alt+S` (NetBeans), `Ctrl+Alt+S` (Visual Studio), `⌘ Comma` (Visual Studio (macOS)), `Ctrl+Alt+S` (Eclipse), `⌘ Comma` (Eclipse (macOS)) to open settings and then select `Plugins`.

2. Open the Installed tab, find the required plugins, and select the checkboxes next to the plugin names to enable them.

## Clone the sample project

To get started, clone the `Spring PetClinic` application from GitHub or open this project in IntelliJ IDEA if you already have it on your machine.

Procedure:

The source code of the application is hosted on GitHub at    [https://github.com/spring-projects/spring-petclinic](https://github.com/spring-projects/spring-petclinic).

1. In the main menu, go to `File | New | Project from Version Control…`.

2. Specify the URL of the repository and click Clone.

3. In the Open or Import Project dialog, select Gradle project to use Gradle as the main build system for the project.

4. If necessary, agree to open the cloned project in a new window.

Let us start with a simple Node.js Express application. Let this application consist of a `hello_express.js` file that returns Hello World! and outputs `Example app listening on port 3000!` in the console.

Procedure: Create an empty project with Node.js

1. Click New Project on the [Welcome screen](null) or select `File | New | Project` from the main menu.

2. In the dialog that opens, select Node.js in the left-hand pane.

3. Specify the location of the application and its name, for example, `hello_world_docker`.

4. Specify the local Node.js runtime to use. Accept the suggested installation or select another one from the list, or even click Download if you do not have Node.js on your machine yet. Learn more from [Create a new
Node.js application](developing-node-js-applications.html#ws_node_quick_start_create_app_with_template).

![Create an empty project with Node.js](https://resources.jetbrains.com.cn/help/img/idea/2026.2/node_dockerize_example_1_create_empty_project_steps.png)

5. Click Create.

Procedure: Populate the application

1. Let us create a separate folder for our application, this will help us later map local folders to folders in the container.

To do that, open the Project tool window `Alt+1` (Windows), `⌘ 1` (macOS), `⌘ 1` (IntelliJ IDEA Classic (macOS)), `⌘ 1` (macOS System Shortcuts), `Alt+1` (XWin), `Alt+1` (GNOME), `Alt+1` (KDE), `Alt+1` (Emacs), `Alt+1` (Sublime Text), `⌘ 1` (Sublime Text (macOS)), `Ctrl+1` (NetBeans), `Ctrl+Alt+L` (Visual Studio), `⌘ ⌥ L` (Visual Studio (macOS)), `Alt+1` (Eclipse), `Alt+1` (Eclipse (macOS)), right-click the project folder, select `New` from the context menu, and then select `Directory`. In the popup dialog that appears, specify the name of the folder, for example, `app`.

![Create an application folder](https://resources.jetbrains.com.cn/help/img/idea/2026.2/example_1_populate_project_create_app_folder.png)

2. Now it is time to create a JavaScript file to place the code of our application in.

From the context menu of the `app` folder, select `New` from the context menu, and then select `JavaScript File`.

![Create a JavaScript file, context menu](https://resources.jetbrains.com.cn/help/img/idea/2026.2/example_1_populate_project_create_app_file_context_menu.png)

In the popup dialog that appears, specify the name of the file, for example, `hello_express.js`.

![Create a JavaScript file](https://resources.jetbrains.com.cn/help/img/idea/2026.2/example_1_populate_project_create_app_file.png)

3. Open the newly created `hello_express.js` file in the editor and type the following code:

```JAVASCRIPT
const express = require('express');
const app = express();

app.get('/', function(req, res) {
    res.send('Hello World!')
    });

app.listen(3000,function() {
    console.log('Example app listening on port 3000!')
    });
```

4. As you might have expected, the `express` reference is not resolved and highlighted as an error. However, IntelliJ IDEA suggests a quick-fix as you hover over the reference:

![Express is not installed - a quick-fix is suggested](https://resources.jetbrains.com.cn/help/img/idea/2026.2/example_1_write_code_express_missing_quick_fix.png)

When you click the Install 'express' link, `express` is added to the `package.json` file and installed.

![package.json - Express installed](https://resources.jetbrains.com.cn/help/img/idea/2026.2/example_1_write_code_express_installed.png)

Procedure: Run the application locally

Let us run our application locally to make sure it works as expected.

* Open the `hello_express.js` file, right-click anywhere in the editor tab, and select `Run 'hello_express.js'` from the context menu.

![Run an application locally](https://resources.jetbrains.com.cn/help/img/idea/2026.2/example_1_run_app_locally.png)

The Run tool window opens showing `Example app listening on port 3000!`.

If you open the browser at `http://localhost:3000`, you will see that the page shows Hello World!, as expected.

![The application is running locally](https://resources.jetbrains.com.cn/help/img/idea/2026.2/example_1_run_app_locally_app_running.png)

## Build the application

Before deploying the application to Kubernetes, you need to build it and package into a container image. In this tutorial, we will use a Gradle task to compile the application source code, run tests, and produce an executable JAR file. This JAR file will later be used when creating a Docker image.

Procedure:

1. Open the Gradle tool window.

2. Expand the project node (`spring-petclinic`), then the Tasks node, and double-click the build task to run it.

![The Gradle tool window](https://resources.jetbrains.com.cn/help/img/idea/2026.2/ij-petclinic-gradle-build.png)

Wait for IntelliJ IDEA to finish the task. As a result, the IDE creates the `build` directory with artifacts in the project root.

![Gradle successfully finished the build task](https://resources.jetbrains.com.cn/help/img/idea/2026.2/ij-petclinic-build-successful.png)

## Containerize the application

In this step, you will package the built application into a Docker image. Kubernetes will run this image later as a container in a pod.

Procedure: Create a Dockerfile

1. In the Project tool window `Alt+1` (Windows), `⌘ 1` (macOS), `⌘ 1` (IntelliJ IDEA Classic (macOS)), `⌘ 1` (macOS System Shortcuts), `Alt+1` (XWin), `Alt+1` (GNOME), `Alt+1` (KDE), `Alt+1` (Emacs), `Alt+1` (Sublime Text), `⌘ 1` (Sublime Text (macOS)), `Ctrl+1` (NetBeans), `Ctrl+Alt+L` (Visual Studio), `⌘ ⌥ L` (Visual Studio (macOS)), `Alt+1` (Eclipse), `Alt+1` (Eclipse (macOS)), right-click the project root, point to New, and click File.

2. In the New File… dialog, type `Dockerfile` and press `Enter` (Windows), `⏎` (macOS), `⏎` (IntelliJ IDEA Classic (macOS)), `⏎` (macOS System Shortcuts), `Enter` (XWin), `Enter` (GNOME), `Enter` (KDE), `Enter` (Emacs), `Enter` (Sublime Text), `⏎` (Sublime Text (macOS)), `Enter` (NetBeans), `Enter` (Visual Studio), `⏎` (Visual Studio (macOS)), `Enter` (Eclipse), `⏎` (Eclipse (macOS)).

If prompted, agree to add the file to Git.

3. Paste the following code to the new Dockerfile:

```DOCKERFILE
FROM eclipse-temurin:17-jre
WORKDIR /app
COPY build/libs/*.jar app.jar
EXPOSE 8080
ENTRYPOINT ["java", "-jar", "app.jar"]
```

The created Dockerfile contains instructions for building a Docker image based on the `eclipse-temurin:17-jre` image, which provides a lightweight Java 17 runtime environment.

When you build the image, Docker copies the executable JAR file produced by the Gradle build from the `build/libs` directory of the project into the `/app` directory inside the container.

When you start a container from the image, Docker runs the `java -jar app.jar` command, which starts the Spring Petclinic application.

Procedure: Create a Dockerfile

1. From the context menu of the project folder, select `New` from the context menu, and then select `Dockerfile`.

![Create a Dockerfile - context menu](https://resources.jetbrains.com.cn/help/img/idea/2026.2/example_1_create_dockerfile.png)

2. Open the newly created `Dockerfile` and type the following code:

```DOCKERFILE
FROM node:22-alpine
WORKDIR /tmp
COPY package*.json .
RUN npm ci --omit=dev
COPY ./app/ ./app/
CMD ["node","./app/hello_express.js"]
```

This `Dockerfile` contains instructions for building an image based on the `node:22` image from [Docker Hub](https://hub.docker.com/).

When you run a container from this image, Docker sets copies the contents of the `/app/` directory to the `/tmp/app/` directory in the container (in our case, the `/app/` directory contains the `hello_express.js` file). The `package.json` file is copied to `/tmp/`.

Then Docker sets the current working directory to `/tmp` and runs `node ./app/hello_express.js`. As a result, the container log should show `Example app listening on port 3000!`.

Procedure: Build the Docker image

> **Note:**
> Before proceeding, make sure that [Docker Desktop](https://docs.docker.com/get-started/introduction/get-docker-desktop/) is running on your machine.

1. Form the Project view, open `Dockerfile` in the editor.

2. Edit the file:

* Change ```DOCKERFILE ENV RAILS_ENV="production" \ BUNDLE_DEPLOYMENT="1" \ BUNDLE_PATH="/usr/local/bundle" \ BUNDLE_WITHOUT="development" ``` to ```DOCKERFILE ENV RAILS_ENV="development" \ BUNDLE_PATH="/usr/local/bundle" ```

* Change ```DOCKERFILE EXPOSE 80 CMD ["./bin/thrust", "./bin/rails", "server"] ``` to ```DOCKERFILE EXPOSE 3000 CMD ["./bin/rails", "server", "-b", "0.0.0.0", "-p", "3000"] ```

3. In the gutter inside the Dockerfile, click ![The Run on Docker icon](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.actions.runAll.svg) and select New Run Configuration.

![Create a new Dockerfile run/debug configuration from the editor](https://resources.jetbrains.com.cn/help/img/idea/2026.2/ij-new-dockerfile-configuration.png)

4. In the Edit Run Configuration dialog, specify `petclinic-app` in the Image tag field and `petclinic` in the Container name field. Then, click Run.

IntelliJ IDEA creates a [Dockerfile run configuration](dockerfile-run-configuration.html), which builds an image from the Dockerfile and then runs a container based on that image.   To follow the whole process, open the Log tab in the Services tool window.

![Push the log tab in the Services tool window](https://resources.jetbrains.com.cn/help/img/idea/2026.2/ij-petclinic-docker-log.png)

## Connect to minikube

Now that you have a Docker image with your application, you need to start a local Kubernetes cluster to deploy it to. We will use minikube to run a local, single-node Kubernetes cluster directly from IntelliJ IDEA.

Procedure: Start minikube with the Docker driver

1. Open the Terminal tool window: go to `View | Tool Windows | Terminal` or press `Alt+F12` (Windows), `⌥ F12` (macOS), `⌥ F12` (IntelliJ IDEA Classic (macOS)), `⌘ ⌃ T` (macOS System Shortcuts), `Alt+F12` (XWin), `Alt+F12` (GNOME), `Alt+F12` (KDE), `Alt+F12` (Emacs), `Alt+F12` (Sublime Text), `⌥ F12` (Sublime Text (macOS)), `Alt+F12` (NetBeans), `Ctrl+Alt+1` (Visual Studio), `⌘ ⌃ 1` (Visual Studio (macOS)), `Alt+F12` (Eclipse), `⌥ F12` (Eclipse (macOS)).

2. Run the following command to start a local Kubernetes cluster and instruct minikube to use Docker as the virtualization driver:

```BASH
minikube start --driver=docker
```

3. Verify that your cluster is up and running by using the command:

```BASH
minikube status
```

Using the Docker driver runs the minikube cluster inside Docker containers, providing a lightweight environment well suited for local development.

Procedure: Add the minikube cluster to IntelliJ IDEA

1. Open the [Services](services-tool-window.html) tool window: go to `View | Tool Windows | Services` or press `Alt+8` (Windows), `⌘ 8` (macOS), `⌘ 8` (IntelliJ IDEA Classic (macOS)), `⌘ 8` (macOS System Shortcuts), `Alt+8` (XWin), `Alt+8` (GNOME), `Alt+8` (KDE), `Alt+8` (Emacs), `Alt+8` (Sublime Text), `⌘ 8` (Sublime Text (macOS)), `Alt+8` (NetBeans), `Alt+8` (Visual Studio), `Alt+8` (Visual Studio (macOS)), `Alt+8` (Eclipse), `⌘ 8` (Eclipse (macOS)).

2. Select the Kubernetes node, click the Add Cluster button, and then select From Default Directory from the context menu.

![Adding a new cluster from the Kubernetes welcome screen in the Services tool window](https://resources.jetbrains.com.cn/help/img/idea/2026.2/k8s-welcome-screen-add-cluster.png)

3. In the Add Clusters dialog, select minikube and click Add Clusters.

The added cluster will become available in the Services tool window.

4. In the Services tool window, right-click the minikube cluster and select Connect Cluster.

![Connect to the minikube cluster](https://resources.jetbrains.com.cn/help/img/idea/2026.2/ij-connect-cluster.png)

At this point, IntelliJ IDEA is connected to the running minikube cluster and can display its Kubernetes resources. You can explore namespaces, nodes, and other cluster objects directly from the Services tool window.

## Deploy the application

Earlier in the tutorial, you already [built the application image
locally](#build-docker-image). However, the minikube cluster cannot automatically access images from your local Docker daemon. You need to load the image into minikube to make it available.

Procedure: Load the Docker image into minikube

1. Open the Terminal tool window: go to `View | Tool Windows | Terminal` or press `Alt+F12` (Windows), `⌥ F12` (macOS), `⌥ F12` (IntelliJ IDEA Classic (macOS)), `⌘ ⌃ T` (macOS System Shortcuts), `Alt+F12` (XWin), `Alt+F12` (GNOME), `Alt+F12` (KDE), `Alt+F12` (Emacs), `Alt+F12` (Sublime Text), `⌥ F12` (Sublime Text (macOS)), `Alt+F12` (NetBeans), `Ctrl+Alt+1` (Visual Studio), `⌘ ⌃ 1` (Visual Studio (macOS)), `Alt+F12` (Eclipse), `⌥ F12` (Eclipse (macOS)).

2. Run the following command to build the container image in minikube:

```BASH
minikube image load petclinic-app
```

3. Validate that the `petclinic-app` image is available in your cluster by running:

```BASH
minikube image ls | grep petclinic-app
```

You should see `docker.io/library/petclinic-app:latest` in the output.

Now that the image is available in minikube, the next step is to describe how Kubernetes will run it. Let us create two Kubernetes manifests:

* Deployment, which helps you run your container in a pod

* Service, which exposes your app so that you can access it from your machine

Procedure: Create a Deployment manifest

1. In the   Project tool window  (`Alt+1` (Windows), `⌘ 1` (macOS), `⌘ 1` (IntelliJ IDEA Classic (macOS)), `⌘ 1` (macOS System Shortcuts), `Alt+1` (XWin), `Alt+1` (GNOME), `Alt+1` (KDE), `Alt+1` (Emacs), `Alt+1` (Sublime Text), `⌘ 1` (Sublime Text (macOS)), `Ctrl+1` (NetBeans), `Ctrl+Alt+L` (Visual Studio), `⌘ ⌥ L` (Visual Studio (macOS)), `Alt+1` (Eclipse), `Alt+1` (Eclipse (macOS))) , right-click the project name and select `New | Kubernetes Resource`.

2. In the New Kubernetes Resource dialog, select the Deployment file type, specify `petclinic-deployment`   as the manifest name, and press `Enter` (Windows), `⏎` (macOS), `⏎` (IntelliJ IDEA Classic (macOS)), `⏎` (macOS System Shortcuts), `Enter` (XWin), `Enter` (GNOME), `Enter` (KDE), `Enter` (Emacs), `Enter` (Sublime Text), `⏎` (Sublime Text (macOS)), `Enter` (NetBeans), `Enter` (Visual Studio), `⏎` (Visual Studio (macOS)), `Enter` (Eclipse), `⏎` (Eclipse (macOS)).

![Create a new Deployment](https://resources.jetbrains.com.cn/help/img/idea/2026.2/ij-petclinic-new-deployment.png)

If prompted, agree to add the file to Git.

3. Replace the content of the resulting `petclinic-deployment.yaml`  file with the following code:

```YAML
apiVersion: apps/v1
kind: Deployment
metadata:
    name: petclinic
spec:
    replicas: 1
    selector:
        matchLabels:
            app: petclinic
    template:
        metadata:
            labels:
                app: petclinic
        spec:
            containers:
                - name: petclinic
                  image: petclinic-app:latest
                  imagePullPolicy: IfNotPresent
                  ports:
                      - containerPort: 8080

```

4. On the [floating toolbar](kubernetes.html#floating-toolbar), select the current cluster and namespace, then click ![Apply icon](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.expui.actions.deploy.svg) Apply to deliver the changes to the local cluster.

![The Apply button on the floating toolbar](https://resources.jetbrains.com.cn/help/img/idea/2026.2/ij-apply-manifest.png)

Procedure: Create a Service manifest

1. In the   Project tool window  (`Alt+1` (Windows), `⌘ 1` (macOS), `⌘ 1` (IntelliJ IDEA Classic (macOS)), `⌘ 1` (macOS System Shortcuts), `Alt+1` (XWin), `Alt+1` (GNOME), `Alt+1` (KDE), `Alt+1` (Emacs), `Alt+1` (Sublime Text), `⌘ 1` (Sublime Text (macOS)), `Ctrl+1` (NetBeans), `Ctrl+Alt+L` (Visual Studio), `⌘ ⌥ L` (Visual Studio (macOS)), `Alt+1` (Eclipse), `Alt+1` (Eclipse (macOS))) , right-click the project name and select `New | Kubernetes Resource`.

2. In the New Kubernetes Resource dialog, select the Service file type, specify `petclinic-service`   as the manifest name, and press `Enter` (Windows), `⏎` (macOS), `⏎` (IntelliJ IDEA Classic (macOS)), `⏎` (macOS System Shortcuts), `Enter` (XWin), `Enter` (GNOME), `Enter` (KDE), `Enter` (Emacs), `Enter` (Sublime Text), `⏎` (Sublime Text (macOS)), `Enter` (NetBeans), `Enter` (Visual Studio), `⏎` (Visual Studio (macOS)), `Enter` (Eclipse), `⏎` (Eclipse (macOS)).

If prompted, agree to add the file to Git.

3. Replace the content of the resulting `petclinic-service.yaml`  file with the following code:

```YAML
apiVersion: v1
kind: Service
metadata:
    name: petclinic
spec:
    type: NodePort
    selector:
        app: petclinic
    ports:
        - port: 8080
          targetPort: 8080
```

4. On the [floating toolbar](kubernetes.html#floating-toolbar), select the current cluster and namespace, then click ![Apply icon](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.expui.actions.deploy.svg) Apply to deliver the changes to the local cluster.

Procedure: Access the application

1. Open the `petclinic-deployment.yaml` file in the editor.

2. Click the Forward Ports inlay hint next to the `- containerPort: 8080` property.

![The port forwarding inlay hint](https://resources.jetbrains.com.cn/help/img/idea/2026.2/port-forwarding-inlay-hint.png)

> **Tip:**
> After IntelliJ IDEA starts a new port-forwarding session, the Forward Ports inlay hint changes to Open in Browser.

3. In the Forward Ports dialog, leave the default values and click Forward.

4. In the `petclinic-deployment.yaml` file, click the Open in Browser inlay hint.

![Start of a new port-forwarding session in the Services tool window](https://resources.jetbrains.com.cn/help/img/idea/2026.2/ij-new-port-forwarding-session.png)

IntelliJ IDEA redirects you to your default browser, where you can check the Spring Petclinic application deployed in your local minikube cluster.

You have learned how to deploy a Spring application to a local Kubernetes cluster using minikube and IntelliJ IDEA. This approach enables quick local testing and experimentation with Kubernetes without requiring a remote cluster.

## Next steps

Learn how to work with Kubernetes from these topics:

* [View logs](kubernetes.html#view-logs)

* [Manage your cluster](kubernetes.html#manage_cluster)

* [Debug in Kubernetes](debugging-in-kubernetes.html)

For a full list of available tutorials, refer to [IntelliJ IDEA tutorials](instance-tutorials.html).

