Cloud - Edge synchronization service
The sync service is a management tool for Edge Computing.
It is designed to simplify applications that run on the edge by providing tools to synchronize objects between the cloud and the edge.
Users of the sync service can create/update an object in the cloud and the object is then automatically propagated to the relevant edge nodes.
Similarly, an object can be updated on the edge and delivered to the cloud.
Example use cases include synchronization of configuration, rules and actions, user preferences, AI models, monitoring statistics, deployment files, and more.
The sync service has two components:
The user application is also assumed to have an edge part and a cloud part. The application interacts with the sync service (CSS and ESS) using REST calls. Communication between the CSS and ESS nodes can be over MQTT or HTTP. The sync service is designed to work with the Watson IoT Platform and perform all communication through it. Direct communication over HTTP/HTTPS or over an MQTT broker is also supported.
The application provides the CSS/ESS an object that includes metadata, which defines the properties of the object, and optionally also binary data. The object's metadata includes the destinations for the object. The sync service supports flexibly addressing which allows an object to be sent from the CSS to:
When an update for an object is received on the ESS/CSS the application is notified by the sync service. The application can then obtain and process the object. Once the application is done processing the object it can mark it as consumed. The sync service allows users to view the delivery status of the object.
The following is a list of the main features provided by the sync service:
export GOPATH=$(pwd)
go get -d github.com/open-horizon/edge-sync-service
cd src/github.com/open-horizon/edge-sync-service
go mod tidy
go mod vendor
./get_dependencies.sh
To build the edge synch service, from the root of the workspace run:
export GOPATH=$(pwd)
(if not already done)go install github.com/open-horizon/edge-sync-service/cmd/edge-sync-service
To build the edge sync service container, from the root of the edge-sync-service repository run:
export GOPATH=<workspace root>
(if not already done)./buildContainer.sh <platform>
(where platform is amd64, armhf, or arm64)Notes:
sudo apt-get install gcc-arm-linux-gnueabihf
docker run --rm --privileged multiarch/qemu-user-static:register --reset
sudo apt-get install gcc-aarch64-linux-gnu
docker run --rm --privileged multiarch/qemu-user-static:register --reset
Setup a pair of configuration files or use environment variables. See sync.conf for an example configuration file. All of the appropriate environment variable names are listed in the configuration file. The use of a configuration file is completely optional.
Note: If you are running both the cloud side and the edge side on the same box and are using environment variables to configure them, make sure the file /etc/edge-sync-service/sync.conf does NOT exist.
The edge-sync-service when running on the "edge" will always only listen to requests using HTTPS. It automatically generates it's own self signed certificate and key pair. The CA certificate is /var/edge-sync-service/persist/sync/certs/cert.pem.
The edge-sync-service when running on the "cloud" can listen either as HTTPS or as HTTP depending on whether or not the configuration properties ServerCertificate and ServerKey or the environment variables SERVER_CERTIFICATE and SERVER_KEY were set to the file names of the server certificate-key pair.
To connect to a MQTT broker that is using TLS and the server certtificate is signed with a CA that is not one of the well known CA's (i.e. self signed), you must provide the file containing the CA certificate using the MQTTCACertificate configuration property or the MQTT_CA_CERTIFICATE environment variable.
To run the cloud side of the edge-sync-service:
export GOPATH=<workspace root>
(if not already done)$GOPATH/bin/edge-sync-service [-c <config file name>]
(the -c option is only needed if you are using one)To run the edge side of the edge-sync-service:
export GOPATH=<workspace root>
(if not already done)$GOPATH/bin/edge-sync-service [-c <config file name>]
(the -c option is only needed if you are using one)To generate the Swagger document for the Edge Synchronization Service you must:
brew tap go-swagger/go-swagger
brew install go-swagger
swagger generate spec -o ./swagger.json -m -b ./cmd/edge-sync-service
Note: This will create an extra file in your clone of the repository. Do NOT commit the file.
To view the generated Swagger document:
$GOPATH/bin/edge-sync-service -swagger swagger.json
http://<host>:<port>/swagger
.Where <host> and <port> are the host and port your edge-sync-service is configured to listen on.
The Sync Service provides a secure infrastructure on which to synchronize objects from the cloud to the edge and from the edge to the cloud. It does this by typically requiring authentication and authorization to perform all tasks. Both objects and edge nodes, refered to as destinations, are protected when authentication is required.
When authentication is required, all applications accessing the Sync Service via the Sync Service's RESTful API are required to provide an app key and app secret pair on all RESTful API calls.
Edge Sync Service instances are also typically required to identify themselves when communicating with a Cloud Sync Service instance.
The exact form of the app key and app secret pair is dependent on how the Sync Service instance one is communicating with has been configured. The app key and app secret pair are used to determine and validate the user's identity. The user's identity includes their username, the organization they are part of, and the type of user they are. A user can be an organization admin, a regular user, or an edge node.
It should be noted that one can set up the Sync Service to not require authentication at all. The default setup, while requiring authentication, makes most users organization admins. Such a setup should not be used in a production setting.
The Sync Service protects objects by limiting access to object types. In addition it protects edge nodes by limiting access to destination types.
In order for an application to create, read, update, or delete an object in the Sync Service, it must have access to the object type of the object in question. The application does this by:
In addition for an application to create an object on a Cloud Sync Service, it must have access to all of the destination types mentioned in the object's metadata. The application does this by:
Sync Service instances running on Edge Nodes identify themselves when they communicate with Cloud Sync Service instances. This is done to prevent an Edge Sync Service instance from masquerading as some other destination. The user identity used for an Edge Sync Service instance can be any one of the user identity types supported by the Sync Service. In particular, if the user identity is of:
Access control lists (ACLs) are used by the Sync Service to grant regular users both read and write access to object types and destination types within an organization. Users who are organization admins can add and remove users from ACLs. An ACL is automatically created when the first user's username is added to the ACL in question. An ACL is automatically deleted when the last user's username is removed from the ACL in question. Adding a username of asterisk (*) to an ACL allows any and all authenticated users within the organization access to object type or destination type in question.
ACLs are maintained using the appropriate Sync Service RESTful APIs. All of the Sync Service client SDKs provide language dependent APIs for these RESTful APIs.