Skip to content
ImagineWorld

Installing an Edge Agent on an Edge Node

node_idnode-book_real-world-edge-computing_chapter-06-installing-an-edge-agent-on-an-edge-node
node_typechapter-node
schema_profileworld.chapter_node.v1
statusactive
entropyhigh
manifoldworld
domainimagineworld.net
authorityinforms
layercorpus
chapter_num6
chapter_titleInstalling an Edge Agent on an Edge Node
governed_byCORPUS
constitutional_citationCONSTITUTION
local graph

Chapter 6 — Installing an Edge Agent on an Edge Node

Section titled “Chapter 6 — Installing an Edge Agent on an Edge Node”

Now that you have a good idea why Edge computing is needed, what it takes to design and build such a scalable Edge platform, the technologies involved, and what an enterprise-class solution must consider from a workload life cycle management point of view, it is about time we get into the nuts and bolts of putting a practical system together.

For an application workload to be placed on an Edge node, an Edge Agent needs to be installed on the Edge node. Once the Edge Agent has been successfully installed, it works with the Management Hub to manage the complete life cycle of containerized application workload deployment and run the application on the Edge node. As described earlier, Edge nodes are broadly categorized into two types: Edge devices and Edge clusters. The process of installing the Edge Agent on both types of Edge nodes is similar.

In this chapter, we are going to cover the following main topics:

  • What is a Management Hub?
  • What is an Edge Agent?
  • Supported architectures and operating systems
  • Options to install the Edge Agent
  • Preparing the working environment
  • Setting up a non-root user
  • Installing the All-in-One (AIO) Open Horizon Management Hub
  • Installing the Edge Agent on an Edge device

To become proficient and practice hands-on examples, it’s required that you have access to an Ubuntu machine, Raspberry Pi, or Mac. Though the process is similar across all variants of Linux, we will be using Ubuntu or Rasbian for the examples in this chapter. While having access to two machines is not essential, it will be useful as we can use one machine for development and the other to observe the deployment of the workload. Also, one machine can have an Edge device node while the other machine can host the Open Horizon Management Hub.

As described in earlier chapters, though each Edge node functions autonomously, managing the Edge nodes requires a Management Hub. The Management Hub is where deployable services with access to underlying container images for the application workload and deployment policies are published. Once a node registers with its own set of properties, known as a node policy, the Management Hub determines what services need to go to which nodes as per the constraint of the service, as published in the deployment policy earlier. So, the Management Hub only participates in the control plane and is not involved in the data plane, which is the sole responsibility of the application code and developers.

As mentioned earlier, the Management Hub has several components, such as the exchange, agbot, secrets manager, Fido Device Onboard (FDO) system, model management system (MMS), and others, backed by several databases. All components are deployed as containers. In commercial deployments, they are deployed on a Red Hat OpenShift Container Platform (OCP) Kubernetes cluster infrastructure to provide scalability, resiliency, and reliability. The commercial Management Hub is deployed as a Kubernetes operator to make the deployment and maintenance tasks easy to manage.

An Edge Agent is a piece of code, about 30 MB in size, that runs as a systemd process on the Linux machine and provides all the capabilities necessary to run the containerized application workload. On Mac, the Edge Agent runs as a Docker container. Additionally, to manage containerized workloads on an Edge device, the Edge Agent requires the Docker or Podman runtime environment on the Linux host. The Edge Agent runs as a pod in a Kubernetes cluster on Edge servers.

Both the Management Hub and the Edge Agent were explained in more detail in Chapter 5, Application Placement and Life Cycle Management.

Supported architectures and operating systems

Section titled “Supported architectures and operating systems”

The Edge Agent can be run on various Edge devices, so long as they support the systemd process and either Docker or Podman runtime environments. This means that a wide range of Linux variants and CPU architectures are compatible, including the following:

  • Ubuntu
  • Debian
  • Raspbian
  • Red Hat Enterprise Linux (RHEL)
  • CentOS
  • MintOS
  • SuSE

The supported architectures span the following systems:

  • x86_64 or amd64
  • ARM
  • ARM64
  • RISC-V
  • Mac (both Intel and Apple silicon)
  • Power Systems
  • System-Z

