Skip to content

Go SDK

The Unikraft Cloud Go module, sdk.kraft.cloud, provides complete lifecycle management for the deployment and management of instances, services and volumes on Unikraft Cloud. Please see pkg.go.dev for full details of the module.

Basic API Usage

A simple example which uses the kraftcloud.Client and starts an instance on the fra0 metro can be done via:

package main
import (
"context"
"fmt"
kraftcloud "sdk.kraft.cloud"
kcinstance "sdk.kraft.cloud/instances"
)
func main() {
ctx := context.TODO()
client := kraftcloud.NewClient(
kraftcloud.WithToken("<YOUR_API_TOKEN>"),
// Optional:
// kraftcloud.WithDefaultMetro("fra0"),
)
instance, err := client.Instances().WithMetro("fra0").Create(ctx, kcinstance.CreateInstanceRequest{
Autostart: true,
Image: "caddy:latest",
Name: "my-instance",
})
if err != nil {
panic(err)
}
fmt.Printf("%#v\n", instance)
}