Developer Deep Dive
Asset Thing Details in AnythingDB
Each Asset record in EdgeOps Fleet Management is represented in AnythingDB automatically so you can interact with it.
In AnythingDB, for every Asset you provision, you will find a corresponding Thing named Cluster in the Cluster category.
A Cluster is based on the semantic of the W3C WoT specification. A Cluster is a regular WoT Thing with some specific fields that convert the Thing into a Cluster.
- @type:
- Values:
cluster
,cluster_updater
cluster
: marks the Thing as a Clustercluster_updater
: marks the Thing for supportingota_edge_apps
software
Properties
- fleet_edge_apps: Allows you to group Clusters to apply OTA Edge Apps software updates using rollouts.
- mqtt-status: Status info about the MQTT connection (such as "Pending Connection").
- secret_name: Stored in the Cluster config files and in the Cluster property so they are linked (such as "01gojo0432p9qa3cd297v78ar4").
Actions
Actions are used to send commands to the Asset.
Events
- kubectl-logs: Final response of kubectl commands.
- send-kubernetes-api: Final response of Kubernetes API request.
- send-api: Final response of API request.
- metrics: Kubernetes metrics.
See the original template used to create Clusters.
Main Fields
Each Asset record in AnythingDB has a few preconfigured actions which you can use to control and configure your Asset remotely.
The following actions are defined automatically:
Action | Description |
---|---|
Run statistics/metrics gathering | Start and update the interval to receive the metrics. |
Send API | Send an API request to the Cluster |
Send kubectl | Send kubectl commands from Altair IoT Studio to the Asset. |
Stop statistics/metrics gathering | Stop the reception of metrics. |
Send Kubernetes API | Send a RESTful request to the Kubernetes API server running on the Asset. |
If an Action has a red settings icon and a greyed out Run button, then the Action needs to have parameters filled in before it can be executed. Click on the Settings icon to display the form.
When running an Action, the status updates for the Action are shown below the form. The final results of the Action are set up as an Event.
Action: Send kubectl
The Send kubectl form has three fields:
Name | Description |
---|---|
CorrelationId | Any alphanumeric text string specified by the user in order to match the resulting Event message to the originating Action. |
Command | Must be "kubectl". |
Arguments | Takes an array of strings based on the command line arguments for a kubectl command. This array can be entered using JSON notation. |
Useful kubectl commands translated into "command" and "arguments" parts:
Description | Command | Arguments |
---|---|---|
Get Nodes | kubectl | [ "get", "nodes"] |
Get Nodes (wide) | kubectl | [ "get", "nodes", "-o", "wide"] |
Top Node {node-name} | kubectl | [ "top", "node", "{node-name}"] |
Get Services | kubectl | [ "get", "services"] |
Get Config Maps | kubectl | [ "get", "configmaps"] |
Get Deployments | kubectl | [ "get", "deployments"] |
Restart Deployment {{deployment-name}} | kubectl | [ "rollout", "restart", "deployment",
"{deployment-name}"] |
Get Pods | kubectl | [ "get", "pods"] |
Top Pod {pod-name} | kubectl | [ "top", "pod", "{pod-name}"] |
Describe Pod {pod-name} | kubectl | [ "describe", "pod", "{pod-name}"] |
Apply YAML {configuration.yaml} | kubectl | [ "apply", "-f", "{configuration.yaml}"] |
Apply Multiple YAMLs | kubectl | [ "apply", "-f", "{configuration1.yaml}", "-f",
"{configuration2.yaml}"] |
Action: Send kubernetes API
Available Endpoints
API calls to the Kubernetes API server at the edge cluster can be made using the Send Kubernetes API action.
The form fields show the following parameters: CorrelationId
,
RequestMethod
, Href
, and
RequestBody
. This is a RESTful API.
The CorrelationId
is any alphanumeric text string specified by the
user in order to match the resulting Event message to the originating Action.
Implemented kubernetes API endpoints are a subset of https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.18/
- Currently Available
-
GET /api/v1/namespaces/{namespace}/pods/{name}/status GET /api/v1/namespaces/{namespace}/services/{name}/status GET /api/v1/namespaces/{namespace}/configmaps/{name} GET /api/v1/namespaces/{namespace}/pods/{name} GET /api/v1/namespaces/{namespace}/secrets/{name} GET /api/v1/namespaces/{namespace}/serviceaccounts/{name} GET /api/v1/namespaces/{namespace}/services/{name} GET /api/v1/namespaces/{namespace}/configmaps GET /api/v1/namespaces/{namespace}/pods GET /api/v1/namespaces/{namespace}/secrets GET /api/v1/namespaces/{namespace}/serviceaccounts GET /api/v1/namespaces/{namespace}/services GET /api/v1/namespaces/{name}/status GET /api/v1/namespaces/{name} GET /api/v1/nodes/{name}/status GET /api/v1/nodes/{name}
- K3s Custom Resource Definitions
-
GET /apis/helm.cattle.io/v1/namespaces/{namespace}/helmcharts POST /apis/helm.cattle.io/v1/namespaces/{namespace}/helmcharts GET /apis/helm.cattle.io/v1/namespaces/{namespace}/helmcharts/{name} PUT /apis/helm.cattle.io/v1/namespaces/{namespace}/helmcharts/{name} DELETE /apis/helm.cattle.io/v1/namespaces/{namespace}/helmcharts/{name}
- Custom
-
GET /apis/swx/v1/edge-apps POST /apis/swx/v1/edge-apps GET /apis/swx/v1/edge-apps/{edge-app-id} PUT /apis/swx/v1/edge-apps/{edge-app-id} DELETE /apis/swx/v1/edge-apps/{edge-app-id}
- Request Body
- The custom API endpoint is the equivalent of "kubectl apply" and accepts a URL as the request body or the actual yaml (string).