Skip to content

Latest commit

Β 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

README.md

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 CLI. Use the unikraft CLI or the legacy kraft 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.

    Note: The unikraft CLI is the current standard, while kraft is the legacy version. Choose one of the CLIs below and only run the commands associated with it for the rest of this guide.

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

    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, πŸ‡©πŸ‡ͺ):

Using the unikraft CLI (Recommended)

unikraft login

or

Using the legacy kraft CLI

# Set Unikraft Cloud access token
export UKC_TOKEN=token
# Set metro to Frankfurt, DE
export UKC_METRO=fra

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

Using the unikraft CLI (Recommended)

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

or

Using the legacy kraft CLI

kraft cloud deploy --metro fra \
  -M 1Gi \
  -p 443:8080/tls+http \
  --scale-to-zero idle \
  --scale-to-zero-stateful \
  --scale-to-zero-cooldown 1s \
  .

The output shows the instance address and other details:

Using the unikraft CLI (Recommended)

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

or

Using the legacy kraft CLI

[●] Deployed successfully!
 β”‚
 β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€ name: httpserver-java17-spring-petclinic-r4s3x
 β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€ uuid: 5a3b7e2c-1f4d-4a8e-b6c9-2d3f8a1e7b4c
 β”œβ”€β”€β”€β”€β”€β”€β”€β”€ metro: https://api.fra.unikraft.cloud/v1
 β”œβ”€β”€β”€β”€β”€β”€β”€β”€ state: starting
 β”œβ”€β”€β”€β”€β”€β”€β”€ domain: https://bitter-dust-a7b2c3d4.fra.unikraft.app
 β”œβ”€β”€β”€β”€β”€β”€β”€β”€ image: oci://unikraft.io/<my-org>/httpserver-java17-spring-petclinic@sha256:3e9d1f8a7b2c4e5f6a3b8c2d1e4f7a8b9c0d1e2f3a4b5c6d7e8f9a0b1c2d3e4f
 β”œβ”€β”€β”€β”€β”€β”€β”€ memory: 1024 MiB
 β”œβ”€β”€β”€β”€β”€β”€ service: bitter-dust-a7b2c3d4
 β”œβ”€ private fqdn: httpserver-java17-spring-petclinic-r4s3x.internal
 └─── private ip: 10.0.4.2

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:

Using the unikraft CLI (Recommended)

unikraft instances list
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

or

Using the legacy kraft CLI

kraft cloud instance list
NAME                                      FQDN                                   STATE    STATUS        IMAGE                                                                     MEMORY   VCPUS  ARGS  BOOT TIME
httpserver-java17-spring-petclinic-r4s3x  bitter-dust-a7b2c3d4.fra.unikraft.app  running  1 minute ago  oci://unikraft.io/<my-org>/httpserver-java17-spring-petclinic@sha256:...  1.0 GiB  1            521.43 ms

When done, you can remove the instance:

Using the unikraft CLI (Recommended)

unikraft instances delete <instance-name>

or

Using the legacy kraft CLI

kraft cloud instance remove <instance-name>

Learn more

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

Using the unikraft CLI (Recommended)

unikraft --help

or

Using the legacy kraft CLI

kraft cloud --help

Or visit the CLI Reference or the legacy CLI Reference.