Creating a Containerized Application

Function

Creates a containerized application. The message parameters are configurations of a containerized application. The created containerized application is stored in the MEF Center database. Only the created containerized application can be deployed or uninstalled. After receiving the containerized application creation message, MEF Center verifies the validity of each field in the message. If the verification is successful, it saves the containerized application parameters to the database and returns a unique containerized application ID in the message.

Syntax

Operation type: POST

URL: https://{ip}:{port}/edgemanager/v1/app

Request header:

Content-Type: application/json

Request message body:

{
    "appName": AppName,
    "containers": [
        {
            "name": ContainerName,
            "cpuRequest": CpuRequest,
            "cpuLimit": CpuLimit,
            "memRequest": MemoryRequest,
            "memLimit": MemoryLimit,
            "npu": Npu,
            "image": ImageName,
            "imageVersion": ImageVersion,
            "env": [
                {
                    "name": EnvVarName,
                    "value": EnvVarValue
                }
            ],
            "userID": UserId,
            "groupID": GroupId,
            "command": [
                Command
            ],
            "args" : [
                Argument
            ],
            "containerPort" : [
                {
                    "name" : PortName,
                    "proto" : PortProto,
                    "containerPort" : ContainerPort,
                    "hostIP" : HostIP,
                    "hostPort" : HostPort
                }
            ],
            "hostPathVolumes":[
                {
                    "name": name1,
                    "hostPath": HostPath,
                    "mountPath": mountPath
                }
            ]
        }
    ],
    "description": Description
}

Request Parameters

Table 1 Parameters for creating a containerized application

Parameter

Mandatory/Optional

Description

Value

appName

Mandatory

Name of a containerized application

The value is a string of 1 to 32 characters, including lowercase letters, digits, and hyphens (-). The value must start and end with a letter or digit.

description

Optional

Description of a containerized application

The value is a string of 0 to 512 characters. Whitespace characters except a space are not supported.

containers

Mandatory

Containerized application configuration array

Object array. The number of containerized applications supported ranges from 1 to 10.

Table 2 containers description

Parameter

Mandatory/Optional

Description

Value

name

Mandatory

Containerized application name

The value is a string of 1 to 32 characters, including lowercase letters, digits, and hyphens (-). The value must start and end with a letter or digit. The container name must be unique.

cpuRequest

Mandatory

Number of CPU cores requested by a containerized application

The value is a number ranging from 0.01 to 1000 and accurate to two decimal places.

cpuLimit

Optional

Maximum number of CPU cores used by a containerized application

The value is a number ranging from 0.01 to 1000, accurate to two decimal places, and greater than or equal to cpuRequest.

memRequest

Mandatory

Size of the memory allocated by a containerized application

The value is an integer ranging from 4 to 1024000, in MiB.

memLimit

Optional

Maximum memory size used by a containerized application

The value is an integer ranging from 4 to 1024000, in MiB. The value must be greater than or equal to memRequest.

npu

Optional

Number of NPU cores allocated by a containerized application

The value is an integer ranging from 0 to 32.

image

Mandatory

Name of the image to be used. If a third-party image repository is used, the full name must contain the IP address or domain name of the image repository server, port number, project, and image name, for example, fd.fusiondirector.huawei.com:443/library/ubuntu. If you do not specify the host name and port number of the image, the containerized application uses the public Docker repository.

The value is a string of 1 to 256 characters, including lowercase letters, uppercase letters, digits, and special characters (:-._/).

imageVersion

Mandatory

Image version

The value is a string of 1 to 32 characters, including lowercase letters, uppercase letters, digits, and special characters (-._).

env

Optional

Environment variables configured in a containerized application

EnvVar object array. A maximum of 256 key-value pairs are supported.

userID

Optional

User ID specified for running a containerized application

If this parameter is not set, the user who creates the image runs a containerized application. If the user is not a numeric ID or the numeric ID is 0, the containerized application fails to run after being deployed. To run an inference containerized application, the driver device is required. In this case, the user ID cannot be configured.

The value is a number ranging from 1 to 65535 and cannot be set to 0. That is, a container cannot be run by the root user.

When deploying an inference containerized application, set userID to the user ID (usually 1000) of HwHiAiUser.

groupID

Optional

Group ID specified for running a containerized application

If this parameter is not set, the user group who creates the image runs a containerized application. If the user is not a numeric group ID or the numeric group ID is 0, the containerized application fails to run after being deployed. To run an inference containerized application, the driver device is required. In this case, the group ID cannot be configured.

The value is a number ranging from 1 to 65535 and cannot be set to 0. That is, a containerized application cannot be run by the root group.

When deploying an inference containerized application, set groupID to the group ID (usually 1000) of HwHiAiUser.

command

Optional

Command executed for starting a containerized application

Character string array. The command list supports a maximum of 16 commands. Each command contains 1 to 256 characters, including lowercase letters, uppercase letters, lowercase letters, digits, spaces, and spacial characters (-/._). The command must end with a letter or digit.

args

Optional

Command parameters for starting a containerized application

