Mender integration
Mender is an open source solution to manage a fleet of targets, including deploying software updates to them, in a reliable manner. This page details the instructions needed to perform an application deployment and update via Mender using the redpesk local builder and the hosted Mender infrastructure, which comprises the Mender-maintained servers.
In addition to requiring your redpesk local builder setup, you will need to open an account on https://hosted.mender.io so that you can connect your target there.
Hosted Mender account
The very first step is to proceed over to https://hosted.mender.io and follow the instructions there to open an account.
Target setup
The next part of the setup takes place on the target itself, as we will
configure the Mender client included in the image to connect to the Hosted
Mender servers at hosted.mender.io
. The following commands, unless noted,
will thus be run in your target SSH connection.
Your account on hosted.mender.io
gave you access to a tenant token. Under the
hosted.mender.io
UI, under the top-right menu, ‘My organization’ submenu.
Update the one below with yours (no spaces or newlines should be inserted).
export TENANT_TOKEN="HOSTED_MENDER_IO_TENANT_TOKEN"
Next, configure the Mender client to connect to the hosted.mender.io
server:
mender setup \
--device-type mb-box \
--hosted-mender \
--tenant-token $TENANT_TOKEN \
--retry-poll 30 \
--update-poll 5 \
--inventory-poll 5 && \
systemctl enable --now mender-client
The board will then connect to the hosted Mender servers. Go into your
hosted.mender.io
account UI and under the ‘Devices’ tab, pick up the new entry
corresponding to your board and authorize the device. The inventory information
(i.e extended target information) will typically load after 5 minutes.
Base localbuilder setup
Now go into your redpesk local builder SSH shell and perform the following steps.
First, check you are able to login to the Mender server on the commandline.
This is done via the /home/devel/bin/mender-cli
binary by specifying your hosted.mender.io
account username and password.
export MENDER_IO_USERNAME="<YOUR_HOSTED_MENDER_IO_USERNAME>"
export MENDER_IO_PASSWORD="<YOUR_HOSTED_MENDER_IO_PASSWORD>"
mender-cli login --server https://hosted.mender.io --username $MENDER_IO_USERNAME --password $MENDER_IO_PASSWORD
You should get a login successful
answer.
Artifact generation
All of Mender artifact generation is performed in the redpesk local builder console shell.
The /home/devel/bin/make-mender-artifact
script can be used to generate Mender
artifacts. Those are special tar archives which Mender uses for deployments to
the managed targets.
We will use mustach
, a sample application, to demo a typical Mender
application deployment. Please follow the standard instructions in the Local
Builder section to build the application once.
Once built, the mustach
RPM will be available under
/home/devel/build/RPMS/mustach-0.0.1-0.rpd28.aarch64.rpm
. It is the one we
will package into a Mender artifact.
Create the directory used to hold all artifacts so that we do not pollute the RPM build output:
export MENDER_DIR=/home/devel/build/MENDER
mkdir -p $MENDER_DIR
Generate a mender artifact for the RPM. By default, the artifact will be created
in the same directory as the RPM. We override this behavior via the
--output|-o
option to point to our artifact directory:
make-mender-artifact -o ~/build/MENDER ~/build/RPMS/mustach-0.0.1-0.rpd28.aarch64.rpm
Next, upload the artifact to the Mender server. As you previously logged in, you should not be asked for your password again.
upload-mender-artifact -u $MENDER_IO_USERNAME ~/build/MENDER/mustach-0.0.1-0.rpd28.aarch64.mender
The final step is to go to the hosted.mender.io
web UI. The newly uploaded
package will be available under the Releases tab:
One can then create a new Deployment targeting their device using it.
For more information on how to manage releases and create deployments for them, please see the hosted Mender documentation
Application updates
The next step is to modify the mustach app, for instance to add a version information switch as per this diff:
diff --git a/mustach-tool.c b/mustach-tool.c
index 364e34a..bdfa6f7 100644
--- a/mustach-tool.c
+++ b/mustach-tool.c
@@ -122,6 +122,10 @@ int main(int ac, char **av)
if (*++av) {
if (!strcmp(*av, "-h") || !strcmp(*av, "--help"))
help(prog);
+ if (!strcmp(*av, "-v") || !strcmp(*av, "--version")) {
+ printf ("Mustach v0.0.2\n");
+ exit(0);
+ }
if (av[0][0] == '-' && !av[0][1])
o = json_object_from_fd(0);
else
Next, rebuild the application as per the Local Builder instructions.
Do not forget to update the Version:
field in mustach.spec
as well.
Make a new artifact using make-mender-artifact
and upload it to the server:
make-mender-artifact ~/build/RPMS/mustach-0.0.2-0.rpd28.aarch64.rpm -o ~/build/MENDER
upload-mender-artifact -u $MENDER_IO_USERNAME ~/build/MENDER/mustach-0.0.2-0.rpd28.aarch64.mender
The newly uploaded artifact will be present in the UI to create a new deployment on the target.
Once deployment is done, one can verify the new package has been uploaded by querying the RPM database on the target itself:
$ rpm -q mustach
mustach-0.0.2-0.rpd28.aarch64
In case the deployment fails, the Mender UI provides access to the Mender client log from the
target, which can also be obtained via journalctl -u mender-client -e -f
(this
is useful to monitor a deployment too).