Management Service

The Management Service is responsible for orchestration and management of the Edge Compute Platform. It connects to the Altair IoT Studio cloud using MQTT and is installed by running the kubectl commands displayed when creating a new Asset in Studio (see Asset Management).

Interaction with the Management Service is done by requesting Actions. Results of these Actions get set up in Events.

Default Actions

The default Actions are already defined on the Asset's schema upon Asset creation. The section Asset Thing Details in AnythingDB describes how these can be used.
Send kubectl
Action as defined on the schema:
"send-kubectl": {
    "description": "Send a kubectl command to the cluster. Command must be an array of words",
    "input": {
        "properties": {
            "arguments": {
                "title": "The arguments of the command",
                "type": "array"
            },
            "command": {
                "const": "kubectl",
                "title": "The command",
                "type": "string"
            },
            "correlationId": {
                "title": "The correlationId",
                "type": "string"
            }
        },
        "type": "object"
    },
    "title": "Send kubectl"
},
Event as defined on the schema:
"kubectl-logs": {
    "data": {
        "properties": {
            "correlationId": {
                "description": "The ID used to match an incoming message with a response message.",
                "title": "The CorrelationID",
                "type": "string"
            },
            "response": {
                "description": "The output of the command that was run.",
                "title": "The Response",
                "type": "string"
            },
            "statusCode": {
                "description": "An HTTP Response Code.",
                "title": "The StatusCode",
                "type": "integer"
            },
            "statusMessage": {
                "description": "A description of the return status.",
                "title": "The StatusMessage",
                "type": "string"
            }
        },
        "title": "kubectl events",
        "type": "object"
    },
    "description": "Final response of kubectl command",
    "title": "Kubectl command is done"
},
Send Kubernetes API
Action as defined on the schema:
"send-kubernetes-api": {
    "description": "Send a Kubernetes API request to the cluster.",
    "input": {
        "properties": {
            "correlationId": {
                "title": "The correlationId",
                "type": "string"
            },
            "href": {
                "type": "string"
            },
            "requestBody": {
                "type": "string"
            },
            "requestMethod": {
                "type": "string",
                "enum": [
                    "GET",
                    "POST",
                    "PUT",
                    "PATCH",
                    "DELETE"
                ]
            }
        },
        "type": "object"
    },
    "title": "Send Kubernetes API"
},
Event as defined on the schema:
"send-kubernetes-api": {
    "data": {
        "properties": {
            "correlationId": {
                "description": "The ID used to match an incoming message with a response message.",
                "title": "The CorrelationID",
                "type": "string"
            },
            "response": {
                "description": "The output of the request that was run.",
                "title": "The Response",
                "type": "string"
            },
            "statusCode": {
                "description": "An HTTP Response Code.",
                "title": "The StatusCode",
                "type": "integer"
            },
            "statusMessage": {
                "description": "A description of the return status.",
                "title": "The StatusMessage",
                "type": "string"
            }
        },
        "title": "Kubernetes API events",
        "type": "object"
    },
    "description": "Final response of Kubernetes API request",
    "title": "Kubernetes API request is done"
},
Run statistics/metrics gathering
Action as defined on the schema:
"run-stats": {
    "description": "Start sending statistics/metrics as events on an interval",
    "input": {
        "properties": {
            "interval": {
                "title": "Frequency in seconds",
                "type": "integer"
            }
        },
        "type": "object"
    },
    "title": "Run statistics/metrics gathering"
},
Stop statistics/metrics gathering
Action as defined on the schema:
"stop-stats": {
    "description": "Stop sending statistics/metrics as events",
    "title": "Stop statistics/metrics gathering"
},

Additional Actions

The following Actions are not part of the asset schema by default. They can be manually added to enhance functionality. If indicated Studio will add the Action to the schema when installing the associated Edge Application.

