Skip to content

Managing Nodes with Labels

This tutorial demonstrates the management of multiple nodes via labels using the Edge Builder CLI. This will cover how to:

Initialise Edge Builder server components and CLI for multiple nodes

To initialize the Edge Builder server components and CLI, complete the following steps:

  1. Set up the environment as described in Tutorials Setup section and ensure that the environment variable NODE_COUNT is set to 3 before you execute vagrant up.
    export NODE_COUNT=3
    vagrant up
    
  2. The names and status of all the VMs can be viewed by using the vagrant status command:

    vagrant status
    Current machine states:
    
    master                    running (virtualbox)
    node1                     running (virtualbox)
    node2                     running (virtualbox)
    node3                     running (virtualbox)
    

  3. SSH into the master node:

    vagrant ssh master
    

  4. Start the Edge Builder server components using the following command:

    sudo edgebuilder-server up -a 192.168.56.10
    
    When the server components are up, you should see all server components up and running via the docker ps command:
    vagrant@master:~$ docker ps
    
    CONTAINER ID   IMAGE                                    COMMAND                  CREATED          STATUS          PORTS                                                                                                                                                     NAMES
    54216df43569   iotechsys/dev-eb-controller:1.2.0.dev    "./entrypoint.sh"        19 seconds ago   Up 16 seconds   0.0.0.0:8085->8085/tcp, :::8085->8085/tcp, 0.0.0.0:50000-50100->50000-50100/tcp, :::50000-50100->50000-50100/tcp, 0.0.0.0:1022->22/tcp, :::1022->22/tcp   eb-controller
    28e962d77a00   chronograf:1.8.8-alpine                  "./custom-entrypoint…"   21 seconds ago   Up 19 seconds   0.0.0.0:8888->8888/tcp, :::8888->8888/tcp                                                                                                                 eb-chronograf
    706d2b19acf4   postgres:alpine                          "./entrypoint.sh"        24 seconds ago   Up 21 seconds   5432/tcp                                                                                                                                                  eb-db
    83f4b4298be4   influxdb:1.8.1-alpine                    "./custom-entrypoint…"   24 seconds ago   Up 21 seconds   0.0.0.0:8086->8086/tcp, :::8086->8086/tcp                                                                                                                 eb-influxdb
    c2981b5cbce7   portainer/portainer-ce:2.1.0-alpine      "/portainer -H unix:…"   24 seconds ago   Up 20 seconds   0.0.0.0:8000->8000/tcp, :::8000->8000/tcp, 0.0.0.0:9000->9000/tcp, :::9000->9000/tcp                                                                      eb-portainer
    5d4110072447   iotechsys/dev-eb-redis:1.2.0.dev         "redis-server /etc/r…"   24 seconds ago   Up 20 seconds   6379/tcp                                                                                                                                                  eb-redis
    64901e67177b   iotechsys/dev-eb-webssh:1.2.0.dev        "wssh --address=0.0.…"   24 seconds ago   Up 21 seconds   0.0.0.0:8989->8989/tcp, :::8989->8989/tcp                                                                                                                 eb-webssh
    34811b289512   grafana/grafana:7.4.2                    "/run.sh"                24 seconds ago   Up 21 seconds   0.0.0.0:3000->3000/tcp, :::3000->3000/tcp                                                                                                                 eb-grafana
    ac79f2182e86   iotechsys/dev-eb-salt-master:1.2.0.dev   "/bin/sh -c 'sed -i …"   24 seconds ago   Up 20 seconds   0.0.0.0:4505-4506->4505-4506/tcp, :::4505-4506->4505-4506/tcp, 0.0.0.0:8099->8099/tcp, :::8099->8099/tcp                                                  eb-salt-master
    6583228fa467   kapacitor:1.5-alpine                     "/entrypoint.sh kapa…"   24 seconds ago   Up 21 seconds   9092/tcp                                                                                                                                                  eb-kapacitor
    6659e040296e   vault:1.7.1                              "./entrypoint.sh"        24 seconds ago   Up 21 seconds   8200/tcp                                                                                                                                                  eb-vault
    

  5. Log in to Edge Builder with the default user credentials using the following command:

    edgebuilder-cli user login -u iotech -p EdgeBuilder123 -c "http://192.168.56.10:8085"
    
    You should see the following INFO message:
    INFO: User "iotech" logged in successfully
    

  6. Confirm that you have a valid license in the Vagrant project directory (edgebuilder-vagrant)

  7. Add the license using the following command:
    edgebuilder-cli license add -l DemoLicense -f /vagrant/EdgeBuilder_test_Evaluation.lic
    
    You should see the output similar to that shown below:
    INFO: License added successfully
    +-------------+--------------------------------------+---------------------------------+-----------+-----------+
    | NAME        | ID                                   | FILENAME                        | MAX NODES | EXPIRY    |
    +-------------+--------------------------------------+---------------------------------+-----------+-----------+
    | DemoLicense | b65c2ba0-c78b-4031-aaf4-cc030d3d763d | EdgeBuilder_test_Evaluation.lic | 100       | unlimited |
    +-------------+--------------------------------------+---------------------------------+-----------+-----------+
    INFO: Viewing 1 result(s)
    

