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)
Install Fermyon's Spin platform by following the guide linked below
https://developer.fermyon.com/spin/v2/quickstart#install-spin
Install Fermyon's plugin templates from git repository
spin templates install --git https://github.com/fermyon/spin --upgradeInstall additional tools by following the guide below
https://developer.fermyon.com/spin/v2/quickstart#install-the-tools
Install Spin Kube plugin
spin plugins install kubeInstall 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
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.
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.
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.
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.