This guide explains how to create and deploy a C app. 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-gcc13.2directory:git clone https://github.com/unikraft-cloud/examples cd examples/httpserver-gcc13.2/
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-gcc132:latest
unikraft run --metro fra \
-m 256M \
-p 443:8080/tls+http \
--scale-to-zero policy=on,cooldown-time=1000 \
--image <my-org>/httpserver-gcc132:latestor
Using the legacy kraft CLI
kraft cloud deploy \
-M 256Mi \
-p 443:8080/tls+http \
--scale-to-zero on \
--scale-to-zero-cooldown 1s \
.The output shows the instance address and other details:
Using the unikraft CLI (Recommended)
metro: fra
name: httpserver-gcc132-is2s9
uuid: bec814ce-6ed5-4858-b247-e7f0b17750f5
state: starting
image: <my-org>/httpserver-gcc132
resources:
memory: 256MiB
vcpus: 1
service:
uuid: c36a4df6-b78d-677e-ea24-3e7a519a4130
name: still-resonance-bja3lste
domains:
- fqdn: still-resonance-bja3lste.fra.unikraft.app
networks:
- uuid: 0f17e562-b57a-d40b-eecc-74e9058ecaaf
private-ip: 10.0.0.49
mac: 12:b0:10:70:49:2f
timestamps:
created: just now
or
Using the legacy kraft CLI
[β] Deployed successfully!
β
ββββββββββ name: httpserver-gcc132-is2s9
ββββββββββ uuid: bec814ce-6ed5-4858-b247-e7f0b17750f5
βββββββββ metro: https://api.fra.unikraft.cloud/v1
βββββββββ state: starting
ββββββββ domain: https://still-resonance-bja3lste.fra.unikraft.app
βββββββββ image: oci://unikraft.io/<my-org>/httpserver-gcc132@sha256:375677bf052f14c18ca79c86d2f47a68f3ea5f8636bcd8830753a254f0e06c1b
ββββββββ memory: 256 MiB
βββββββ service: still-resonance-bja3lste
ββ private fqdn: httpserver-gcc132-is2s9.internal
ββββ private ip: 10.0.0.49
In this case, the instance name is httpserver-gcc132-is2s9 and the address is https://still-resonance-bja3lste.fra.unikraft.app.
They're different for each run.
Use curl to query the Unikraft Cloud instance:
curl https://still-resonance-bja3lste.fra.unikraft.appHello, World!
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-gcc132-is2s9 standby <my-org>/httpserver-gcc132 256MiB 1 still-resonance-bja3lste.fra.unikraft⦠2 minutes ago
or
Using the legacy kraft CLI
kraft cloud instance listNAME FQDN STATE STATUS IMAGE MEMORY VCPUS ARGS BOOT TIME
httpserver-gcc132-is2s9 still-resonance-bja3lste.fra.unikraft.app standby standby oci://unikraft.io/<my-org>/httpserver-gcc132@sha256:... 256 MiB 1 12.91 ms
When done, you can remove the instance:
Using the unikraft CLI (Recommended)
unikraft instances delete httpserver-gcc132-is2s9or
Using the legacy kraft CLI
kraft cloud instance remove httpserver-gcc132-is2s9Use 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.