Create multiple nodes

In this section of the tutorial, three Edge Nodes will be added. To add the nodes, complete the following steps:

  1. Confirm that you have the example multi node configuration file using the cat command:
    cat /vagrant/examples/multi-node-config.json
    
    Expected output:
    {
      "NodeConfig": [
        {
          "name": "node1",
          "description": "virtual node 1",
          "nodeaddress": "192.168.56.11",
          "nodesshport": "22",
          "username": "vagrant",
          "password": "vagrant",
          "serveraddress": "192.168.56.10",
          "labels" : ["node_label1"]
        },
        {
          "name": "node2",
          "description": "virtual node 2",
          "nodeaddress": "192.168.56.12",
          "nodesshport": "22",
          "username": "vagrant",
          "password": "vagrant",
          "serveraddress": "192.168.56.10",
          "labels" : ["node_label2"]
        },
        {
          "name": "node3",
          "description": "virtual node 3",
          "nodeaddress": "192.168.56.13",
          "nodesshport": "22",
          "username": "vagrant",
          "password": "vagrant",
          "serveraddress": "192.168.56.10",
          "labels" : ["node_label3"]
        }
      ]
    }
    
  2. Add the nodes to Edge Builder using the following command:

    edgebuilder-cli node add -f /vagrant/examples/multi-node-config.json
    
    Expected Output:
    INFO: SSH Node(s) added successfully:
    +-------+--------------------------------------+-------------+
    | NODE  | ID                                   | LABELS      |
    +-------+--------------------------------------+-------------+
    | node1 | c60a626b-b8a4-4c37-9ae2-ca3ca0411cbb | node_label1 |
    | node2 | 21150da0-6577-46f3-9692-89f387be8445 | node_label2 |
    | node3 | 8ec12783-da7e-4e10-a57e-f4538e2d2e21 | node_label3 |
    +-------+--------------------------------------+-------------+
    INFO: Viewing 3 result(s)
    

  3. Confirm that the nodes have been added using the following command:

    edgebuilder-cli node view --all
    
    Expected Output:
    INFO: Finding all nodes...
    INFO: *** Node View Results ***
    +-------+--------------------------------------+--------+------------+--------------+------------------------------------------+----------------+
    | NAME  | ID                                   | STATUS | DEBUG MODE | METRICS MODE | LABELS                                   | DESCRIPTION    |
    +-------+--------------------------------------+--------+------------+--------------+------------------------------------------+----------------+
    | node1 | c60a626b-b8a4-4c37-9ae2-ca3ca0411cbb | Up     | Off        | Local        | Language:en_US, OSFamily:Debian, Product | virtual node 1 |
    |       |                                      |        |            |              | Name:VirtualBox, Kernel:Linux, Manufactu |                |
    |       |                                      |        |            |              | rer:innotekGmbH, UserName:root, OSArch:a |                |
    |       |                                      |        |            |              | md64, GroupName:root, Virtual:VirtualBox |                |
    |       |                                      |        |            |              | , OSFinger:Ubuntu-20.04, Timezone:UTC, H |                |
    |       |                                      |        |            |              | ostname:node1, CPUModel:11thGenIntel(R)C |                |
    |       |                                      |        |            |              | ore(TM)i7-11800H@2.30GHz, CPUArch:x86_64 |                |
    |       |                                      |        |            |              | , node_label1                            |                |
    | node2 | 21150da0-6577-46f3-9692-89f387be8445 | Up     | Off        | Local        | Language:en_US, Hostname:node2, OSFamily | virtual node 2 |
    |       |                                      |        |            |              | :Debian, ProductName:VirtualBox, Kernel: |                |
    |       |                                      |        |            |              | Linux, node_label2, Manufacturer:innotek |                |
    |       |                                      |        |            |              | GmbH, UserName:root, OSArch:amd64, Group |                |
    |       |                                      |        |            |              | Name:root, Virtual:VirtualBox, OSFinger: |                |
    |       |                                      |        |            |              | Ubuntu-20.04, Timezone:UTC, CPUModel:11t |                |
    |       |                                      |        |            |              | hGenIntel(R)Core(TM)i7-11800H@2.30GHz, C |                |
    |       |                                      |        |            |              | PUArch:x86_64                            |                |
    | node3 | 8ec12783-da7e-4e10-a57e-f4538e2d2e21 | Up     | Off        | Local        | Language:en_US, OSFamily:Debian, Product | virtual node 3 |
    |       |                                      |        |            |              | Name:VirtualBox, Kernel:Linux, node_labe |                |
    |       |                                      |        |            |              | l3, Manufacturer:innotekGmbH, UserName:r |                |
    |       |                                      |        |            |              | oot, OSArch:amd64, GroupName:root, Hostn |                |
    |       |                                      |        |            |              | ame:node3, Virtual:VirtualBox, OSFinger: |                |
    |       |                                      |        |            |              | Ubuntu-20.04, Timezone:UTC, CPUModel:11t |                |
    |       |                                      |        |            |              | hGenIntel(R)Core(TM)i7-11800H@2.30GHz, C |                |
    |       |                                      |        |            |              | PUArch:x86_64                            |                |
    +-------+--------------------------------------+--------+------------+--------------+------------------------------------------+----------------+
    INFO: Viewing 3 result(s)
    

    Note

    • The node status is initially shown as Deploying. After a few minutes, you can re-issue the command and the status will have changed to Up
    • You can also use the watch command with the node view above to automatically track the status changes
    • A number of standard labels can been seen, these are automatically populated

