Breaking

Tuesday, September 22, 2020

EdgeX Foundry:-

All the different types of IoT devices speak different languages and follow different protocols like BACnet, OPC-UA, MQTT, and REST. EdgeX foundry brings data from all different sources to a single platform and makes it available for the cloud. It a software solution that takes all that data in and normalized into a single format for the cloud and it's also able to control things.


It can also be configured to match individual data formats used by devices from different vendors by using device profiles. EdgeX Foundry is made up of a collection of microservices, each of which runs in a container. That you can see in the above picture. Microservices communicate with each other over REST API interfaces. It is able to convert source data from proprietary data formats into XML or JSON, encrypt, compress, and finally forward that data to an external source over MQTT or other protocols.


Installation of EdgeX Foundry would generally be done close to the sensors/data being generated. For example on an edge gateway appliance. There could be thousands of these, each with its own EdgeX installation, ingesting, converting, and forwarding data to a central location. While EdgeX runs as a collection of containerized microservices it doesn’t currently support k8s. Note that since the overhead for k8s can be prohibitive for low-powered edge nodes, lack of k8s support isn’t necessarily a concern.


Below we are going to discuss the installation setup of EdgeX foundry on Ubuntu 20.04 (VM).


Step 1: Installing Docker and docker-compose

If you are not aware of docker, you can read from here.

WHAT IS DOCKER AND HOW IT WORKS? 

Follow the process to install docker-engine. 

Run these command to update the system

$ sudo apt update

$ sudo apt upgrade -y


Now install the Docker-CE by verifying the certificate

$ sudo apt install apt-transport-https ca-certificates curl software-properties-common -y

$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -


Note: Match “ focal ” below with your distribution if different from 20.04 (check with “lsb_release -a” if unsure about the version):

$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"

$ sudo apt update

$ sudo apt install docker-ce -y


Now give permission to the current user to run docker binary and after that, log out and back in again to get the effect of new permissions.

$ sudo usermod -aG docker ${USER}


Now install docker-compose with the below command.

$ sudo apt install docker-compose -y


Step 2: Running EdgeX Foundry

We are going to run EdgeX using a docker-composer that manages the containers in the YAML file as a group. basically, it specifies how each microservice should run, its ports, volumes, and all dependencies.

First, create a directory for the EdgeX Foundry docker-compose.yml file.

$ mkdir edgex

$ cd edgex


Download the docker-compose.yml file from the link

$ wget https://raw.githubusercontent.com/edgexfoundry/developer-scripts/master/releases/geneva/compose-files/docker-compose-geneva-redis.yml

$ cp docker-compose-geneva-redis.yml docker-compose.yml


Pull the containers and list the newly downloaded images

$ docker-compose pull

$ docker image ls

EdgeX services

Start EdgeX Foundry using docker-compose

$ docker-compose up -d


List the running containers

$ docker-compose ps


Note that the ports used by EdgeX are listed for each container. These ports are defined in the docker-compose.yml file along with many other settings.


Step 3: Accessing EdgeX Foundry

We can interact with edgex either from the command line (using cURL, postman, etc..) or from the web browser(chrome, firefox, etc..).

To list out the registered device in edgex foundry we can run the curl command on the CLI.

$ curl http://<edgex ip>:48082/api/v1/device 


Or to get a structured output run:

$ sudo apt install jq

$ curl http://<edgex ip>:48082/api/v1/device | jq

edgex data

Similarly, we can make a POST method to send the sensor data and the GET method to get the data from EdgeX using any REST API libs like cURL or postman.


Note: The command “docker-compose ps” is helpful to find out the port number to get interact with that service.


We can also interact with EdgeX through UI. There are many UI available for EdgeX Foundry but we are using its own golang UI for this example.

a. Open the docker-compose.yml file in an editor

b. Add an entry for the golang ui under the “services” section as per the below:


ui:

container_name: edgex-ui-go

hostname: edgex-ui-go

image:

nexus3.edgexfoundry.org:10004/docker-edgex-ui-go:master

networks:

edgex-network: null

ports:

- "0.0.0.0:4000:4000/tcp"

read_only: true

edgex-ui-go

Note: compare the entries above and match the indentation.


c. Save and exit the editor

d. Start EdgeX Foundry

$ docker-compose up -d


e. The EdgeX UI can now be accessed in a browser at:

http://<edgex ip>:4000

EdgeX console


Note: If asked, use “admin” / “admin” for username / password.


Step 4: Stopping EdgeX Foundry

The commands in this section need to be issued from the folder containing the docker-compose.yml file (“edgex” in this example).

To just stop the containers:

$ docker-compose stop


To stop and remove the containers:

$ docker-compose down


To stop and remove containers + volumes (the original images will remain):

$ docker-compose down -v


Here is the video demonstration:-

In the next post, we will see how to send the sensor data to any server or cloud using the EdgeX foundry.

close