Hubro Documentation Help

Extending Hubro

Hubro can be extended through individually authored plugins, each capable of serving various functions.

Typically, these functions may include:

  • Fetching data from an external source of data (e.g. REST API) (example)

  • Integration of an IoT connected device (example)

Fundamentally, plugins are crafted using Fermyon's Spin platform, and in terms of deployment, they reside within the same Kubernetes cluster as the core Hubro system. For proper functionality, developers need to implement a predefined API that facilitates communication between plugins and Hubro. For each study, it is necessary to activate plugins individually.

Authoring a new plugin

Preparations (only the first time)

  1. Install Fermyon's Spin platform by following the guide linked below

    https://developer.fermyon.com/spin/v2/quickstart#install-spin

  2. Install Fermyon's plugin templates from git repository

    spin templates install --git https://github.com/fermyon/spin --upgrade
  3. Install additional tools by following the guide below

    https://developer.fermyon.com/spin/v2/quickstart#install-the-tools

  4. Install Spin Kube plugin

    spin plugins install kube
  5. Install templates from our GitHub repository

    spin templates install --git https://github.com/hubro-platform/hubro-sdk --upgrade

Generating a new plugin from template

We, at Hubro, have prepared multiple templates that demonstrate how various types of plugins can be implemented. To generate a new plugin based on a pre-created template, run the following command

spin new --template hubro-http-rust

A directory structure similar to this will be created for you, offering a solid foundation for initiating the implementation of your plugin.

Hubro SDK

To facilitate creation of new plugins, we have created a Hubro SDK - a library written in Rust, that wraps communication with the core Hubro system from & to your plugin. You can use Hubro SDK to perform various tasks, such as pushing data to Hubro system, or listening to various events that occur in the system.

Basic use of Hubro SDK is examplified in the template, that you can use to scaffold a new plugin. To get more information about this library, refer to the documentation.

Testing

To build & start your plugin locally, run the command below within the newly generated folder for your plugin.

spin build --up

By default, this will expose your application on port 3000.

Deployment

Once you are happy with the way how your plugin works, you can start the deployment process to the Hubro server, by pushing your application's image to the OCI registry. For the sake of simplicity, you can use ttl.sh registry.

spin registry push --build ttl.sh/example-plugin:24h

Finally, you can deploy your plugin through Hubro admin interface.

Plugin management

Plugins can be managed by navigating into the Settings section and selecting the Plugins subsection. Over there, you can find ready-to-use plugins which you can individually install. You can also deploy custom plugins.

Screenshot 2024-08-23 at 7.28.57.png

Plugin installation under normal conditions takes few seconds. You can verify that the plugin has been installed by revisiting the page and making sure there's at least one replica running.

Screenshot 2024-08-23 at 7.29.30.png
Last modified: 23 September 2024