For the latest supported versions and architectures, take a look at the official documentation that is available via IBM (https://www.ibm.com/docs/en/eam) or Open Horizon (https://github.com/open-horizon/).

The preparation work that’s required to install an Edge Agent on various hosts may be different but for the most part, an agent-install script makes the Edge Agent installation task easy for the user.

User interactions

Though the Edge Agent runs with root privilege, it is recommended that all user interactions with it be done as non-root users. Wherever necessary, the non-root user privilege may be raised using sudo. Doing so helps users avoid errors while working with the system.

The Open Horizon documentation describes several different ways to install the Edge Agent on Edge devices. The most important options are as follows:

  • Automated agent installation
  • Bulk agent installation
  • FDO-based agent installation

We’ll go through each in brief in the following subsections.

The Edge Agent installation process goes through several stages. At a high level, for the proper functioning of the Edge Agent, you must ensure that all prerequisite conditions are met, an Edge node architecture-specific binary is used, an appropriate Management Hub certificate is obtained, and an appropriate container runtime such as Docker or Podman is installed. The details are described in the manual agent installation process of the Open Horizon document 1. Given the complexity involving all these variabilities, the Open Horizon development team has done an excellent job of providing an automation script that considers the intricate details and installs the Edge Agent on Edge devices correctly. We will be using this approach in this book.

1 https://open-horizon.github.io/docs/installing/advanced_man_install/

When you have to manage a large number of Edge nodes, then manually installing Edge Agents on each node is not practical. That’s where the bulk agent installation technique comes in handy. If you look at the details, bulk agent installation makes use of the aforementioned automated agent installation technique and repeats the process for each Edge device. It is also possible to use Ansible or similar tools to manage bulk agent installation on a large number of nodes.

While manual, automated, and bulk installation techniques are handy tools for developers and DevOps personnel, these techniques still require access to each Edge node and access credentials to each device. To truly deploy hundreds or thousands of Edge devices, the process of securely installing the Edge Agent on Edge devices is passed to the device manufacturers. A technique called FDO has been developed by the Open Horizon community in partnership with industry leaders, including the FIDO alliance, Intel, and others.

In a nutshell, in following this approach, the device manufacturer generates a voucher for each Edge node and passes that to a rendezvous server. When an Edge device powers up with internet connectivity, it reaches out to the rendezvous server for instructions to download and install the Edge Agent. The developers of this approach have ensured that the end-to-end process is secured with cryptographically encrypted tokens that are assigned to each device by the manufacturer.

To learn about the details and the exact handoff process, see https://open-horizon.github.io/docs/installing/fdo/.

As we embark on learning about Open Horizon-based edge computing, it’s important to note that the environment we’re setting up is relatively small. In a real production environment, the Management Hub will be hosted on a Red Hat OCP Kubernetes infrastructure with multiple pods running various components of the hub. The Management Hub can be reached over the public internet. IBM provides a commercial offering of Open Horizon called IBM Edge Application Manager.

In contrast, the AIO environment that we will be setting up for this book will be in a LAN environment to keep the complexity low so that you can focus on learning the concepts and be able to practice them locally.

We suggest that you prepare at least two Ubuntu hosts – either two bare-metal machines or two VMs. Though you can do everything with one machine, having two machines makes it easier to follow the hands-on examples.

One machine will be used to host the Open Horizon Management Hub and the other will be used as an Edge device. The Management Hub machine must have a minimum of 4 cores, 4 GB of RAM, and 32 GB of storage.

In practice, there can be a large number of Edge nodes. As an exercise, you can add many more Edge devices over time.

We generally recommend that you use the Linux best practice of using least-privilege access mode for your users. To that end, we will always start with a non-root user who has sudo privilege and uses sudo to accomplish certain tasks as needed.

Follow these steps:

Tip

We have observed that when the administrative staff create a Linux VM, they usually give users full root access and leave it to the users to create non-root users. Subsequently, typical users will start using root itself for their tasks. However, this practice isn’t the most secure approach in a software environment. We strongly encourage users to create a non-root user, and that’s the direction we’ll follow. This may be somewhat redundant and if your environment is already configured accordingly, you may choose to skip this step. These or similar steps can be used to create a non-root user on all machines that we will use throughout this book. If you are conversant with the Linux environment, you may have a different set of steps to create a non-root user.

  1. Open a CLI Terminal to work on a Linux machine.
  2. Log in as a root user using
    ssh root@<ip-address-of-the-host>
  3. Add a user and make the user a member of the sudo
    useradd -s /bin/bash -d /home/<username> -m -G sudo <username>
  4. Add the user to the users group
    usermod -g users <username>
  5. Create a non-root user login password. When prompted, enter a password of
    passwd <username>
  6. Log out as a root
    exit or CTRL+D
  7. Log back in as a non-root
    ssh <username>@<ip-address-of-the-host>

Installing AIO Open Horizon Management Hub

Section titled “Installing AIO Open Horizon Management Hub”

Since this book is a practitioner book, you will need access to a Management Hub. The developers of Open Horizon have provided an AIO package that installs all the necessary components as a set of Docker containers. Follow https://open-horizon.github.io/docs/mgmt-hub/docs/ to install a Management Hub locally that we will use throughout this book as we learn to deploy workloads at the Edge:

  1. Open a CLI Terminal to work on a Linux machine that you plan to dedicate to running AIO Open Horizon Management Hub.
  2. Log in as a non-root
    ssh <username>@<ip-address-of-the-host>
  3. As a matter of practice, it is always a good idea to update and upgrade the Linux operating system. Follow through with the instructions as prompted regarding updating and upgrading your
    sudo apt update
    sudo apt upgrade
  4. Make a directory where you can git clone the repository. Use your preference to organize your working environment. In this example, we’ve done
    mkdir -p ~/github.com/PacktPublishing
    cd ~/github.com/PacktPublishing
  5. Run git clone for the Open Horizon devops repository. Note that at the time of writing we are using the latest version v2.26.12. While the community is proactive in maintaining backwards compatibility, it is always prudent to check the current version of Open Horizon and adjust for any changes that may have occurred. We do not need the entire repository, just a few of the scripts
    git clone https://github.com/open-horizon/devops.git
  6. Change to
    cd devops/mgmt-hub
  7. Review the deploy-mgmt-hub.sh script options with -h:
    ./deploy-mgmt-hub.sh -h
    By default, the preceding command does the following:
    • Installs the AIO Open Horizon Management Hub
      • Installs basic examples in the AIO Open Horizon Management Hub
      • Installs the Horizon CLI (hzn)
      • Installs the Edge Agent
      • Registers the Edge node We will do some of the steps separately to understand them in more detail by skipping the Edge device agent installation and registration process initially. Use the following command with option as specified to install the AIO Open Horizon Management Hub, the hzn CLI, and the basic examples only:
    • -A: Skips installing the Edge device agent
      • -R: Skips registering the Edge node

Important note

The AIO Open Horizon Management Hub will be used by all the Edge nodes within the LAN only. To keep complexity low, we will be using an http connection, although https can be enabled as well. The IBM Edge Application Manager, a commercial product, provides full https connectivity and access to the public internet.

export HZN_LISTEN_IP=<the-ip-address-of-this-host>
sudo -s -E ./deploy-mgmt-hub.sh -A -R

After around 5 minutes, AIO Open Horizon Management Hub will be installed with a detailed log that you will see in your Terminal.

Important note

Make sure to follow the instruction that is displayed at the end of the install.

  1. Save all the export credentials shown in the Terminal in a secure location. Some of them will be needed when you start using the AIO Open Horizon Management Hub.
  2. Run the docker ps command to see running Docker containers that make up the AIO Open Horizon Management Hub:
    sudo docker ps
    Here’s an example output:
    CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
    830be5e4d131 openhorizon/amd64_agbot:latest "/bin/sh -c /usr/hor…" 26 minutes ago Up 24 minutes (healthy) 127.0.0.1:3110->8080/tcp, 192.168.200.131:3111->8083/tcp agbot
    d7560063fd18 openhorizon/fdo-owner-services:testing "/bin/sh -c $WORKDIR…" 26 minutes ago Up 25 minutes (unhealthy) 0.0.0.0:8042->8042/tcp, :::8042->8042/tcp, 0.0.0.0:9008->9008/tcp, :::9008->9008/tcp fdo-owner-services
    239cc41700b2 openhorizon/amd64_vault:latest "entrypoint.sh server" 26 minutes ago Up 26 minutes (healthy) 192.168.200.131:8200->8200/tcp vault
    9c3fa4382714 openhorizon/amd64_cloud-sync-service:latest "/usr/edge-sync-serv…" 26 minutes ago Up 26 minutes (healthy) 192.168.200.131:9443->8080/tcp css-api
    4ad61c145437 openhorizon/amd64_exchange-api:latest "/bin/sh -c '/usr/bi…" 26 minutes ago Up 26 minutes (healthy) 8083/tcp, 192.168.200.131:3090->8080/tcp exchange-api
    54443d9e6619 mongo:4.0.6 "Docker-entrypoint.s…" 26 minutes ago Up 26 minutes (healthy) 27017/tcp mongo
    adc47eab1a15 postgres:13 "Docker-entrypoint.s…" 26 minutes ago Up 26 minutes (healthy) 0.0.0.0:5433->5432/tcp, :::5433->5432/tcp postgres-fdo-owner-service
    58e2f9c33089 postgres:13 "Docker-entrypoint.s…" 26 minutes ago Up 26 minutes (healthy) 0.0.0.0:5432->5432/tcp, :::5432->5432/tcp postgres

Tip

To avoid needing to use sudo with Docker commands, add your username to the Docker group. This will become effective the next time you log in:

sudo usermod -aG Docker <user-name>
  1. Perform a few simple tests by exporting and running the following commands for the HZN_ORG_ID and HZN_EXCHANGE_USER_AUTH
    export HZN_ORG_ID=myorg
    export HZN_EXCHANGE_USER_AUTH=admin:<as-per-your-above-install>
  2. Run the following commands to verify your installation:
    1. Check the hzn CLI version. Your version may be different:
    hzn version
    Here’s an example output:
    Horizon CLI version: 2.30.0-1491
    Horizon Agent version: failed to get.
    If Horizon Agent version is set to failed to get, that’s fine since we didn’t install the Edge Agent on this machine by choice.
    1. Check the AIO Open Horizon Management Hub version. Your version may be different:
    hzn exchange version
    Here’s an example output:
    2.110.4
    1. Test user credentials:
    hzn exchange user list
    Here’s an example output:
    {
    "myorg/admin": {
    "password": "********",
    "email": "not@used",
    "admin": true,
    "hubAdmin": false,
    "lastUpdated": "2024-02-13T02:09:45.344124229Z[UTC]",
    "updatedBy": "root/root"
    }
    }
    1. The following are a few other helpful commands for verifying your installation:
    hzn exchange node list
    hzn exchange service list IBM/
    hzn exchange pattern list IBM/

With that, we’ve installed the AIO Open Horizon Management Hub. You will be using it throughout this book. If any of the previous commands fail then it’s most likely that you have not exported the ENVIRONMENT variables as instructed. Do save them in a file so that you can source them again as needed.

Installing the Edge Agent on an Edge device

Section titled “Installing the Edge Agent on an Edge device”

Now that we have AIO Open Horizon Management Hub installed, we can make use of it to install an Edge Agent on an Edge device. Follow these steps:

  1. Open a CLI Terminal to work on a Linux VM that you plan to use as an Edge device node. We will be installing Edge Agent on it.
  2. Log in as a non-root
    ssh <username>@<ip-address-of-the-host>
  3. Update and upgrade the Linux operating system. Follow the instructions as prompted about updating and upgrading your
    sudo apt update
    sudo apt upgrade
  4. Make a directory in the git-cloned agent-install repository. Organize your working environment as per
    mkdir -p ~/github.com/PacktPublishing
    cd ~/github.com/PacktPublishing
  5. Ruin git clone for the Open Horizon anax repository. Note that at the time of writing we are using the latest version v2.30.0-1491. While the community is proactive in maintaining backwards compatibility, it is always prudent to check the current version of Open Horizon and adjust for any changes that may have occurred. We don’t need the entire repository, just a
    git clone https://github.com/open-horizon/anax.git
  6. Change to the anax
    cd anax/agent-install
  7. Create a directory where you will keep all the environment variables in a file – for ENV_OH_AIO_AGENT_INSTALL
    mkdir ~/oh-agent
  8. Save the following information in a file – for ~/oh-agent/ENV_OH_AIO_AGENT_INSTALL
    export HZN_ORG_ID=myorg
    export HZN_EXCHANGE_USER_AUTH=admin:<as-per-your-AIO-install>
    export HZN_EXCHANGE_URL=http://<ip-address-of-the-VM-running-AIO-OH-mgmt-hub>:3090/v1
    export HZN_FSS_CSSURL=http://<ip-address-of-the-VM-running-AIO-OH-mgmt-hub>:9443/
    export HZN_AGBOT_URL=http://<ip-address-of-the-VM-running-AIO-OH-mgmt-hub>:3111
    export HZN_FDO_SVC_URL=http://<ip-address-of-the-VM-running-AIO-OH-mgmt-hub>:9008/api
    export HZN_DEVICE_ID=<arbitrary-edge-node-name>
    export ANAX_LOG_LEVEL=<log-level-3-is-a-good-choice>
  9. Source the preceding environment variables and verify that the HZN values have been
    source ~/oh-agent/ENV_OH_AIO_AGENT_INSTALL
    env | grep HZN
  10. Install the Edge Agent using the following command. Using -s skips the
    sudo -s -E ./agent-install.sh -i 'anax:' -s
  11. Run the following commands to verify the installation edge-agent
    hzn version
    hzn exchange version
    hzn exchange user list
    hzn exchange service list IBM/
    hzn exchange pattern list IBM/
    hzn exchange node list

You used these commands earlier in this section. They will be explained in more detail in Chapter 8.

Tip

As mentioned earlier, the agent-install.sh script installs as a systemd process and status. Both can be viewed by running sytemctl status horizon.

The process name is anax and can be viewed by running ps -aef | grep anax.

The Edge Agent also creates a file called /etc/default/horizon that contains the necessary details about the EXCHANGE URL, DEVICE ID, NODE ID, and other related values. You should review it.

With that, we’ve installed the Edge Agent on the Edge device.

In this chapter, you were introduced to Management Hub and the Edge device agent, along with instructions on how to install them in your local Linux environment. You were also introduced to some of the hzn CLI commands that we’ll be utilizing extensively throughout this book.

In the next chapter, you will learn how to register an Edge device node with the Open Horizon Management Hub.