Add a custom label to the nodes

In this section we associate the label label4 with our nodes.

  1. Execute the following command to add the label label4 to all of our nodes:

    edgebuilder-cli node labels -n node1,node2,node3 --add label4
    
    Expected Output:
    INFO: Labels updated successfully for node "node2"
    INFO: Labels updated successfully for node "node1"
    INFO: Labels updated successfully for node "node3"
    

  2. You can verify that the label has been added by using it to view the nodes:

    edgebuilder-cli node view -l label4
    
    Expected Output:
    INFO: Finding nodes with labels: label4
    INFO: *** Node View Results ***
    +-------+--------------------------------------+--------+------------+--------------+------------------------------------------+----------------+
    | NAME  | ID                                   | STATUS | DEBUG MODE | METRICS MODE | LABELS                                   | DESCRIPTION    |
    +-------+--------------------------------------+--------+------------+--------------+------------------------------------------+----------------+
    | node1 | c60a626b-b8a4-4c37-9ae2-ca3ca0411cbb | Up     | Off        | Local        | Language:en_US, label4, OSFamily:Debian, | virtual node 1 |
    |       |                                      |        |            |              |  ProductName:VirtualBox, Kernel:Linux, M |                |
    |       |                                      |        |            |              | anufacturer:innotekGmbH, UserName:root,  |                |
    |       |                                      |        |            |              | OSArch:amd64, GroupName:root, Virtual:Vi |                |
    |       |                                      |        |            |              | rtualBox, OSFinger:Ubuntu-20.04, Timezon |                |
    |       |                                      |        |            |              | e:UTC, Hostname:node1, CPUModel:11thGenI |                |
    |       |                                      |        |            |              | ntel(R)Core(TM)i7-11800H@2.30GHz, CPUArc |                |
    |       |                                      |        |            |              | h:x86_64, node_label1                    |                |
    | node2 | 21150da0-6577-46f3-9692-89f387be8445 | Up     | Off        | Local        | Language:en_US, Hostname:node2, label4,  | virtual node 2 |
    |       |                                      |        |            |              | OSFamily:Debian, ProductName:VirtualBox, |                |
    |       |                                      |        |            |              |  Kernel:Linux, node_label2, Manufacturer |                |
    |       |                                      |        |            |              | :innotekGmbH, UserName:root, OSArch:amd6 |                |
    |       |                                      |        |            |              | 4, GroupName:root, Virtual:VirtualBox, O |                |
    |       |                                      |        |            |              | SFinger:Ubuntu-20.04, Timezone:UTC, CPUM |                |
    |       |                                      |        |            |              | odel:11thGenIntel(R)Core(TM)i7-11800H@2. |                |
    |       |                                      |        |            |              | 30GHz, CPUArch:x86_64                    |                |
    | node3 | 8ec12783-da7e-4e10-a57e-f4538e2d2e21 | Up     | Off        | Local        | Language:en_US, label4, OSFamily:Debian, | virtual node 3 |
    |       |                                      |        |            |              |  ProductName:VirtualBox, Kernel:Linux, n |                |
    |       |                                      |        |            |              | ode_label3, Manufacturer:innotekGmbH, Us |                |
    |       |                                      |        |            |              | erName:root, OSArch:amd64, GroupName:roo |                |
    |       |                                      |        |            |              | t, Hostname:node3, Virtual:VirtualBox, O |                |
    |       |                                      |        |            |              | SFinger:Ubuntu-20.04, Timezone:UTC, CPUM |                |
    |       |                                      |        |            |              | odel:11thGenIntel(R)Core(TM)i7-11800H@2. |                |
    |       |                                      |        |            |              | 30GHz, CPUArch:x86_64                    |                |
    +-------+--------------------------------------+--------+------------+--------------+------------------------------------------+----------------+
    INFO: Viewing 3 result(s)
    

