Services
On creation, Unikraft Cloud assigns each instance a private IP address and private FQDN for internal connectivity. It connects them to the Internet through a service: create a service and attach instances to it.
A service defines how to reach a group of instances from the outside world. It maps an external FQDN port to an internal port common to all instances. The platform load balances incoming connections across instances. Avoid placing apps that expose different ports in the same service.
If you use the kraft cloud deploy command, part of the output lists a service, for example:
(ansi)
Because kraft cloud deploy is a single command to deploy a service, it automatically creates a service and attaches the new instance to it.
The rest of this guide shows how to create a service first, then use kraft cloud deploy to create and attach instances to it.
First, create a new service with the kraft cloud service command:
(bash)
This creates a new service named my-service listening on port 443.
Unikraft Cloud terminates TLS and sends HTTP to port 8080.
This example assumes that the app opens port 8080.
Now use kraft cloud deploy with the --service flag to attach the instance to the my-service service.
For example, from the Go web server guide (see all guides here):
(bash)
This creates a new Go web server instance and immediately attaches it to the my-service service.
The output shows the instance address and other details:
(ansi)
In this case, the instance name is http-go121-fkt1x.
The address is https://my-service-rrtckyyi.fra.unikraft.app.
These values differ for each run.
Use curl to query the Go web server:
(bash)
(text)
If you specify a port with the -p option when using kraft cloud deploy, the command creates a service automatically.
In that case the platform deletes the service when the instance ends, and you can't define the service name.
That's it.
In the end, if you want to remove a service, use:
(bash)
Learn more
- The
kraft cloudCLI reference, in particular the services subcommand - Unikraft Cloud's REST API reference, in particular the section on services