Understanding the applications.edgelq.com service APIv1, in proto package ntt.applications.v1.
SPEKTRA Edge Applications Service API
Applications service manages the applications running on the edge devices. Those applications are typically represented either as a pod or distribution resource, and running as a container.
A standalone executable nor virtual machine based applications are not supported.
Full API Specifications (with resources):
Application Management (Pod Resources)
A Pod resource delivers an application to a specific SPEKTRA Edge device; a Distribution resource automatically generates a Pod resource for any SPEKTRA Edge device that matches the specified criteria. In other words, a Distribution resource acts as a template for a Pod resource.
In Pod resources, Docker Compose is usually used to define the containers to be run.
Below is a simple Docker Compose example for running an Nginx server. For simplicity, host is used for the network in this example.
version: "3"
services:
nginx:
image: "nginx:latest"
network_mode: host
To use this Docker Compose file as a Pod, create a manifest file like this:
pod:
name: projects/nttni-test/regions/eu1/pods/nginx-test
spec:
node: projects/nttni-test/regions/eu1/devices/device-test
compose: "version: \"3\"\nservices:\n nginx:\n image: nginx:latest\n network_mode: host\n"
Field | Description |
---|---|
name |
Specify an arbitrary Pod name. |
spec.node |
Specify the resource name of the SPEKTRA Edge device where you want to deploy the application. |
spec.compose |
Set the value of the above Docker Compose file escaped as a string. Please refer to the following tips for the escaping method. |
To create a pod resource using the above file (here named $POD_FILE
), use the command cuttle applications create pod
.
cuttle applications create pod -f $POD_FILE
String escaping with jq command
The jq command can be used to easily perform the escaping process. For example, if the above Docker Compose file is stored in nginx.yaml, the following command will yield the escaped string.
cat nginx.yaml | jq -R -s .
Bulk Distribution of Applications (Distribution Resources)
Although Pod resources are useful for distributing applications to individual devices, resource management becomes complicated when the number of devices is large. To solve this problem, Distribution resources can be used.
The Distribution resource is a template resource for Pod resources, and has a label-matching function for device resources, allowing automatic generation of Pod resources for device resources that match the criteria in a batch. The Distribution resource is a template for the Pod resource.
The following is an example of a Distribution resource to distribute Joki’s Nginx server to all devices present in the project.
Distribution:
name: projects/ntt-test/distributions/nginx-test
displayName: Nginx Test
spec:
template:
spec:
compose: "version: \"3\"\nservices:\n nginx:\n image: nginx:latest\n network_mode: host\n"
To create a Distribution resource from a file, use the
cuttle applications create distribution
command:
cuttle applications create distribution -f $DIST_FILE
Use the spec.selector
field if you want to target only specific Device
resources for delivery. If this field is not set, all devices will be
targeted for delivery.
The following is an example of how to distribute only to Device resources
with {"purpose": "frontend"}
set in metadata.labels
.
Distribution:
name: projects/ntt-test/distributions/nginx-test
displayName: Nginx Test
spec:
selector:
matchLabels:
purpose: frontend
template:
spec:
compose: >
version: "3"
services: {}
image: "nginx:latest"
network_mode: host