Zudoku
Example apps

Spring PetClinic

Spring PetClinic is an example project that uses Spring boot to model a simple pet clinic.

To run this example, follow these steps:

  1. Install the unikraft CLI. You need a BuildKit builder. The easiest way to get one is via Docker. Alternatively, you can also directly set up and use BuildKit, see the quick start.

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

    TerminalCode
    git clone https://github.com/unikraft-cloud/examples cd examples/httpserver-java17-spring-petclinic/

Make sure to log into Unikraft Cloud and pick a metro close to you. This guide uses fra (Frankfurt, 🇩🇪):

TerminalCode
unikraft login

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

TerminalCode
unikraft build . --output <my-org>/httpserver-java17-spring-petclinic:latest unikraft run --metro fra \ -m 1G \ -p 443:8080/tls+http \ --scale-to-zero policy=idle,cooldown-time=1000,stateful=true \ --image <my-org>/httpserver-java17-spring-petclinic:latest

The output shows the instance address and other details:

TerminalCode
metro: fra name: httpserver-java17-spring-petclinic-r4s3x uuid: 5a3b7e2c-1f4d-4a8e-b6c9-2d3f8a1e7b4c state: starting image: <my-org>/httpserver-java17-spring-petclinic resources: memory: 1024MiB vcpus: 1 service: uuid: f4c2b1a0-3e5d-8b7a-9c6d-1e2f3a4b5c6d name: bitter-dust-a7b2c3d4 domains: - fqdn: bitter-dust-a7b2c3d4.fra.unikraft.app networks: - uuid: 7d6e5f4a-3b2c-1d0e-9f8a-7b6c5d4e3f2a private-ip: 10.0.4.2 mac: 12:b0:4a:1c:8f:73 timestamps: created: just now

In this case, the instance name is httpserver-java17-spring-petclinic-r4s3x and the address is https://bitter-dust-a7b2c3d4.fra.unikraft.app. They're different for each run.

After deploying, point your browser to the provided URL.

You can list information about the instance by running:

TerminalCode
unikraft instances list
TerminalCode
METRO NAME STATE IMAGE ARGS MEMORY VCPUS FQDN CREATED fra httpserver-java17-spring-petclinic-r4s3x running <my-org>/httpserver-java17-spring-petclinic 1024MiB 1 bitter-dust-a7b2c3d4.fra.unikraft.app 2 minutes ago

When done, you can remove the instance:

TerminalCode
unikraft instances delete <instance-name>

Learn more

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

TerminalCode
unikraft --help

Or visit the CLI Reference.

Last modified on