Send API
This Action is needed for the API Client (see Using the Cluster API Inspector) and will be added to the Asset schema by Studio when installing the "App - Edge Compute Platform" application from the Marketplace.
Action as defined on the schema:
"send-api": {
    "description": "Send an API request to the cluster.",
    "input": {
        "properties": {
            "correlationId": {
                "type": "string"
            },
            "href": {
                "type": "string"
            },
            "requestBody": {
                "type": "string"
            },
            "requestMethod": {
                "type": "string",
                "enum": [
                    "GET",
                    "POST",
                    "PUT",
                    "PATCH",
                    "DELETE"
                ]
            }
        },
        "type": "object"
    },
    "title": "Send API"
},
Event as defined on the schema:
"send-api": {
    "data": {
        "properties": {
            "correlationId": {
                "description": "The ID used to match an incoming message with a response message.",
                "title": "The CorrelationID",
                "type": "string"
            },
            "response": {
                "description": "The output of the request that was run.",
                "title": "The Response",
                "type": "string"
            },
            "statusCode": {
                "description": "An HTTP Response Code.",
                "title": "The StatusCode",
                "type": "integer"
            },
            "statusMessage": {
                "description": "A description of the return status.",
                "title": "The StatusMessage",
                "type": "string"
            }
        },
        "title": "API events",
        "type": "object"
    },
    "description": "Final response of API request",
    "title": "API request is done"
},
Configure logger
This Action can be used to set the output level for the log of the Management Service.
Action as defined on the schema:
"configure-logger": {
    "description": "Configure the message output of the logger",
    "input": {
        "properties": {
            "color": {
                "title": "Colorize the pretty print",
                "type": "boolean"
            },
            "level": {
                "title": "Minimum log level",
                "type": "string",
                "enum": [
                    "debug",
                    "info",
                    "warning",
                    "error",
                    "critical"
                ]
            },
            "pretty": {
                "title": "Pretty print",
                "type": "boolean"
            }
        },
        "type": "object"
    },
    "title": "Configure logger"
},
Retrieve kubeconfig
This Action can only be used when the "App - ECP Tunnel" has been deployed. It will return a kubeconfig file to be used by a local client. The kubeconfig file is regenerated every six hours and would need to be retrieved again.
Action as defined on the schema:
"retrieve-kubeconfig": {
    "description": "Retrieve kubeconfig from cluster",
    "input": {
        "properties": {
            "correlationId": {
                "type": "string"
            },
            "format": {
                "type": "string",
                "enum": [
                    "yaml",
                    "json"
                ]
            }
        },
        "type": "object"
    },
    "title": "Retrieve kubeconfig"
},
Note: The format is "yaml" by default, but can be set to "json" too.
Event as defined on the schema:
"retrieve-kubeconfig": {
    "data": {
        "type": "object"
    },
    "description": "Retrieve kubeconfig result",
    "title": "Retrieve kubeconfig is done"
},
Manage a Kubernetes Deployment
This Action can be used to restart or scale a Deployment.
Note: Not all Deployments have been coded to be able to run with multiple instances at the same time.
Action as defined on the schema:
"manage-deployment": {
    "description": "Manage a kubernetes deployment",
    "input": {
        "properties": {
            "command": {
                "title": "The command",
                "type": "string",
                "enum": [
                    "restart",
                    "scale"
                ]
            },
            "correlationId": {
                "title": "The correlationId",
                "type": "string"
            },
            "parameters": {
                "properties": {
                    "deployment": {
                        "title": "Deployment name",
                        "type": "string"
                    },
                    "namespace": {
                        "title": "The namespace",
                        "type": "string"
                    },
                    "replicas": {
                        "title": "Number of replicas",
                        "type": "integer"
                    }
                },
                "title": "The parameters of the command",
                "type": "object"
            }
        },
        "type": "object"
    },
    "title": "Manage Deployment"
},
The command property needs to be either restart or scale. Scale to 0 can be used to temporarily halt the service.
Event as defined on the schema:
"manage-deployment": {
    "data": {
        "type": "object"
    },
    "description": "Final response of Manage Deployment request",
    "title": "Manage Deployment is done"
},
Backup/restore database
This Action can be used to backup or restore a database file to/from a remote SFTP server.
Note: Only applications/services that use an sqlite database have this functionality available.
Action as defined on the schema:
"restore-command": {
    "description": "Backup/restore database",
    "input": {
        "properties": {
            "command": {
                "title": "The command",
                "type": "string",
                "enum": [
                    "backup-database",
                    "restore-database"
                ]
            },
            "correlationId": {
                "title": "The correlationId",
                "type": "string"
            },
            "parameters": {
                "properties": {
                    "deployment": {
                        "title": "Deployment name",
                        "type": "string"
                    },
                    "host": {
                        "title": "SFTP server host",
                        "type": "string"
                    },
                    "port": {
                        "title": "SFTP server port",
                        "type": "integer"
                    },
                    "user": {
                        "title": "SFTP server username",
                        "type": "string"
                    },
                    "password": {
                        "title": "SFTP server password",
                        "type": "string"
                    },
                    "remotePath": {
                        "title": "SFTP server path for storage",
                        "type": "string"
                    }
                },
                "title": "The parameters of the command",
                "type": "object"
            }
        },
        "type": "object"
    },
    "title": "Run backup/restore"
},
The command property needs to be either backup-database or restore-database. Backup will upload the local copy of the database file to the remote SFTP server. Restore will download the remote copy and replace the local copy with it after which the application/service will restart and use the restored database.
Event as defined on the schema:
"restore-command": {
    "data": {
        "type": "object"
    },
    "description": "Final response of backup/restore request",
    "title": "Backup/restore is done"
},
Copy Kubernetes Resource
This Action can be used to copy a kubernetes resource from one namespace to another. This can be useful for copying configmaps or secrets.
Note: This should only be attempted if you are sure there are no adverse consequences.
Action as defined on the schema:
"copy-resource": {
    "description": "Copy kubernetes resource",
    "input": {
        "properties": {
            "command": {
                "title": "The command",
                "type": "string",
                "const": "copy"
            },
            "correlationId": {
                "title": "The correlationId",
                "type": "string"
            },
            "parameters": {
                "properties": {
                    "type": {
                        "title": "Type of resource",
                        "type": "string"
                    },
                    "from": {
                        "properties": {
                            "namespace": {
                                "title": "Namespace of source resource",
                                "type": "string"
                            },
                            "name": {
                                "title": "Name of source resource",
                                "type": "string"
                            }
                        },
                        "title": "Details of source resource",
                        "type": "object"
                    },
                    "to": {
                        "properties": {
                            "namespace": {
                                "title": "Namespace of destination resource",
                                "type": "string"
                            },
                            "name": {
                                "title": "Name of destination resource",
                                "type": "string"
                            }
                        },
                        "title": "Details of destination resource",
                        "type": "object"
                    }
                },
                "title": "The parameters of the command",
                "type": "object"
            }
        },
        "type": "object"
    },
    "title": "Run copy resource"
},
The command property can only be copy. The type of the resource to copy can only be one of the following: secrets, configmaps, deployments, or services.
Event as defined on the schema:
"copy-resource": {
    "data": {
        "properties": {
            "correlationId": {
                "description": "The ID used to match an incoming message with a response message.",
                "title": "The CorrelationID",
                "type": "string"
            },
            "response": {
                "description": "The output of the request that was run.",
                "title": "The Response",
                "type": "string"
            },
            "statusCode": {
                "description": "An HTTP Response Code.",
                "title": "The StatusCode",
                "type": "integer"
            },
            "statusMessage": {
                "description": "A description of the return status.",
                "title": "The StatusMessage",
                "type": "string"
            }
        },
        "title": "Copy resource events",
        "type": "object"
    },
    "description": "Final response of the copy resource request",
    "title": "Copy resource is done"
},