Character string array. The parameter list supports a maximum of 16 parameters. Each parameter contains 1 to 256 characters, including lowercase letters, uppercase letters, digits, spaces, and spacial characters (-/._=). The parameter must end with a letter or digit.

containerPort

Optional

Host port and intra-container port mapping configured for a containerized application

ContainerPort object array. A maximum of 16 groups of ports are supported.

hostPathVolumes

Optional

Mounting path configuration of a containerized application

When creating an inference containerized application, you need to configure the mounting path. Otherwise, the application may fail to run.

HostPathVolumes object array. A maximum of 256 groups are supported.

Table 3 envVar description

Parameter

Mandatory/Optional

Description

Value

name

Mandatory

Name of an environment variable

The value is a string of 2 to 32 characters, including uppercase letters, lowercase letters, digits, and spacial characters (-._). It must start with a letter and end with a letter or digit.

value

Mandatory

Value of an environment variable

The value is a string of 1 to 512 characters, including uppercase letters, lowercase letters, digits, spacial characters (-._/:), and spaces.

Table 4 containerPort description

Parameter

Mandatory/Optional

Description

Value

name

Mandatory

Port mapping name

The value is a string of 1 to 32 characters, including lowercase letters, digits, and hyphens (-). It must start and end with a lowercase letter or digit.

proto

Mandatory

Network transport layer protocol specified by port mapping

Character string. The value can be TCP or UDP.

containerPort

Mandatory

Port in a containerized application

The value is an integer ranging from 1 to 65535.

hostIP

Mandatory

IP address of the host bound for port mapping

The value is a character string and must be a valid host IP address. Only IPv4 addresses are supported. The value cannot be all 0s or all 255s.

hostPort

Mandatory

Host port address for port mapping

The value is an integer ranging from 1024 to 65535.

Table 5 hostPathVolumes description

Parameter

Mandatory/Optional

Description

Value

name

Mandatory

Name of the volume to be attached

The value is a string of 1 to 32 characters, including lowercase letters, digits, and hyphens (-). It must start and end with a letter or digit.

The name of the volume mounted to the same containerized application must be unique.

hostPath

Mandatory

Host path used by a containerized application to mount volumes

NOTE:

Only the host paths of the listed files or directories can be configured. If you create a container image by referring to Creating an Inference Image or Atlas 200I A2 Accelerator Module Ascend Software Quick Installation Guide, see "Creating a Container Image > Starting a Container".

Only the host paths to which the following files or directories are mounted can be configured:

  • "/etc/sys_version.conf"
  • "/etc/hdcBasic.cfg"
  • "/usr/lib64/libaicpu_processer.so"
  • "/usr/lib64/libaicpu_prof.so"
  • "/usr/lib64/libaicpu_sharder.so"
  • "/usr/lib64/libadump.so"
  • "/usr/lib64/libtsd_eventclient.so"
  • "/usr/lib64/libaicpu_scheduler.so"
  • libcrypto.so.1.1
    • Ubuntu host OS: "/usr/lib/aarch64-linux-gnu/libcrypto.so.1.1"
    • openEuler host OS: "/usr/lib64/libcrypto.so.1.1.1m"
  • libyaml-0.so.2
    • Ubuntu host OS: "/usr/lib/aarch64-linux-gnu/libyaml-0.so.2.0.6"
    • openEuler host OS: "/usr/lib64/libyaml-0.so.2.0.9"
  • "/usr/lib64/libdcmi.so"
  • "/usr/lib64/libmpi_dvpp_adapter.so"
  • "/usr/lib64/aicpu_kernels/"
  • "/usr/local/sbin/npu-smi"
  • "/usr/lib64/libstackcore.so"
  • "/usr/local/Ascend/driver/lib64"
  • "/var/slogd"
  • "/var/dmp_daemon"

mountPath

Mandatory

Mounting path of a container

The path must start with a slash (/) and then be followed by uppercase letters, lowercase letters, digits, and spacial characters (_./-). The path cannot contain two consecutive periods (..). The total length of the path is 2 to 512 characters. The mounting path names in the same container must be unique.

Usage Example

Request:

POST https://10.10.10.10:30035/edgemanager/v1/app

Request message body:

{
    "appName": "mef-apptest1",
    "containers": [
        {
            "name": "container1",
            "cpuRequest": 1,
            "cpuLimit": 1,
            "memRequest": 200,
            "memLimit": 200,
            "image": "ubuntu",
            "imageVersion": "22.04",
            "env": [
                {
                    "name": "lib",
                    "value": "/test"
                }
            ],
            "userID": 1001,
            "groupID": 1001,
            "command": [
                "/bin/bash","-c"
            ],
            "args" : [
                "sleep 30000"
            ],
            "containerPort" : [
                {
                    "name" : "test-port",
                    "proto" : "TCP",
                    "containerPort" : 1234,
                    "hostIP" : "xx.xx.xx.xx",
                    "hostPort" : 30023
                }
            ]
        }
    ],
    "description": "a test case for app-manager"
}
Response:
{
    "status":"00000000",
    "msg":"success",
    "data":3
}

Response status code: 200

Output Description

Table 6 Operation output description

Parameter

Type

Description

status

String

Error code

msg

String

Description

data

Number

ID of the created containerized application