Skip to content

Latest commit

Β 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

README.md

C HTTP Server

This guide explains how to create and deploy a C app. 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-gcc13.2 directory:

    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 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-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:latest

or

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.app
Hello, World!

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-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 list
NAME                     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-is2s9

or

Using the legacy kraft CLI

kraft cloud instance remove httpserver-gcc132-is2s9

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.