DEV Community

Sergio Marin
Sergio Marin

Posted on • Originally published at itnext.io on

How I explain to my friends what we do at work

Pantahub and Pantavisor could sometimes be a difficult paradigm to understand because, in a way, it changes how we are related to the firmware and software of devices.

Today, when you don’t do something with an embedded device, maybe an IoT project or home automation with your Raspberry, you will go and flash your device with a Linux distribution and start to install packages and configure all of them via ssh, and if you need to replicate that you will do it all over again. Then if you want to automate that process a little bit you may create a shell script to do all the configuration and installation.

What happens if you have updated that script and you then need to update that configuration (let’s say you have only two devices), you need to go and run everything on both devices, hopefully via SSH. You can do some kind of more sophisticated thing here, there are a lot of tools for that, but maybe you are running this on a device with very little memory and your plans can fall apart.

But what we want to do is see devices and their configuration as you see Docker images and Docker containers, but you don’t even need to install and configure the device once. You only need to flash it with Pantahub. and then post revisions that will be deployed on the device. You can even set a device as leader of a pack, and the whole pack will follow the leader revisions automatically.

Let’s start by understanding all this terminology: devices, revisions, platforms, etc. For that let’s talk more about Pantahub and Pantavisor.

What is Pantahub?

Pantahub offers cloud-controlled firmware and software management for all kinds of Linux-based connected devices. In addition to this, Pantahub provides a community ecosystem for device makers, operators, and technology enthusiasts to gather around and share their work.

To use Pantahub, you will need to install Pantavisor on your devices.

What is Pantavisor?

Pantavisor is the Linux device init system that turns all the runtime into a set of container micro functions. Through Pantavisor, devices become software-defined infrastructure, through Linux container technology. All Pantavisor enabled devices can automatically connect to a Pantahub instance.

By using these two technologies you will be able to manage your devices and the software in a way similar (similar but not the same) to how you manage applications with docker.

However, instead of having a container running on the device, the device will run the PLATFORM directly on metal, allowing you to have versions of the device. This device state version is called REVISION , and inside Pantahub you will have the ability to return to a previous revision and, more importantly, the system is fault-tolerant. That means if you deploy a revision that can’t run correctly on the device, it will start the last revision that worked correctly with that, you can be sure that you won’t lose your device if you configure something in the wrong way or if the software has any kind of problem.

How the ecosystem works

The ecosystem could look similar to how you see containers on the Docker hub, but instead of containers, you will see devices.

Here you can see how a device is shown inside Pantahub.

A device in Pantahub represents a physical device, in this example a raspberry pi 3 b+ running several PLATFORMS /APPS inside.

Those PLATFORMS are built from a docker container, but inside of the device there isn’t any Docker runtime.

In this example you see a device running:

  • cloudflare : Platform installed by one.apps.pantahub.com to manage the DNS configuration and to set the DNS filters for your WIFI hotspot
  • awconnect : Manages the network and the wifi connections.
  • pv-avahi : Exposes an mDns configuration in order to be able to discover any Pantahub enabled device on the network using the PVR CLI or the Mobile application.
  • pvr-sdk : Manages some of the functionalities of the device like the SSH connection, the ability to follow devices, read user metadata and so much more.

With this, you can notice how a device is composed of several platforms and those platforms are based on docker containers. But remember there is not any docker container running on the device.

The device revision is described as a JSON file that is converted to a file system when you clone the device.

Let me explain with a visual example using the same device.

We call this JSON specification of the device revision state.json

As you can see the STATE is a normalized JSON with the folder structure of the device, where any .json file inside that structure is part of state.json and any other file format is represented by the sha256 of that file and is saved in Pantahub objects (our storage in the cloud)

When you use pvr clone URL_OF_DEVICE (just like a git clone), you will get the same structure as in the state.json but the files represented as sha256 are going to be downloaded.

The result is going to be a folder like this one.

Every platform lives in its own folder and all the configuration files live inside of the _config/${PLATFORM} folder

If you want to dive deep in all the available endpoints you can read the API reference here in the documentation or the swagger documentation here

Discussion (0)