Spring PetClinic is an example project that uses Spring boot to model a simple pet clinic.
To run this example, follow these steps:
-
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.
-
Clone the
examplesrepository andcdinto theexamples/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 loginor
Using the legacy kraft CLI
# Set Unikraft Cloud access token
export UKC_TOKEN=token
# Set metro to Frankfurt, DE
export UKC_METRO=fraWhen 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:latestor
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 listMETRO 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 listNAME 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>Use the --help option for detailed information on using Unikraft Cloud:
Using the unikraft CLI (Recommended)
unikraft --helpor
Using the legacy kraft CLI
kraft cloud --helpOr visit the CLI Reference or the legacy CLI Reference.