Skip to content

Containerized Apps

This tutorial demonstrates how a docker-compose application can be managed and provisioned with custom configuration. This covers:

Initialize Edge Builder server components and CLI

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

  1. Set up the environment as described in Tutorials Setup

  2. SSH into the master node:

    vagrant ssh master
    

  3. 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
    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
    

  4. 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"
    
    The following message displays:
    INFO: User "iotech" logged in successfully
    

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

  6. 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)
    

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:

  1. Confirm that the example node configuration file is avaliable using the cat command:

    cat /vagrant/examples/single-node-config.json
    
    The output is similar to the following:
    {
      "NodeConfig": [
          {
              "name": "node1",
              "description": "virtual node 1",
              "nodeaddress": "192.168.56.11",
              "username" : "vagrant",
              "password" : "vagrant",
              "serveraddress": "192.168.56.10",
              "labels" : ["label1", "label2"]
          }
      ]
    }
    

  2. Add the edge node to Edge Builder using the following command:

     edgebuilder-cli node add -f /vagrant/examples/single-node-config.json
    
    The output is similar to the following:
    INFO: SSH Node(s) added successfully:
    +-------+--------------------------------------+
    | NODE  | ID                                   |
    +-------+--------------------------------------+
    | node1 | e01c540b-fa87-4721-b38c-5f0109210381 |
    +-------+--------------------------------------+
    INFO: Viewing 1 result(s)
    

  3. Confirm that the node has been added using the following command:

    edgebuilder-cli node view --all
    
    The output is similar to the following:
    INFO: Finding all nodes...
    INFO: *** Node View Results ***
    +-------+----------+------------+--------------+----------------+--------------------------------------+
    | NAME  |  STATUS  | DEBUG MODE | METRICS MODE | DESCRIPTION    | ID                                   |
    +-------+----------+------------+--------------+----------------+--------------------------------------+
    | node1 | Deploying| Off        | Local        | virtual node 1 | e01c540b-fa87-4721-b38c-5f0109210381 |
    +-------+----------+------------+--------------+----------------+--------------------------------------+
    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 to Up
    • You can also use the watch command with the node view above to automatically track the status changes

Add a compose app definition

In this section of the tutorial, we create an app definition that defines a simple web server.

  1. Confirm that the example app definition configuration file is available using the cat command:

    cat /vagrant/examples/appConfiguration/nginx-app-def.json
    
    The output is similar to the following:
    {
      "AppDefinitionConfig": [
        {
          "Name": "SimpleWebServer-Config",
          "Description": "A simple web server",
          "FilePath": "/vagrant/examples/appConfiguration/docker-compose.yml",
          "Type": "docker-compose"
        }
      ]
    }
    

  2. Confirm that the example docker compose file is available using the following command:

    cat /vagrant/examples/appConfiguration/docker-compose.yml
    
    The output is similar to the following:
    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
  3. Add the app definition to Edge Builder using the following command:

    edgebuilder-cli appDefinition add -f /vagrant/examples/appConfiguration/nginx-app-def.json
    
    The output is similar to the following:
    INFO: AppDefinition(s) added successfully:
    +------------------------+--------------------------------------+--------+
    | NAME                   | ID                                   | LABELS |
    +------------------------+--------------------------------------+--------+
    | SimpleWebServer-Config | 73c2b570-45db-4ab6-960f-b02cc891527c |        |
    +------------------------+--------------------------------------+--------+
    INFO: Viewing 1 result(s)
    

  4. Confirm that the app definition has been added using the following command:

    edgebuilder-cli appDefinition view --all
    
    The output is similar to the following:
    INFO: Finding all appDefinitions...
    INFO: *** AppDefinition View Results ***
    +------------------------+--------------------------------------+---------------------+----------------+--------+
    | NAME                   | ID                                   | DESCRIPTION         | TYPE           | LABELS |
    +------------------------+--------------------------------------+---------------------+----------------+--------+
    | SimpleWebServer-Config | 73c2b570-45db-4ab6-960f-b02cc891527c | A simple web server | docker-compose |        |
    +------------------------+--------------------------------------+---------------------+----------------+--------+
    INFO: Viewing 1 result(s)
    

Add a compose app config file definition

This section of the tutorial illustrates how application configuration files can added to the system.

  1. Confirm that the AppConfigFile definition is avaliable using the 'cat' command:
    cat /vagrant/examples/appConfiguration/nginx-file-config.json
    
    The output is similar to the following:
    {
      "AppConfigFileConfig": [
        {
          "Name": "website",
          "Description": "a file to configure the web output",
          "FileName": "index.html",
          "FilePath": "/vagrant/examples/appConfiguration/index.html"
        }
      ]
    }
    
  2. Confirm that the config file, index.html, is avaliable using the 'cat' command:

    cat /vagrant/examples/appConfiguration/index.html
    
    The output is similar to the following:
    "I am edge $HOSTNAME - insert your own text here!!"
    

    Note

    • This file can be edited to output a custom message
  3. Add the AppConfigFile definition using the following command:

    edgebuilder-cli appConfigFile add -f /vagrant/examples/appConfiguration/nginx-file-config.json
    
    The output is similar to the following:
    INFO: appConfigFile(s) added successfully:
    +---------+--------------------------------------+------------------------------------+
    | NAME    | ID                                   | DESCRIPTION                        |
    +---------+--------------------------------------+------------------------------------+
    | website | db3407c0-3b3f-410d-b5da-549e36168544 | 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.

  1. Confirm that the AppConfig definition is available using the 'cat' command:

    cat /vagrant/examples/appConfiguration/nginx-app-config.json
    
    The output is similar to the following:
    {
      "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
  2. Change the 'AppDefinitionID' to the ID returned when the SimpleWebServer definition was added.

  3. Add the AppConfig using the following command:

    edgebuilder-cli appConfig add -f /vagrant/examples/appConfiguration/nginx-app-config.json
    
    The output is similar to the following:
    INFO: AppConfig(s) added successfully:
    +-------------+--------------------------------------+------------------------------------------+--------------------------------------+
    | NAME        | ID                                   | DESCRIPTION                              | APP_DEFINITION ID                    |
    +-------------+--------------------------------------+------------------------------------------+--------------------------------------+
    | NginxConfig | 3f1aa76b-4fee-493d-bfc2-1475ba27f349 | config to inject into the nginx containe | b26aa20d-b0f9-4272-b8f9-bb91b3b18a1c |
    |             |                                      | 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:

    edgebuilder-cli app create -n node1 -d SimpleWebServer-config -c NginxConfig
    

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

    edgebuilder-cli app view --all
    
    The output is similar to the following:
    INFO: Finding all apps...
    INFO: *** App View Results ***
    +-------------------------------------------------------------+---------+--------------------------------------+------------------------+-------+--------+
    | NAME                                                        | STATUS  | ID                                   | APP_DEFINITION         | NODE  | LABELS |
    +-------------------------------------------------------------+---------+--------------------------------------+------------------------+-------+--------+
    | SimpleWebServer-Config_d7c010cd-dc35-433c-8bf0-03df0438e40d | Created | d7c010cd-dc35-433c-8bf0-03df0438e40d | SimpleWebServer-Config | 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 to Created
    • You can also use the watch command with the app view command above to automatically track the status changes
  • Start the app using the following command, where <appname/id> is the ID of your app:

    edgebuilder-cli app start -a <appname/id>
    
    The output is similar to the following:
    INFO: Finding apps: ["d7c010cd-dc35-433c-8bf0-03df0438e40d"]
    INFO: Starting 1 app(s)
    

    Note

    • You can find the ID of your app using the app view --all command.
  • To view the status of the app we deployed, use the app view command again

    edgebuilder-cli app view --all
    
    The output is similar to the following:
    INFO: Finding all apps...
    INFO: *** App View Results ***
    +-------------------------------------------------------------+---------+--------------------------------------+------------------------+-------+--------+
    | NAME                                                        | STATUS  | ID                                   | APP_DEFINITION         | NODE  | LABELS |
    +-------------------------------------------------------------+---------+--------------------------------------+------------------------+-------+--------+
    | SimpleWebServer-Config_d7c010cd-dc35-433c-8bf0-03df0438e40d | Running | d7c010cd-dc35-433c-8bf0-03df0438e40d | SimpleWebServer-Config | node1 |        |
    +-------------------------------------------------------------+---------+--------------------------------------+------------------------+-------+--------+
    INFO: Viewing 1 result(s)
    

    Note

    • It might take a few seconds for the status of the app to move from Starting to Running
  • When running, you can verify the app using the following command:

    curl http://192.168.56.11:55555
    
    If the app is running, you see either the custom message or the following:
    I am edge node1 - insert your own text here!!