edge-home-orchestration-backup

module
v0.0.0-...-707febc Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 28, 2020 License: Apache-2.0

README

Edge Orchestration

Goreport

The main purpose of Edge Orchestration is to implement distributed computing between Docker Container enabled devices.

The Workflow is as follows:

  1. Run Edge Orchestration container at a host machine. Then the host machine becomes an Edge Orchestration device.
  2. The device receives Service Execution request from host via REST API.
  3. The device gets and compares the scores from the other Edge Orchestration Devices.
  4. The device requests Service Execution to the device that has the highest score.
    • If the device itself has the highest score, the service is executed on itself.

Quick start

This section provides how to download and run pre-built Docker image without building the project.

1. Install docker-ce
2. Download Docker image

Please download edge-orchestration

3. Load Docker image from tar file
$ docker load -i edge-orchestration.tar

If it succeeds, you can see the Docker image as follows:

$ docker images
REPOSITORY                 TAG                 IMAGE ID            CREATED             SIZE
edge-orchestration         baobab              502e3c07b01f        3 minutes ago       132MB
4. Add Key file

To let the Edge Orchestration devices communicate with each other, each devices should have same authentication key in:

/var/edge-orchestration/data/cert/edge-orchestration.key

$ sudo cp {SampleKey.key} /var/edge-orchestration/data/cert/edge-orchestration.key

*Any cert file can be authentication key

5. Run with Docker image

You can execute Edge Orchestration with a Docker image as follows:

$ docker run -it -d \
                --privileged \
                --network="host" \
                --name edge-orchestration \
                -v /var/edge-orchestration/:/var/edge-orchestration/:rw \
                -v /var/run/docker.sock:/var/run/docker.sock:rw \
                -v /proc/:/process/:ro \
                edge-orchestration:baobab

Build Prerequisites

How to build

This project offers Docker image build as a default build option.

$ ./build.sh 

This build script will build Edge Orchestration in Docker Container environment.

If it succeeds, you can see the container runs as follows:

**********************************
 Run Docker container 
**********************************
5d2efd81057fe56236602acfece0e8f11d447b54627f4f3669b18c85a95b8687
CONTAINER ID        IMAGE                      COMMAND             CREATED                  STATUS                  PORTS               NAMES
5d2efd81057f        edge-orchestration:baobab  "sh run.sh"         Less than a second ago   Up Less than a second                       edge-orchestration

and the built image as follows:

$ docker images
REPOSITORY                 TAG                 IMAGE ID            CREATED             SIZE
edge-orchestration         baobab              502e3c07b01f        3 seconds ago       132MB
  • All Build Options
build script
Usage:
----------------------------------------------------------------------------------------------
  ./build.sh                  : build edge-orchestration by default container
  ./build.sh secure           : build edge-orchestration by default container with secure option
  ./build.sh container        : build Docker container as build system environmet
  ./build.sh container secure : build Docker container as build system environmet with secure option
  ./build.sh object           : build object (c-object, java-object)
  ./build.sh object secure    : build object (c-object, java-object) with secure option
  ./build.sh clean            : build clean
  ./build.sh test [PKG_NAME]  : run unittests (optional for PKG_NAME)
----------------------------------------------------------------------------------------------

API Document

Edge Orchestration provides only one REST API for its operation. Description for the APIs are stored in /doc folder.

Note that you can visit Swagger Editor to graphically investigate the REST API in YAML.

How to work

0. Prerequisites
  • 2 or more devices with Ubuntu 14.04 (or above) and Docker 17.09 (or above)
  • Same WIFI network connected among the devices.
  • Same Authentication key in /etc/edge-orchestration/orchestration_userID.txt
    • Please see the above 4. Add User ID to know how to add authentication key
  • Edge Orchestration Docker image
    • Please see the above How to build to know how to build Edge Orchestration Docker image
1. Run Edge Orchestration container
$ docker run -it -d \
                --privileged \
                --network="host" \
                --name edge-orchestration \
                -v /var/edge-orchestration/:/var/edge-orchestration/:rw \
                -v /var/run/docker.sock:/var/run/docker.sock:rw \
                -v /proc/:/process/:ro \
                edge-orchestration:baobab
  • Result
$ docker logs -f edge-orchestration 

