This guide shows you how to use MongoDB, a source-available, cross-platform, document-oriented database program.
To run it, follow these steps:
-
Install the
kraftCLI tool and a container runtime engine, for example Docker. -
Clone the
examplesrepository andcdinto theexamples/mongodb/directory:
Code
Make sure to log into Unikraft Cloud by setting your token and a metro close to you.
This guide uses fra (Frankfurt, 🇩🇪):
Code
When done, invoke the following command to deploy this app on Unikraft Cloud:
Code
The output shows the instance address and other details:
Code
In this case, the instance name is mongodb-6tiuu which is different for each run.
To test the deployment, first forward the port with the kraft cloud tunnel command:
Code
Then, on a separate console, you can use the mongosh client to connect to the server:
Code
You should see output like:
Code
To disconnect, kill the tunnel command with Ctrl+c.
This guide uses kraft cloud tunnel only when a service doesn't support TLS and isn't HTTP-based (TLS/SNI determines the correct instance to send traffic to).
Also note that the tunnel command isn't needed when connecting via an
instance's private IP/FQDN.
For example when a MongoDB instance serves as a database server to another instance that acts as a frontend and which does support TLS.
You can list information about the instance by running:
Code
Code
When done, you can remove the instance:
Code
Customize your app
To customize the app, update the files in the repository, listed below:
Kraftfile: the Unikraft Cloud specification, including command-line argumentsDockerfile: In case you need to add files to your instance's rootfs
Learn more
Use the --help option for detailed information on using Unikraft Cloud:
Code
Or visit the CLI Reference.