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
- Create multiple nodes
- Add a custom label to the nodes
- Create an app definition
- Deploy an app to nodes by label
- Stop and Remove apps by node label
- Remove nodes via label
Initialise Edge Builder server components and CLI for multiple nodes
To initialize the Edge Builder server components and CLI, complete the following steps:
- Set up the environment as described in Tutorials Setup section and ensure that the environment variable
NODE_COUNT
is set to 3 before you executevagrant up
.export NODE_COUNT=3 vagrant up
-
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)
-
SSH into the master node:
vagrant ssh master
-
Start the Edge Builder server components using the following command:
When the server components are up, you should see all server components up and running via thesudo edgebuilder-server up -a 192.168.56.10
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
-
Log in to Edge Builder with the default user credentials using the following command:
You should see the following INFO message:edgebuilder-cli user login -u iotech -p EdgeBuilder123 -c "http://192.168.56.10:8085"
INFO: User "iotech" logged in successfully
-
Confirm that you have a valid license in the Vagrant project directory (
edgebuilder-vagrant
) - Add the license using the following command:
You should see the output similar to that shown below:
edgebuilder-cli license add -l DemoLicense -f /vagrant/EdgeBuilder_test_Evaluation.lic
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:
- Confirm that you have the example multi node configuration file using the
cat
command:Expected output:cat /vagrant/examples/multi-node-config.json
{ "NodeConfig": [ { "name": "node1", "description": "virtual node 1", "nodeaddress": "192.168.56.11", "username": "vagrant", "password": "vagrant", "serveraddress": "192.168.56.10", }, { "name": "node2", "description": "virtual node 2", "nodeaddress": "192.168.56.12", "username": "vagrant", "password": "vagrant", "serveraddress": "192.168.56.10", }, { "name": "node3", "description": "virtual node 3", "nodeaddress": "192.168.56.13", "username": "vagrant", "password": "vagrant", "serveraddress": "192.168.56.10", } ] }
-
Add the nodes to Edge Builder using the following command:
Expected Output:edgebuilder-cli node add -f /vagrant/examples/multi-node-config.json
INFO: SSH Node(s) added successfully: +-------+--------------------------------------+--------+ | NODE | ID | LABELS | +-------+--------------------------------------+--------+ | node1 | d59aecb8-1d30-46e8-9838-3987d31470a3 | | | node2 | 00b81c62-afb9-43cc-b180-a0f6546995d8 | | | node3 | ead23113-a585-428d-985c-63155402fa7f | | +-------+--------------------------------------+--------+ INFO: Viewing 3 result(s)
-
Confirm that the nodes have been added using the following command:
Expected Output:edgebuilder-cli node view --all
INFO: Finding all nodes... INFO: *** Node View Results *** +-------+--------------------------------------+--------+------------+--------------+------------------------------------------+----------------+ | NAME | ID | STATUS | DEBUG MODE | METRICS MODE | LABELS | DESCRIPTION | +-------+--------------------------------------+--------+------------+--------------+------------------------------------------+----------------+ | node1 | d59aecb8-1d30-46e8-9838-3987d31470a3 | Up | Off | Local | OSFamily:Debian, Timezone:UTC, ProductNa | virtual node 1 | | | | | | | me:VirtualBox, OSArch:amd64, UserName:ro | | | | | | | | ot, CPUArch:x86_64, OSFinger:Ubuntu-20.0 | | | | | | | | 4, Manufacturer:innotekGmbH, Language:en | | | | | | | | _US, Kernel:Linux, label1, CPUModel:Inte | | | | | | | | l(R)Core(TM)i7-9750HCPU@2.60GHz, Virtual | | | | | | | | :VirtualBox, GroupName:root, Hostname:no | | | | | | | | de1 | | | node2 | 00b81c62-afb9-43cc-b180-a0f6546995d8 | Up | Off | Local | OSFamily:Debian, Timezone:UTC, ProductNa | virtual node 2 | | | | | | | me:VirtualBox, OSArch:amd64, UserName:ro | | | | | | | | ot, CPUArch:x86_64, OSFinger:Ubuntu-20.0 | | | | | | | | 4, Manufacturer:innotekGmbH, Language:en | | | | | | | | _US, Kernel:Linux, label1, CPUModel:Inte | | | | | | | | l(R)Core(TM)i7-9750HCPU@2.60GHz, Virtual | | | | | | | | :VirtualBox, GroupName:root, Hostname:no | | | | | | | | de2 | | | node3 | ead23113-a585-428d-985c-63155402fa7f | Up | Off | Local | OSFamily:Debian, Timezone:UTC, Hostname: | virtual node 3 | | | | | | | node3, ProductName:VirtualBox, OSArch:am | | | | | | | | d64, UserName:root, CPUArch:x86_64, OSFi | | | | | | | | nger:Ubuntu-20.04, Manufacturer:innotekG | | | | | | | | mbH, Language:en_US, Kernel:Linux, label | | | | | | | | 1, CPUModel:Intel(R)Core(TM)i7-9750HCPU@ | | | | | | | | 2.60GHz, Virtual:VirtualBox, GroupName:r | | | | | | | | oot | | +-------+--------------------------------------+--------+------------+--------------+------------------------------------------+----------------+ 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 toUp
- You can also use the
watch
command with thenode view
above to automatically track the status changes - A number of standard labels can been seen, these are automatically populated
- The node status is initially shown as
Add a custom label to the nodes
In this section we associate the label label1
with our nodes.
-
Execute the following command to add the label
label1
to all of our nodes:Expected Output:edgebuilder-cli node labels -n node1,node2,node3 --add label1
INFO: Labels updated successfully for node "node2" INFO: Labels updated successfully for node "node1" INFO: Labels updated successfully for node "node3"
-
You can verify that the label has been added by using it to view the nodes:
Expected Output:edgebuilder-cli node view -l label1
INFO: Finding nodes with labels: label1 INFO: *** Node View Results *** +-------+--------------------------------------+--------+------------+--------------+------------------------------------------+----------------+ | NAME | ID | STATUS | DEBUG MODE | METRICS MODE | LABELS | DESCRIPTION | +-------+--------------------------------------+--------+------------+--------------+------------------------------------------+----------------+ | node1 | d59aecb8-1d30-46e8-9838-3987d31470a3 | Up | Off | Local | OSFamily:Debian, Timezone:UTC, ProductNa | virtual node 1 | | | | | | | me:VirtualBox, OSArch:amd64, UserName:ro | | | | | | | | ot, CPUArch:x86_64, OSFinger:Ubuntu-20.0 | | | | | | | | 4, Manufacturer:innotekGmbH, Language:en | | | | | | | | _US, Kernel:Linux, label1, CPUModel:Inte | | | | | | | | l(R)Core(TM)i7-9750HCPU@2.60GHz, Virtual | | | | | | | | :VirtualBox, GroupName:root, Hostname:no | | | | | | | | de1 | | | node2 | 00b81c62-afb9-43cc-b180-a0f6546995d8 | Up | Off | Local | OSFamily:Debian, Timezone:UTC, ProductNa | virtual node 2 | | | | | | | me:VirtualBox, OSArch:amd64, UserName:ro | | | | | | | | ot, CPUArch:x86_64, OSFinger:Ubuntu-20.0 | | | | | | | | 4, Manufacturer:innotekGmbH, Language:en | | | | | | | | _US, Kernel:Linux, label1, CPUModel:Inte | | | | | | | | l(R)Core(TM)i7-9750HCPU@2.60GHz, Virtual | | | | | | | | :VirtualBox, GroupName:root, Hostname:no | | | | | | | | de2 | | | node3 | ead23113-a585-428d-985c-63155402fa7f | Up | Off | Local | OSFamily:Debian, Timezone:UTC, Hostname: | virtual node 3 | | | | | | | node3, ProductName:VirtualBox, OSArch:am | | | | | | | | d64, UserName:root, CPUArch:x86_64, OSFi | | | | | | | | nger:Ubuntu-20.04, Manufacturer:innotekG | | | | | | | | mbH, Language:en_US, Kernel:Linux, label | | | | | | | | 1, CPUModel:Intel(R)Core(TM)i7-9750HCPU@ | | | | | | | | 2.60GHz, Virtual:VirtualBox, GroupName:r | | | | | | | | oot | | +-------+--------------------------------------+--------+------------+--------------+------------------------------------------+----------------+ INFO: Viewing 3 result(s)
Create app definition
In this section of the tutorial, we will register an app definition
.
-
Confirm that you have the example app definition configuration file using the
cat
command:Expected Output:cat /vagrant/examples/app-def-config.json
{ "AppDefinitionConfig": [ { "Name": "SimpleWebServer", "Description": "Node docker-compose appDefinition", "FilePath": "/vagrant/examples/docker-compose.yaml", "Type": "docker-compose", "Labels": ["appLabel1","appLabel2"] } ] }
-
Confirm that you have the example docker compose file, which defines a simple web server that prints a greeting, using the following command:
Expected output:cat /vagrant/examples/docker-compose.yaml
version: "3" services: simple-webserver: image: nginx ports: - 55555:80 volumes: - /home/vagrant/src:/usr/share/nginx/html
-
Add the app definition to Edge Builder using the following command:
Expected output:edgebuilder-cli appDefinition add -f /vagrant/examples/app-def-config.json
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 label1
.
-
Create the app on the nodes using the following command:
Expected output:edgebuilder-cli app create -d SimpleWebServer --node-label label1
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)
-
Confirm that the app is in the
created
state using the following command:Expected Output:edgebuilder-cli app view --all
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 toCreated
- You can also use the
watch
command with theapp view
command above to automatically track the status changes
- The status of the app is initially shown as
-
Run the app using the
app start
command:Expected output:edgebuilder-cli app start --node-label label1
vagrant@master:~$ edgebuilder-cli app start --node-label label1 INFO: Finding apps in nodes with labels: label1 INFO: Found nodes: "node2, node1, node3" INFO: Starting 3 app(s)
-
To view the status of the apps we deployed, use the
app view
commandedgebuilder-cli app view --all
-
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
toRunning
- It might take a few seconds for the status of the app to move from
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 label1
.
-
Stop the apps from running using the following command:
edgebuilder-cli app stop --node-label label1
-
Remove the apps from the nodes using the following command:
edgebuilder-cli app rm --node-label label1
-
Confirm that the apps are removed successfully:
edgebuilder-cli app view --all
Remove nodes via label
In this section of the tutorial, we remove nodes via the label label1
.
-
Remove all nodes using the following command:
Expected output:edgebuilder-cli node rm -l label1
INFO: Finding apps in nodes with labels: label1 INFO: Found nodes: "node2, node1, node3" INFO: Attempting to remove 3 app(s)
-
Confirm that all 3 nodes have been removed using the following command:
edgebuilder-cli node view --all