2019/10/16 07:35:45 main_secured.go:89: [interface] OrchestrationInit
2019/10/16 07:35:45 main_secured.go:90: >>> commitID  :  c3041ae
2019/10/16 07:35:45 main_secured.go:91: >>> version   :  
2019/10/16 07:35:45 main_secured.go:92: >>> buildTime :  {build time}
2019/10/16 07:35:45 main_secured.go:93: >>> buildTags :  secure
2019/10/16 07:35:45 discovery.go:256: [discoverymgr] UUID :  {$UUID}
2019/10/16 07:35:45 discovery.go:338: [discoverymgr] [{$discovery_ip_list}]
2019/10/16 07:35:45 discovery.go:369: [deviceDetectionRoutine] edge-orchestration-{$UUID}
2019/10/16 07:35:45 discovery.go:370: [deviceDetectionRoutine] confInfo    : ExecType(container), Platform(docker)
2019/10/16 07:35:45 discovery.go:371: [deviceDetectionRoutine] netInfo     : IPv4({$discovery_ip_list})
2019/10/16 07:35:45 discovery.go:372: [deviceDetectionRoutine] serviceInfo : Services([])
2019/10/16 07:35:45 discovery.go:373: 
2019/10/16 07:35:45 tls.go:40: SetCertFilePath:  /var/edge-orchestration/data/cert
2019/10/16 07:35:45 tls.go:40: SetCertFilePath:  /var/edge-orchestration/data/cert
2019/10/16 07:35:45 route.go:76: {APIV1Ping GET /api/v1/ping 0x8090f0}
2019/10/16 07:35:45 route.go:76: {APIV1ServicemgrServicesPost POST /api/v1/servicemgr/services 0x809160}
2019/10/16 07:35:45 route.go:76: {APIV1ServicemgrServicesNotificationServiceIDPost POST /api/v1/servicemgr/services/notification/{serviceid} 0x8091c0}
2019/10/16 07:35:45 route.go:76: {APIV1ScoringmgrScoreLibnameGet GET /api/v1/scoringmgr/score 0x809220}
2019/10/16 07:35:45 route.go:76: {APIV1RequestServicePost POST /api/v1/orchestration/services 0x806cb0}
2019/10/16 07:35:45 route.go:104: ListenAndServeTLS_For_Inter
2019/10/16 07:35:45 route.go:111: ListenAndServe
2019/10/16 07:35:45 main_secured.go:141: interface orchestration init done
2. Request to execute a service

RESTAPI

  • POST

  • IP:56001/api/v1/orchestration/services

  • BODY :

    {
        "ServiceName": "hello-world",
        "ServiceInfo": [
        {
            "ExecutionType": "container",
            "ExecCmd": [
                "docker",
                "run",
                "-v", "/var/run:/var/run:rw",
                "hello-world"
            ]
        }],
        "StatusCallbackURI": "http://localhost:8888/api/v1/services/notification"
    }
    
  • Curl Example:

    - curl -X POST "IP:56001/api/v1/orchestration/services" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"ServiceName\": \"hello-world\", \"ServiceInfo\": [{ \"ExecutionType\": \"container\", \"ExecCmd\": [ \"docker\", \"run\", \"-v\", \"/var/run:/var/run:rw\", \"hello-world\"]}], \"StatusCallbackURI\": \"http://localhost:8888/api/v1/services/notification\"}"
    
  • Result(Execution on itself)

    $ docker logs -f edge-orchestration 
    
    2019/06/07 05:41:03 externalhandler.go:75: [RestExternalInterface] APIV1RequestServicePost
    2019/06/07 05:41:03 orchestration_api.go:70: [RequestService] container_service: [docker run -v /var/run:/var/run:rw hello-world]
    2019/06/07 05:41:03 scoringmgr.go:131: [IN] getScoreLocalEnv
    2019/06/07 05:41:03 scoringmgr.go:139: scoringmgr scoreValue :  7.481732534124991
    2019/06/07 05:41:03 orchestration_api.go:90: [orchestrationapi]  [{192.168.1.37 7.481732534124991}]
    2019/06/07 05:41:03 route.go:87: POST /api/v1/orchestration/services APIV1RequestServicePost 272.182µs
    2019/06/07 05:41:03 containerexecutor.go:75: [containerexecutor] container_service [docker run -v /var/run:/var/run:rw hello-world]
    2019/06/07 05:41:03 containerexecutor.go:76: [containerexecutor] parameter length : 5
    2019/06/07 06:46:12 route.go:87: POST /api/v1/orchestration/services APIV1RequestServicePost 396.063µs
    {"status":"Pulling from library/hello-world","id":"latest"}
    {"status":"Digest: sha256:0e11c388b664df8a27a901dce21eb89f11d8292f7fca1b3e3c4321bf7897bffe"}
    {"status":"Status: Image is up to date for hello-world:latest"}
    2019/06/07 05:41:21 containerexecutor.go:90: [containerexecutor] create container : bb8c3425ec
    2019/06/07 05:41:22 containerexecutor.go:108: [containerexecutor] container execution status : 0
    2019-06-07T05:41:22.144893108Z 
    2019-06-07T05:45:35.717107646Z Hello from Docker!
    2019-06-07T05:45:35.717110637Z This message shows that your installation appears to be working correctly.
    2019-06-07T05:45:35.717112612Z 
    2019-06-07T05:45:35.717114418Z To generate this message, Docker took the following steps:
    2019-06-07T05:45:35.717116284Z  1. The Docker client contacted the Docker daemon.
    2019-06-07T05:45:35.717118076Z  2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    2019-06-07T05:45:35.717120060Z     (amd64)
    2019-06-07T05:45:35.717121906Z  3. The Docker daemon created a new container from that image which runs the
    2019-06-07T05:45:35.717123788Z     executable that produces the output you are currently reading.
    2019-06-07T05:45:35.717125570Z  4. The Docker daemon streamed that output to the Docker client, which sent it
    2019-06-07T05:45:35.717127407Z     to your terminal.
    2019-06-07T05:45:35.717129190Z 
    2019-06-07T05:45:35.717130971Z To try something more ambitious, you can run an Ubuntu container with:
    2019-06-07T05:45:35.717132780Z  $ docker run -it ubuntu bash
    2019-06-07T05:45:35.717134548Z 
    2019-06-07T05:45:35.717136249Z Share images, automate workflows, and more with a free Docker ID:
    2019-06-07T05:45:35.717138053Z  https://hub.docker.com/
    2019-06-07T05:45:35.717139826Z 
    2019-06-07T05:45:35.717141538Z For more examples and ideas, visit:
    2019-06-07T05:45:35.717143307Z  https://docs.docker.com/get-started/
    2019-06-07T05:45:35.717145081Z 
    2019/06/07 05:41:22 orchestration_api.go:163: [orchestrationapi] service status changed [appNames:container_service][status:Finished]
    
  • Not supported docker run option [Args in Body]

    --detach-keys
    --disable-content-trust
    --sig-proxy
    --name
    --platform
    --help
    --cpu-percent       (Windows only option)
    --cpu-count         (Windows only option)
    --io-maxbandwidth   (Windows only option)
    --io-maxiops        (Windows only option)
    

