Containerized Apps
This tutorial demonstrates how a docker-compose application can be managed and provisioned with custom configuration. This covers:
- Initialise the Edge Builder server components and CLI
- Add a node
- Add a compose app definition
- Add a compose app config file definition
- Add a compose app config definition
- Deploy compose app and inject configuration
Initialize Edge Builder server components and CLI
To initialize the Edge Builder server components and CLI, complete the following steps:
-
Set up the environment as described in Tutorials Setup
-
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 7760c2ef24ff iotechsys/dev-eb-controller:1.2.0.dev "./entrypoint.sh" 20 minutes ago Up 20 minutes 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 1b727b4d9836 iotechsys/dev-eb-vault-setup:1.2.0.dev "/bin/sh -c ./setup-…" 20 minutes ago Exited (0) 20 minutes ago eb-vault-setup 639b032001a2 chronograf:1.8.8-alpine "./custom-entrypoint…" 20 minutes ago Up 20 minutes 0.0.0.0:8888->8888/tcp, :::8888->8888/tcp eb-chronograf f58f2c929117 vault:1.7.1 "./entrypoint.sh" 20 minutes ago Up 20 minutes 8200/tcp eb-vault ecddbcb443cf portainer/portainer-ce:2.1.0-alpine "/portainer -H unix:…" 20 minutes ago Up 20 minutes 0.0.0.0:8000->8000/tcp, :::8000->8000/tcp, 0.0.0.0:9000->9000/tcp, :::9000->9000/tcp eb-portainer b073acb8864d postgres:alpine "./entrypoint.sh" 20 minutes ago Up 20 minutes 5432/tcp eb-db 590bc53e2adf iotechsys/dev-eb-webssh:1.2.0.dev "wssh --address=0.0.…" 20 minutes ago Up 20 minutes 0.0.0.0:8989->8989/tcp, :::8989->8989/tcp eb-webssh d941d61bcfbb iotechsys/dev-eb-redis:1.2.0.dev "redis-server /etc/r…" 20 minutes ago Up 20 minutes 6379/tcp eb-redis 70fdf21ff278 influxdb:1.8.1-alpine "./custom-entrypoint…" 20 minutes ago Up 20 minutes 0.0.0.0:8086->8086/tcp, :::8086->8086/tcp eb-influxdb 56f986f6a243 iotechsys/dev-eb-salt-master:1.2.0.dev "/bin/sh -c 'sed -i …" 20 minutes ago Up 20 minutes 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 6b6ce98355f1 grafana/grafana:7.4.2 "/run.sh" 20 minutes ago Up 20 minutes 0.0.0.0:3000->3000/tcp, :::3000->3000/tcp eb-grafana 97656c20a6c0 kapacitor:1.5-alpine "/entrypoint.sh kapa…" 20 minutes ago Up 20 minutes 9092/tcp eb-kapacitor eb_influxdb
-
Log in to Edge Builder with the default user credentials using the following command:
The following message displays: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)
Add a node
In this section of the tutorial, we add an edge node to Edge Builder, which is accessible on 192.168.56.11
.
To add an edge node, complete the following steps:
-
Confirm that the example node configuration file is avaliable using the
cat
command:The output is similar to the following:cat /vagrant/examples/single-node-config.json
{ "NodeConfig": [ { "name": "node1", "description": "virtual node 1", "nodeaddress": "192.168.56.11", "nodesshport": "22", "username" : "vagrant", "password" : "vagrant", "serveraddress": "192.168.56.10", "labels" : ["label1", "label2"] } ] }
-
Add the edge node to Edge Builder using the following command:
The output is similar to the following:edgebuilder-cli node add -f /vagrant/examples/single-node-config.json
INFO: SSH Node(s) added successfully: +-------+--------------------------------------+----------------+ | NODE | ID | LABELS | +-------+--------------------------------------+----------------+ | node1 | 4ce8c47a-46c4-40fb-b1ed-71351933ce0b | label1, label2 | +-------+--------------------------------------+----------------+ INFO: Viewing 1 result(s)
-
Confirm that the node has been added using the following command:
The output is similar to the following:edgebuilder-cli node view --all
INFO: Finding all nodes... INFO: *** Node View Results *** +-------+--------------------------------------+--------+------------+--------------+------------------------------------------+----------------+ | NAME | ID | STATUS | DEBUG MODE | METRICS MODE | LABELS | DESCRIPTION | +-------+--------------------------------------+--------+------------+--------------+------------------------------------------+----------------+ | node1 | 4ce8c47a-46c4-40fb-b1ed-71351933ce0b | Up | Off | Local | OSFinger:Ubuntu-20.04, Kernel:Linux, lab | virtual node 1 | | | | | | | el2, OSFamily:Debian, CPUModel:11thGenIn | | | | | | | | tel(R)Core(TM)i7-11800H@2.30GHz, Hostnam | | | | | | | | e:node1, Virtual:VirtualBox, GroupName:r | | | | | | | | oot, OSArch:amd64, Language:en_US, label | | | | | | | | 1, Manufacturer:innotekGmbH, Timezone:UT | | | | | | | | C, UserName:root, ProductName:VirtualBox | | | | | | | | , CPUArch:x86_64 | | +-------+--------------------------------------+--------+------------+--------------+------------------------------------------+----------------+ INFO: Viewing 1 result(s)
Note
- The status of the node 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
- The status of the node is initially shown as
Add a compose app definition
In this section of the tutorial, we create an app definition
that defines a simple web server.
-
Confirm that the example app definition configuration file is available using the
cat
command:The output is similar to the following:cat /vagrant/examples/appConfiguration/nginx-app-def.json
{ "AppDefinitionConfig": [ { "Name": "SimpleWebServer", "Description": "A simple web server", "FilePath": "/vagrant/examples/appConfiguration/docker-compose.yml", "Type": "docker-compose", "Labels": ["appLabel1","appLabel2"] } ] }
-
Confirm that the example docker compose file is available using the following command:
The output is similar to the following:cat /vagrant/examples/appConfiguration/docker-compose.yml
version: "3" volumes: web_config: services: simple-webserver: image: nginx ports: - 55555:80 volumes: - web_config:/usr/share/nginx/html
Note
- Configuration is provided using the web_config volume
-
Add the app definition to Edge Builder using the following command:
The output is similar to the following:edgebuilder-cli appDefinition add -f /vagrant/examples/appConfiguration/nginx-app-def.json
INFO: AppDefinition(s) added successfully: +------------------------+--------------------------------------+----------------------+ | NAME | ID | LABELS | +------------------------+--------------------------------------+----------------------+ | SimpleWebServer | 8e16c83f-eba5-436f-b262-0fe29a85cd0a | appLabel1, appLabel2 | +------------------------+--------------------------------------+----------------------+ INFO: Viewing 1 result(s)
-
Confirm that the app definition has been added using the following command:
The output is similar to the following:edgebuilder-cli appDefinition view --all
INFO: Finding all appDefinitions... INFO: *** AppDefinition View Results *** +------------------------+--------------------------------------+-----------------------------------+----------------+----------------------+ | NAME | ID | DESCRIPTION | TYPE | LABELS | +------------------------+--------------------------------------+-----------------------------------+----------------+----------------------+ | SimpleWebServer | 8e16c83f-eba5-436f-b262-0fe29a85cd0a | A simple web server | docker-compose | appLabel1, appLabel2 | +------------------------+--------------------------------------+-----------------------------------+----------------+----------------------+ INFO: Viewing 1 result(s)
Add a compose app config file definition
This section of the tutorial illustrates how application configuration files can be added to the system.
- Confirm that the AppConfigFile definition is available using the
cat
command:The output is similar to the following:cat /vagrant/examples/appConfiguration/nginx-file-config.json
{ "AppConfigFileConfig": [ { "Name": "website", "Description": "a file to configure the web output", "FileName": "index.html", "FilePath": "/vagrant/examples/appConfiguration/index.html" } ] }
-
Confirm that the config file, index.html, is available using the
cat
command:The output is similar to the following:cat /vagrant/examples/appConfiguration/index.html
"I am edge $HOSTNAME - insert your own text here!!"
Note
- This file can be edited to output a custom message
-
Add the AppConfigFile definition using the following command:
The output is similar to the following:edgebuilder-cli appConfigFile add -f /vagrant/examples/appConfiguration/nginx-file-config.json
INFO: appConfigFile(s) added successfully: +---------+--------------------------------------+------------------------------------+ | NAME | ID | DESCRIPTION | +---------+--------------------------------------+------------------------------------+ | website | ab3553be-5bc9-4c07-9d03-f32c0003d59f | a file to configure the web output | +---------+--------------------------------------+------------------------------------+ INFO: Viewing 1 result(s)
Add a compose app config definition
This section creates an AppConfig by associating the AppConfigFile above with a volume in our AppDefinition.
-
Confirm that the AppConfig definition is available using the
cat
command:The output is similar to the following:cat /vagrant/examples/appConfiguration/nginx-app-config.json
{ "AppConfig": [ { "Name": "NginxConfig", "Description": "config to inject into the nginx container", "AppDefinitionID": "0a96ccd8-6d3f-45d1-b696-7dc44abe9024", "ConfigMappings": [ { "Destination": "web_config", "AppConfigFiles": [ "website" ] } ] } ] }
Note
- The app config maps one or more app config files to one or more volumes. The volumes must exist in the app definition
-
Change the 'AppDefinitionID' to the ID returned when the SimpleWebServer definition was added.
-
Add the AppConfig using the following command:
The output is similar to the following:edgebuilder-cli appConfig add -f /vagrant/examples/appConfiguration/nginx-app-config.json
INFO: AppConfig(s) added successfully: +-------------+--------------------------------------+------------------------------------------+--------------------------------------+ | NAME | ID | DESCRIPTION | APP_DEFINITION ID | +-------------+--------------------------------------+------------------------------------------+--------------------------------------+ | NginxConfig | d4252c95-903e-4e53-88e7-80f68d789bae | config to inject into the nginx containe | 8e16c83f-eba5-436f-b262-0fe29a85cd0a | | | | r | | +-------------+--------------------------------------+------------------------------------------+--------------------------------------+ INFO: Viewing 1 result(s)
Deploy Compose App and Inject Configuration
This section explains how to deploy an application using the app definition and app config defined above.
-
To create the application run the following command:
Expected Output:edgebuilder-cli app create -n node1 -d SimpleWebServer -c NginxConfig
INFO: Creating app(s): +-------------------------------------------------------------+--------------------------------------+----------+--------------------------------------+--------+ | APP NAME | APP ID | STATUS | NODE ID | LABELS | +-------------------------------------------------------------+--------------------------------------+----------+--------------------------------------+--------+ | SimpleWebServer_92063e2d-ef52-4cb7-a3da-d79834932eea | 92063e2d-ef52-4cb7-a3da-d79834932eea | Creating | 4ce8c47a-46c4-40fb-b1ed-71351933ce0b | | +-------------------------------------------------------------+--------------------------------------+----------+--------------------------------------+--------+ INFO: Viewing 1 result(s)
-
Confirm that the app is in the
created
state using the following command:The output is similar to the following:edgebuilder-cli app view --all
INFO: Finding all apps... INFO: *** App View Results *** +-------------------------------------------------------------+---------+--------------------------------------+------------------------+-------+--------+ | NAME | STATUS | ID | APP_DEFINITION | NODE | LABELS | +-------------------------------------------------------------+---------+--------------------------------------+------------------------+-------+--------+ | SimpleWebServer_d7c010cd-dc35-433c-8bf0-03df0438e40d | Created | d7c010cd-dc35-433c-8bf0-03df0438e40d | SimpleWebServer | node1 | | +-------------------------------------------------------------+---------+--------------------------------------+------------------------+-------+--------+ INFO: Viewing 1 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
-
Start the app using the following command, where
<appname/id>
is the ID or Name of your app:The output is similar to the following:edgebuilder-cli app start -a <appname/id>
INFO: Finding apps: ["SimpleWebServer_92063e2d-ef52-4cb7-a3da-d79834932eea"] INFO: Starting 1 app(s)
Note
- You can find the ID and Name of your app using the
app view --all
command.
- You can find the ID and Name of your app using the
-
To view the status of the app we deployed, use the
app view
command againThe output is similar to the following:edgebuilder-cli app view --all
INFO: Processing all apps... INFO: *** App View Results *** +-------------------------------------------------------------+---------+--------------------------------------+------------------------+-------+--------+ | NAME | STATUS | ID | APP_DEFINITION | NODE | LABELS | +-------------------------------------------------------------+---------+--------------------------------------+------------------------+-------+--------+ | SimpleWebServer_92063e2d-ef52-4cb7-a3da-d79834932eea | Running | 92063e2d-ef52-4cb7-a3da-d79834932eea | SimpleWebServer | node1 | | +-------------------------------------------------------------+---------+--------------------------------------+------------------------+-------+--------+ INFO: Viewing 1 result(s)
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
-
When running, you can verify the app using the following command:
If the app is running, you see either the custom message or the following:curl http://192.168.56.11:55555
I am edge node1 - insert your own text here!!
Delete the app
This section explains how to remove the application which is running.
- Stop the running application using the following command, where
<appname/Id>
is the ID or Name of your app:Expected Output:edgebuilder-cli app stop -a <appName/Id>
INFO: Finding apps: ["92063e2d-ef52-4cb7-a3da-d79834932eea"] INFO: Stopping 1 app(s)
-
Confirm the app is stopped by running the following command
The output is similar to the following:edgebuilder-cli app view --all
INFO: Processing all apps... INFO: *** App View Results *** +-------------------------------------------------------------+---------+--------------------------------------+------------------------+-------+--------+ | NAME | STATUS | ID | APP_DEFINITION | NODE | LABELS | +-------------------------------------------------------------+---------+--------------------------------------+------------------------+-------+--------+ | SimpleWebServer_92063e2d-ef52-4cb7-a3da-d79834932eea | Stopped | 92063e2d-ef52-4cb7-a3da-d79834932eea | SimpleWebServer | node1 | | +-------------------------------------------------------------+---------+--------------------------------------+------------------------+-------+--------+ INFO: Viewing 1 result(s)
-
Remove the app using the following command, where
<appname/Id>
is the ID or Name of your app:Expected Output:edgebuilder-cli app remove -a <appname/Id> -y
INFO: Finnding apps: ["92063e2d-ef52-4cb7-a3da-d79834932eea"] INFO: Attempting to remove 1 app(s) INFO: Removal request for 1 app(s) accepted for processing by Edge Builder. Use 'app view' command to get updated status
Remove the node
To remove an edge node, complete the following steps:
-
Remove the edge node
node1
using the following command:Expected output:edgebuilder-cli node rm -n node1 -y
INFO: Processing nodes: ["node1"] INFO: Attempting to remove 1 node(s) INFO: Removal request for 1 node(s) accepted for processing by Edge Builder. Use 'node view' command to get updated status
-
Confirm that the node has been removed using the following command:
Expected output:edgebuilder-cli node view -n node1
INFO: Finding nodes: ["node1"] WARN: node "node1" not found WARN: 0 results to view