Create app definition

In this section of the tutorial, we will register an app definition.

  1. Confirm that you have the example app definition configuration file using the cat command:

    cat /vagrant/examples/app-def-config.json
    
    Expected Output:
    {
      "AppDefinitionConfig": [
        {
          "Name": "SimpleWebServer",
          "Description": "Node docker-compose appDefinition",
          "FilePath": "/vagrant/examples/docker-compose.yaml",
          "Type": "docker-compose",
          "Labels": ["appLabel1","appLabel2"]
        }
      ]
    }
    

  2. Confirm that you have the example docker compose file, which defines a simple web server that prints a greeting, using the following command:

    cat /vagrant/examples/docker-compose.yaml
    
    Expected output:
    version: "3"
    
    services:
    simple-webserver:
    image: nginx
    ports:
        - 55555:80
    volumes:
        - /home/vagrant/src:/usr/share/nginx/html
    

  3. Add the app definition to Edge Builder using the following command:

    edgebuilder-cli appDefinition add -f /vagrant/examples/app-def-config.json
    
    Expected output:
    INFO: AppDefinition(s) added successfully:
    +-----------------+--------------------------------------+----------------------+
    | NAME            | ID                                   | LABELS               |
    +-----------------+--------------------------------------+----------------------+
    | SimpleWebServer | d23d15da-2147-4f16-95f9-09717ecfec06 | appLabel1, appLabel2 |
    +-----------------+--------------------------------------+----------------------+
    INFO: Viewing 1 result(s)
    

Deploy an app to nodes by label