Directories

Path Synopsis
GoMain
src/main
Package main provides REST interface for edge-orchestration
Package main provides REST interface for edge-orchestration
src
common/commandvalidator
****************************************************************************** * Copyright 2019 Samsung Electronics All Rights Reserved.
****************************************************************************** * Copyright 2019 Samsung Electronics All Rights Reserved.
common/errormsg
Package errormsg implements error messages for orchestration
Package errormsg implements error messages for orchestration
common/errors
Package errors defines error cases of edge-orchestration.
Package errors defines error cases of edge-orchestration.
common/logmgr
Package logmgr implements to handle log files and log format
Package logmgr implements to handle log files and log format
common/networkhelper
Package networkhelper checks the status of network interfaces and let subscribers know if it is updated
Package networkhelper checks the status of network interfaces and let subscribers know if it is updated
common/networkhelper/detector
Package detector implements wrapper of netlink package
Package detector implements wrapper of netlink package
common/networkhelper/detector/mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
common/resourceutil
Package resourceutil provides the information of resource usage of local device
Package resourceutil provides the information of resource usage of local device
common/resourceutil/mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
common/types/configuremgrtypes
****************************************************************************** * Copyright 2019 Samsung Electronics All Rights Reserved.
****************************************************************************** * Copyright 2019 Samsung Electronics All Rights Reserved.
common/types/servicemgrtypes
Package servicemgrtypes defines types for servicemgr
Package servicemgrtypes defines types for servicemgr
controller/configuremgr
Package configuremgr provides interfaces between ochrestrationapi and configuremgr
Package configuremgr provides interfaces between ochrestrationapi and configuremgr
controller/configuremgr/container
Package container provides container specific functions for configuremgr
Package container provides container specific functions for configuremgr
controller/configuremgr/mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
controller/configuremgr/native
Package native provides native specific functions for configuremgr
Package native provides native specific functions for configuremgr
controller/configuremgr/native/description
Package confdescription defines the configuration informantion of service application
Package confdescription defines the configuration informantion of service application
controller/discoverymgr
Package discoverymgr provides functions to register local device to network and find other orchestration devices
Package discoverymgr provides functions to register local device to network and find other orchestration devices
controller/discoverymgr/mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
controller/discoverymgr/wrapper
Package wrapper serves wrapper functions of zeroconf for orchestration
Package wrapper serves wrapper functions of zeroconf for orchestration
controller/discoverymgr/wrapper/mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
controller/scoringmgr
Package scoringmgr provides the way to apply specific scoring method for each service application
Package scoringmgr provides the way to apply specific scoring method for each service application
controller/scoringmgr/mock_internal
Package mockscoringmgr implements the mock functions for scoringmgr
Package mockscoringmgr implements the mock functions for scoringmgr
controller/scoringmgr/mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
controller/servicemgr
Package servicemgr manages service application execution
Package servicemgr manages service application execution
controller/servicemgr/executor
Package executor provides struct and interface for multi-platform execution
Package executor provides struct and interface for multi-platform execution
controller/servicemgr/executor/androidexecutor
Package androidexecutor provides functions to execute service application in android native
Package androidexecutor provides functions to execute service application in android native
controller/servicemgr/executor/containerexecutor
Package containerexecutor provides functions to execute service application in container enviroment
Package containerexecutor provides functions to execute service application in container enviroment
controller/servicemgr/executor/containerexecutor/mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
controller/servicemgr/executor/mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
controller/servicemgr/executor/nativeexecutor
Package nativeexecutor provides functions to execute service application in Linux native
Package nativeexecutor provides functions to execute service application in Linux native
controller/servicemgr/mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
controller/servicemgr/notification
Package notification provides functions to manage notification after running service application
Package notification provides functions to manage notification after running service application
controller/servicemgr/notification/mocks
Package mock_notification is a generated GoMock package.
Package mock_notification is a generated GoMock package.
db/bolt/configuration
******************************************************************************
******************************************************************************
db/bolt/configuration/mocks
Package mock_configuration is a generated GoMock package.
Package mock_configuration is a generated GoMock package.
db/bolt/network
******************************************************************************
******************************************************************************
db/bolt/network/mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
db/bolt/resource/mocks
Package mock_resource is a generated GoMock package.
Package mock_resource is a generated GoMock package.
db/bolt/service/mocks
Package mock_service is a generated GoMock package.
Package mock_service is a generated GoMock package.
db/bolt/system/mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
db/bolt/wrapper
******************************************************************************
******************************************************************************
db/bolt/wrapper/mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
db/helper/mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
interfaces/capi
Package main provides C interface for orchestration
Package main provides C interface for orchestration
interfaces/javaapi
Package javaapi provides Java interface for orchestration
Package javaapi provides Java interface for orchestration
orchestrationapi
Package orchestrationapi provides orchestration functionalities to handle distributed service in multi-device enviroment
Package orchestrationapi provides orchestration functionalities to handle distributed service in multi-device enviroment
orchestrationapi/mocks
Package mock_orchestrationapi is a generated GoMock package.
Package mock_orchestrationapi is a generated GoMock package.
restinterface
Package restinterface implements internal/external REST API
Package restinterface implements internal/external REST API
restinterface/cipher
Package cipher implements simple encrypting and decrypting message
Package cipher implements simple encrypting and decrypting message
restinterface/cipher/dummy
Package dummy provides the mocking functions
Package dummy provides the mocking functions
restinterface/cipher/mocks
Package mock_cipher is a generated GoMock package.
Package mock_cipher is a generated GoMock package.
restinterface/cipher/sha256
Package sha256 implements encryption/decryption functions by sha256
Package sha256 implements encryption/decryption functions by sha256
restinterface/client
Package client implements REST client management functions
Package client implements REST client management functions
restinterface/client/mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
restinterface/client/restclient
Package restclient implements REST client functions to send reqeust to remote orchestration
Package restclient implements REST client functions to send reqeust to remote orchestration
restinterface/externalhandler
Package externalhandler implements REST server functions to communication between orchestration and service applications
Package externalhandler implements REST server functions to communication between orchestration and service applications
restinterface/internalhandler
Package internalhandler implements REST server functions to communication between orchestrations
Package internalhandler implements REST server functions to communication between orchestrations
restinterface/mocks
Package mock_restinterface is a generated GoMock package.
Package mock_restinterface is a generated GoMock package.
restinterface/resthelper
Package resthelper implements rest helper functions
Package resthelper implements rest helper functions
restinterface/resthelper/mocks
Package mock_resthelper is a generated GoMock package.
Package mock_resthelper is a generated GoMock package.
restinterface/route
Package route implements management functions of REST Router
Package route implements management functions of REST Router

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL