Skip to content

Deploy Pet Clinic (Spring Boot)

This example uses Pet Clinic, a Spring Boot application built using Maven or Gradle. Pet Clinic can be deployed as Unikraft Cloud service and can be queried via HTTP to process images.

To run this example, follow these steps:

  1. Install the kraft CLI tool and a container runtime engine, e.g. Docker.

  2. Clone the examples repository and cd into the examples/java17-spring-petclinic/ directory:

Terminal window
git clone https://github.com/kraftcloud/examples
cd examples/java17-spring-petclinic/

Make sure to log into Unikraft Cloud by setting your token and a metro close to you. We use fra0 (Frankfurt, 🇩🇪) in this guide:

Terminal window
# Set Unikraft Cloud access token
export UKC_TOKEN=token
# Set metro to Frankfurt, DE
export UKC_METRO=fra0

When done, invoke the following command to deploy this application on Unikraft Cloud:

Terminal window
kraft cloud deploy -p 443:8080 -M 1024 .

The output shows the instance URL and other details:

Terminal window
[] Deployed successfully!
────────── name: java17-spring-petclinic-x77pg
────────── uuid: d089f764-0f0b-4a52-966d-f97183ed9a53
───────── state: starting
─────────── url: https://bold-haze-kugtro97.fra0.kraft.host
───────── image: java17-spring-petclinic@sha256:8e478742271165f4f7359c7ceaf54a3c0199b2ff72c2a68a0d999c058014536f
──────── memory: 1024 MiB
─────── service: bold-haze-kugtro97
── private fqdn: java17-spring-petclinic-x77pg.internal
──── private ip: 172.16.3.1
────────── args: /usr/lib/jvm/java-17-openjdk-amd64/bin/java -jar /usr/src/spring-petclinic-3.3.0-SNAPSHOT.jar

In this case, the instance name is java17-spring-petclinic-x77pg and the URL is https://bold-haze-kugtro97.fra0.kraft.host. They are different for each run.

Use a browser to open the URL and visit the Pet Clinic landing page.

At any point in time, you can list information about the instance:

Terminal window
kraft cloud instance list
NAME FQDN STATE STATUS IMAGE MEMORY ARGS BOOT TIME
java17-spring-petclinic-x77pg bold-haze-kugtro97.fra0.kraft.host running since 4mins java17-spring-p... 1.0 GiB /usr/lib/jvm/java-17-openjdk-amd64... 169.87 ms

When done, you can remove the instance:

Terminal window
kraft cloud instance remove java17-spring-petclinic-x77pg

The Pet Clinic Unikraft Cloud deployment works out of the box. Updates to it would generally imply updates to the application source code, not to the Unikraft Cloud configuration.

Learn More

Use the --help option for detailed information on using Unikraft Cloud:

Terminal window
kraft cloud --help

Or visit the CLI Reference.