In this section of the tutorial, we deploy the simple web server application to all nodes with the label label4.

  1. Create the app on the nodes using the following command:

     edgebuilder-cli app create -d SimpleWebServer --node-label label4
    
    Expected output:
    INFO: Creating app(s):
    +------------------------------------------------------+--------------------------------------+----------+--------------------------------------+--------+
    | APP NAME                                             | APP ID                               | STATUS   | NODE ID                              | LABELS |
    +------------------------------------------------------+--------------------------------------+----------+--------------------------------------+--------+
    | SimpleWebServer_089d2f5b-8e8a-4d56-93ae-bb76b5371043 | 089d2f5b-8e8a-4d56-93ae-bb76b5371043 | Creating | 00b81c62-afb9-43cc-b180-a0f6546995d8 |        |
    | SimpleWebServer_6f8b47cb-0518-4491-bdde-8715647a45ee | 6f8b47cb-0518-4491-bdde-8715647a45ee | Creating | d59aecb8-1d30-46e8-9838-3987d31470a3 |        |
    | SimpleWebServer_04225f79-06fe-4c08-ad00-95f84b1cc2cf | 04225f79-06fe-4c08-ad00-95f84b1cc2cf | Creating | ead23113-a585-428d-985c-63155402fa7f |        |
    +------------------------------------------------------+--------------------------------------+----------+--------------------------------------+--------+
    INFO: Viewing 3 result(s)
    

  2. Confirm that the app is in the created state using the following command:

    edgebuilder-cli app view --all
    
    Expected Output:
    INFO: Processing all apps...
    INFO: *** App View Results ***
    +------------------------------------------------------+---------+--------------------------------------+-----------------+-------+--------+
    | NAME                                                 | STATUS  | ID                                   | APP_DEFINITION  | NODE  | LABELS |
    +------------------------------------------------------+---------+--------------------------------------+-----------------+-------+--------+
    | SimpleWebServer_04225f79-06fe-4c08-ad00-95f84b1cc2cf | Created | 04225f79-06fe-4c08-ad00-95f84b1cc2cf | SimpleWebServer | node3 |        |
    | SimpleWebServer_089d2f5b-8e8a-4d56-93ae-bb76b5371043 | Created | 089d2f5b-8e8a-4d56-93ae-bb76b5371043 | SimpleWebServer | node2 |        |
    | SimpleWebServer_6f8b47cb-0518-4491-bdde-8715647a45ee | Created | 6f8b47cb-0518-4491-bdde-8715647a45ee | SimpleWebServer | node1 |        |
    +------------------------------------------------------+---------+--------------------------------------+-----------------+-------+--------+
    INFO: Viewing 3 result(s)
    

    Note

    • The status of the app is initially shown as Creating. After a few seconds, you can re-issue the command and the status will have changed to Created
    • You can also use the watch command with the app view command above to automatically track the status changes
  3. Run the app using the app start command:

    edgebuilder-cli app start --node-label label4
    
    Expected output:
    INFO: Finding apps in nodes with labels: label4
    INFO: Found nodes: "node2, node1, node3"
    INFO: Starting 3 app(s)
    

  4. To view the status of the apps we deployed, use the app view command

    edgebuilder-cli app view --all
    

  5. With the apps running they can be verified via these curl commands:

    curl http://192.168.56.11:55555
    I am edge node1
    curl http://192.168.56.12:55555
    I am edge node2
    curl http://192.168.56.13:55555
    I am edge node3
    

    Note

    • It might take a few seconds for the status of the app to move from Starting to Running

Stop and Remove apps by node label

In this section of the tutorial, we remove the simple web server app from all 3 edge nodes using the label label4.

  1. Stop the apps from running using the following command:
    edgebuilder-cli app stop --node-label label4
    
    Expected output:
    INFO: Finding apps in nodes with labels: label4
    INFO: Found nodes: "node2, node3, node1" 
    INFO: Stopping 3 app(s)
    
  2. Remove the apps from the nodes using the following command:
    edgebuilder-cli app rm --node-label label4 -y
    
    Expected output:
    INFO: Finding apps in nodes with labels: label4
    INFO: Found nodes: "node2, node3, node1" 
    INFO: Attempting to remove 3 app(s)
    INFO: Removal request for 3 app(s) accepted for processing by Edge Builder. Use 'app view' command to get updated status
    
  3. Confirm that the apps are removed successfully:
    edgebuilder-cli app view --all
    
    Expected output:
    INFO: Processing all apps...
    WARN: 0 results to view
    

Remove nodes via label

In this section of the tutorial, we remove nodes via the label label4.

  1. Remove all nodes using the following command:

    edgebuilder-cli node rm -l label4 -y
    
    Expected output:
    INFO: Processing nodes with labels: ["label4"]
    INFO: Attempting to remove 3 node(s)
    INFO: Removal request for 3 node(s) accepted for processing by Edge Builder. Use 'node view' command to get updated status
    

  2. Confirm that all 3 nodes have been removed using the following command:

    edgebuilder-cli node view --all
    
    Expected output:
    INFO: Finding all nodes...
    WARN: 0 results to view