From babbb610d90819cb012795bbb7c845521f6ff3ed Mon Sep 17 00:00:00 2001 From: mariobassem Date: Wed, 5 Feb 2025 11:51:05 +0200 Subject: [PATCH] feat(tfgrid3deployer): add openwebui deployment example - Adds a new example demonstrating deployment of OpenWebUI on the ThreeFold Grid using the `tfgrid3deployer` module. - Provides detailed instructions and a README file for easy setup and execution. Co-authored-by: mahmmoud.hassanein --- .../open_webui_gw/open_webui_gw.vsh | 41 ++++++++++++++ .../tfgrid3deployer/open_webui_gw/readme.md | 53 +++++++++++++++++++ 2 files changed, 94 insertions(+) create mode 100755 examples/threefold/tfgrid3deployer/open_webui_gw/open_webui_gw.vsh create mode 100644 examples/threefold/tfgrid3deployer/open_webui_gw/readme.md diff --git a/examples/threefold/tfgrid3deployer/open_webui_gw/open_webui_gw.vsh b/examples/threefold/tfgrid3deployer/open_webui_gw/open_webui_gw.vsh new file mode 100755 index 00000000..08814a67 --- /dev/null +++ b/examples/threefold/tfgrid3deployer/open_webui_gw/open_webui_gw.vsh @@ -0,0 +1,41 @@ +#!/usr/bin/env -S v -gc none -no-retry-compilation -d use_openssl -enable-globals -cg run + +//#!/usr/bin/env -S v -gc none -no-retry-compilation -cc tcc -d use_openssl -enable-globals -cg run +import freeflowuniverse.herolib.threefold.gridproxy +import freeflowuniverse.herolib.threefold.tfgrid3deployer +import freeflowuniverse.herolib.installers.threefold.griddriver +import os +import time + +griddriver.install()! + +v := tfgrid3deployer.get()! +println('cred: ${v}') + +deployment_name := 'openwebui_example' +mut deployment := tfgrid3deployer.new_deployment(deployment_name)! + +deployment.add_machine( + name: 'vm1' + cpu: 1 + memory: 16 + planetary: true + size: 100 // 10 gig + flist: 'https://hub.grid.tf/mariobassem1.3bot/docker.io-threefolddev-open_webui-latest.flist' +) +deployment.deploy()! + +vm1 := deployment.vm_get('vm1')! +println('vm1 info: ${vm1}') + +deployment.add_webname( + name: 'openwebui' + backend: 'http://${vm1.wireguard_ip}:8080' + use_wireguard_network: true +) +deployment.deploy()! + +gw1 := deployment.webname_get('openwebui')! +println('gw info: ${gw1}') + +// tfgrid3deployer.delete_deployment(deployment_name)! diff --git a/examples/threefold/tfgrid3deployer/open_webui_gw/readme.md b/examples/threefold/tfgrid3deployer/open_webui_gw/readme.md new file mode 100644 index 00000000..11ab11ea --- /dev/null +++ b/examples/threefold/tfgrid3deployer/open_webui_gw/readme.md @@ -0,0 +1,53 @@ +# OpenWebUI Deployment on ThreeFold Grid + +## Overview +This script automates the deployment of an OpenWebUI instance on the ThreeFold Grid using the `tfgrid3deployer` module. It sets up a virtual machine (VM), configures networking, and assigns a webname for easy access. + +## Requirements +- V compiler installed +- OpenSSL support enabled +- herolib dependencies: + - `freeflowuniverse.herolib.threefold.gridproxy` + - `freeflowuniverse.herolib.threefold.tfgrid3deployer` + - `freeflowuniverse.herolib.installers.threefold.griddriver` + +## Installation +Ensure you have the required dependencies installed. The script will automatically install the `griddriver` before proceeding. + +## Usage +Run the script using the following command: + +```sh +./open_webui_gw.vsh +``` + +### Script Execution Steps +1. Installs the necessary ThreeFold Grid driver. +2. Retrieves credentials for deployment. +3. Creates a new deployment named `openwebui_example`. +4. Adds a VM with the following specifications: + - 1 CPU + - 16GB RAM + - 100GB storage + - Uses planetary networking + - Deploys OpenWebUI from the ThreeFold Hub. +5. Deploys the VM. +6. Retrieves VM information. +7. Configures a webname (`openwebui`) pointing to the VM's backend. +8. Deploys the webname for public access. +9. Retrieves and displays webname gateway details. + +## Cleanup +To delete the deployment, run the following line in the script: + +```v +tfgrid3deployer.delete_deployment(deployment_name)! +``` + + +## Gateway Information +The gateway points to the WireGuard IP of the VM on port 8080, which is the port that the OpenWebUI server is listening on. + +## Notes +- Ensure you have a valid ThreeFold Grid account and necessary permissions to deploy resources. +- Adjust VM specifications based on your requirements.