Understanding Resin and ResinOS
I felt I needed to write this post about Resin.io, as I was jumping directly into deploying and building in a Raspberry Pi (see this post), just jumping from one tutorial to the next.
It is good to pace down, understand, and then go full speed.
Resin.io
Resin.io makes it simple to deploy, update, and maintain code running on remote devices. We are bringing the web development and deployment workflow to hardware, using tools like git and Docker to allow you to seamlessly update all your embedded linux devices in the wild. We handle cross-compilation, device monitoring, VPNs, and log collection, so you can focus on your product and not the infrastructure.
Highlights from How the code is deployed:
- Changes tracked and deployed from a Github repository
- Each Resin.io application as an unique remote repository associated
- Changes in
master
triggers a remote update on devices - Changes compiled in a cross-compiler docker container (i.e.
ARMv6
for the Raspberry Pi) - Compiler container updates the docker registry
- Possible to include a
Dockerfile
to further tune the process
ResinOS
ResinOS is an operating system optimised for running Docker containers on embedded devices
This is the other endpoint - the device side who handles the updates.
Highlights from What is ResinOS:
- Linux oriented
- Based on the Yocto Framework
2.0.0+rev2
recommended for production2.0.0+rev2-dev
is used for active development. The local mode (to build and sync in a local network) is only available in this mode- Docker socket exposed on via port
2377
, which allowsresin local push
to do remote Docker builds on the target device - 8 MB journald RAM buffer to avoid wear on the flash storage
- Stateless rootFS (Read-Only system), to keep configuration information a persistent partition is maintained
- However, persistent storage can be enabled by changing
"persistentLogging": true
in theconfig.json
file resin-boot
(as used in the Raspberry Pi) is a FAT32 partition for device boot configuration. Theconfig.json
file used by ResinOS is located here- Other partitions (read-only):
resin-rootA
: holds read-only root filesystemresin-rootB
: empty partition that is only used when the rootfs is to be updatedresin-state
: holds persistent dataresin-data
: holds downloaded Docker images
ResinOS is composed by the following services:
The resin.io supervisor
: a lightweight container that manages applications and communicates with Resin.io serversSystemd
: arrghDocker Engine
: a lightweight container runtime to build and run linux containers on resinOSNetworkManager and ModemManager
: manage connection to the Internet, either via ethenet, wifi or cellular modem. Asystem-connections
folder in the boot partition allows to replicate content in/etc/NetworkManager/system-connections
DNSmasq
: manage the nameserversAvahi
: advertises the device in the local networkOpenVPN server
: disabled by default, must be configured and activated
The BSP
for each platform is built using poki/yocto
meta packages, an example of how it is built for the Raspberry Pi is shown Here
The following language support is available: Nodejs, Python, Go and Java.
Wrap-up
That’s it - I just wanted to grab the basic concepts as I go through Resin.io and Docker. To run simple scripts (i.e. run a typical IoT sensor-application) seems an overkill, however it is practical as reduce the hurdles of device management, and it makes a lot of sense if scaling-up your application.