Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents
maxLevel2

Introduction

These APIs provide services for manipulating ote-stack platform on AI Edge Blueprint. 

...

Code Block
collapsetrue
GET /v1/repository/third/repo1
Response:
{
    "data": {
                "repositoryId":"yq01",
                "address":"xxzxsdsdsds",
                "user":"ddddddd"
    },
    "code": 200,
    "message": "Success"
}

Application Management

Create Application

POST /v1/app

Parameters

Name

Type

Required

Description

appName

stringyesThe name of applicaton
deployTypestringyes

Deployment mode: Only deployment or daemonset can be set

imagestringyesImage repository with specified tag.
versionstringyesMain version with format x.x, for example 1.1.
repositoryIdstringnoThe ID of repository whose secret can be used to pull docker image.
portarrayyesThe exposed port.
commandstringnoStart command line.
volumearraynoVolume information.
envarraynoExecuting environment.
replicasuint32noDefault replicas. Effective only at deployment.
minReplicasuint32noMinimal replicas. Effective only at deployment.
maxReplicasuint32noMaximun replicas. Effective only at deployment.
minCPUuint32yesMinimal cpu (%)
maxCPUuint32yesMaximun cpu(%)
GPUuint32noGPU count
isHPAboolyes
Allow to use horizontal pod autoscaler
targetCPUUtilizationuint32yes

CPU utilization which will trigger autoscale

targetMemUtilizationuint32yes
CPU utilization which will trigger autoscale
minMemoryuint32yes
Minimal memory (MB)
maxMemoryuint32yes
Maximun memory (MB)

maxUnavailable

uint32yes
Max unavailable pod

maxSurge

uint32yesmax surge pod

minReadySeconds

uint32yesmin ready seconds for updating


Example

Code Block
titleExample
collapsetrue
POST  /v1/app
Body:
{
    "appName": "nginx1",
    "deployType": "deployment",
    "image": "nginx:latest",
    "version": "1.2",
    "repositoryId": "repo1",
    "replicas": 10,
    "port": [
       {"port": 8080, "hostPort": 9090}],
    "command": "",
    "volume": [
       {"path": "/host/usr/bin", "hostPath": "/usr/bin", "readOnly": true},
       {"path": "/host/usr/sbin", "hostPath": "/usr/sbin", "readOnly": true} ],
    "env": [
       {"name": "NGINX_PATH", "value": "/usr/share/nginx/" } ],
    "minReplicas": 2,
    "maxReplicas": 20,
    "minCPU": 10,
    "maxCPU": 200,
    "isHPA": true,
    "targetCPUUtilization": 100,
    "targetMemUtilization": 150,
    "minMemory": 100,
    "maxMemory": 200,
    "maxUnavailable": 1,
    "maxSurge": 1,
    "minReadySeconds": 10,
}
Response:
{
	"code": 200,
	"message": "success"
}

Delete Application

DELETE /v1/app

Parameters

NameTypeRequiredDescription

appId

[ ]intyesThe IDs of application

Example

Code Block
collapsetrue
DELETE  /v1/app
{
   "appId": [1,2,3,4]
}

List Applications

GET /v1/app

Description

List applications.

Parameters

NameTypeRequiredDefaultDescription
pageSizeintno10The size of per page, 0 for limited.
pageintno1The page number

appName

stringno
application name for filtering result
appNameModestringnopartial

the filter mode: strict, partial, prefix

versionstringno
version

Example

Code Block
collapsetrue
Get /v1/app
{
  "apps": [ {
    "id": 1,
    "appName": "nginx1",
    "status": 1,
    "deployType": "deployment",
    "image": "nginx:latest",
    "projectName": "proj1",
    "repositoryId": "repo1",
    "version": "1.2.3.4",
    "replicas": 10,
    "port": [
       {"port": 8080, "hostPort": 9090}],
    "command": "",
    "volume": [
       {"path": "/host/usr/bin", "hostPath": "/usr/bin", "readOnly": true},
       {"path": "/host/usr/sbin", "hostPath": "/usr/sbin", "readOnly": true} ],
    "dependence": [
       {"name": "nginx", "service": "xxxx", "port": 9090 } ],
    "env": [
       {"name": "NGINX_PATH", "value": "/usr/share/nginx/" } ],
    "minReplicas": 2,
    "maxReplicas": 20,
    "minCPU": 0.1,
    "maxCPU": 2,
    "GPU": 2,
    "isHPA": true,
    "targetCPUUtilization": 1,
    "targetMemUtilization": 150,
    "minMemory": 100,
    "maxMemory": 200,
    "maxUnavailable": 1,
    "maxSurge": 1,
    "minReadySeconds": 10,
    "createTime": 1551758321,
    "updateTime": 1551758321},
  ]
  "total": 1,
  "code": 200,
  "message": "Success"
}

Get Application

GET /v1/app/id/{appId}

Description

Return specified application information by ID.

Parameters

NameTypeRequiredDescription
appIdintnoThe ID of application

Example

Code Block
collapsetrue
GET  /v1/app/id/1
{
  "data": {
    "id": 1,
    "appName": "nginx1",
    "status": 1,
    "deployType": "deployment",
    "image": "nginx",
    "projectName": "proj1",
    "repositoryId": "repo1",
    "version": "1.2.3",
    "replicas": 10,
    "port": [
       {"port": 8080, "hostPort": 9090}],
    "command": "",
    "volume": [
       {"path": "/host/usr/bin", "hostPath": "/usr/bin", "readOnly": true},
       {"path": "/host/usr/sbin", "hostPath": "/usr/sbin", "readOnly": true} ],
    "dependence": [
       {"name": "nginx", "service": "xxxx", "port": 9090 } ],
    "env": [
       {"name": "NGINX_PATH", "value": "/usr/share/nginx/" } ],
    "minReplicas": 2,
    "maxReplicas": 20,
    "minCPU": 0.1,
    "maxCPU": 2,
    "GPU": 1,
    "isHPA": true,
    "targetCPUUtilization": 1,
    "targetMemUtilization": 150,
    "minMemory": 100,
    "maxMemory": 200,
    "maxUnavailable": 1,
    "maxSurge": 1,
    "minReadySeconds": 10,
    "createTime": 1551758321,
    "updateTime": 1551758321
  },
  "code": 200,
  "message": "Success"
}

Upload Helm Chart to Create Application 

POST /v1/app/chart

Description

Upload a helm chart tar file to create the application. The request type must be multipart/form-data.

Parameters

NameTypeRequiredDescription

appName

string

yes

The name of application

version

string

yes

version

chart

file

yes

the chart file needs to be upload

Example

Code Block
POST /v1/app/chart
appName=test
version=1.1
chart=@file

curl 0.0.0.0/v1/app/chart -F "version=1.2" -F "appName=test1" -F "chart=@file"

Deployment Management

Create Deployment

POST /v1/deploy

Description

Deploy the application to specified cluster.

Parameters

NameTypeRequiredDescription
deployNamestringyesThe unique name of deployment.
appNamestringyesThe application that will be deployed.
versionstringyesThe version of application.
clusterstringyes

The label of cluster that will install the application, default all cluster.

nodeLabelstringyesThe label of node that will install the application, default all node.
commentstringyesThe comment about deployment.

Example

Code Block
collapsetrue
POST  /v1/deploy/install
Body:
{
    "deployName": "nginx1",
    "appName": "nginx1",
    "version": "1.1.1.1",
    "cluster": "cluster1",
    "nodeLabel": "node1",
    "comment": ""
}
Response:
{
    "code": 200,
    "message": "success"
}

Delete Deployment

DELETE /v1/deploy/{deployName}

Description

Delete deployment by name.

Parameters

NameTypeRequiredDescription
deployNamestringyesThe name of deployment.

Example

Code Block
collapsetrue
DELETE  /v1/deploy/deploy1
Response:
{
    "code": 200,
    "message": "success"
}

Upgrade Deployment

POST /v1/deploy/id/{deployId}

Description

Upgrade the deployment to specified version.

Parameters

NameTypeRequiredDescription
deployIdintyesThe ID of deployment.
versionstringyesThe version of application that needs to be upgraded to.
commentstringnoThe comment about upgrade.

Example

Code Block
collapsetrue
POST  /v1/deploy/id/1
Body:
{
    "version": "1.1.1.2"
}
Response:
{
    "code": 200,
    "message": "success"
}

List Deployment

GET /v1/deploy

Description

List all deployments.

Parameters

NameTypeRequiredDefaultDescription
pageSizeintno10The size of per page, 0 for no limited.
pageintno1The page number
fieldstringno
Fields that need be presented, default all informations.

appName

stringno
The name of application for filtering result.
appNameModestringnopartial

The mode of filter: strict, partial, prefix.

editable

stringnoall

The flag, which indicates if the deployment can be update now, is used for filtering result. The value can be: true, false, or all.

runningstringnoall

The running status of deployment for filtering result. The value can be: true, or all.

Response Parameters

NameTypeDescription
idint32ID
deployNamestringThe name of deployment.
appNamestringThe name of application.
versionstringThe version of application.
clusterstringThe cluster that have deployed.
nodeLabelstringThe node that have deployed.
commentstringThe comment about deployment.

deployType

int32The deployment type: 1: new deployment, 2: upgrading, 3: rollbacking, 4: deleted
statusint32

The status of deployment:0: pending 1: Approved 2: Disapproved 3:Processing 4:Deploying 5: Success 6: Partial success 7: Failed 8: Internal error 9: Deleted

createTimeint32The creation time of deployment.
updateTimeint32The update time of deployment.
editableboolThe flag that indicates if the deployment can be update now.
errorMessagestringThe detailed deployment status which contains the count of running pod and error pod.
auditCommentstringThe comment about audit.

Example

Code Block
collapsetrue
GET  /v1/deploy?pageSize=10&page=1
Response:
{
 "data": [ {
    "id": 1,
    "deployName": "nginx1",
    "appName": "nginx1",
    "version": "1.1.1.1",
    "cluster": "cluster1",
    "nodeLabel": "node1",
    "deployType": 1
    "status": 6,
	"errorMessage": "{\"running\": 10, \"error\": 3, \"total\": 13}",
    "comment": ""
    "editable": true,
    "createTime": 1551758321,
    "updateTime": 1551758321}
  ],
  "total": 1 
}

Rollback Deployment

PUT /v1/deploy/id/{deployId}

Description

Rollback the deployment to previous version.

Parameters

NameTypeRequiredDescription
deployIdintyesThe ID of deployment.
versionstringyesThe version that needs to rollback to.
commentstringyesThe comment about rollback.

Example

Code Block
collapsetrue
PUT  /v1/deploy/id/1
Body:
{
    "version": "1.1.1.2",
    "comment": ""
}
Response:
{
    "code": 200,
    "message": "success"
}

Get Deployment

GET /v1/deploy/id/{deployId}

Description

Get specified deployment information by ID.

Parameters

NameTypeRequiredDescription

field

stringnoThe fields that need to be presented, default all information without history version information. But when field=historyVersion, the API will return all versions of deployed application.
Response parameters

Same as the API of List Deployment

Code Block
collapsetrue
GET  /v1/deploy/id/1
Response:
{
  "data" : {
    "id": 1,
    "deployName": "nginx1",
    "appName": "nginx1",
    "version": "1.1.1.2",
    "cluster": "cluster1",
    "nodeLabel": "node1",
    "status": 6,
    "comment": "",
    "errorMessage": "{\"running\": 10, \"error\": 3, \"total\": 13}",
    "deployType": 1,
    "createTime": 1551758321,
    "updateTime": 1551758321
    }
  }
}

Delete Deployment

DELETE /v1/deploy/id/{deployId}

Parameters

NameTypeRequiredDescription
deployIdintyesThe ID of deployment that needs to be removed

Example

Code Block
collapsetrue
DELETE  /v1/deploy/id/1

Audit Deployment

PUT /v1/admin/deploy

Description

Audit the deployment created by general user. This can only be done by general administrator and system administrator. 

Parameters 

Name

Type

Required

Description

idintyesID
statusintyesThe status of deployment
commentstringyesThe comment of

Example

Code Block
POST /v1/admin/deploy
Body:
{
  "id": 123456,
  "status": 0,
  "comment": "xxxx"
}

List Audit List of Deployment

GET /v1/admin/deploy

Description

List deployment that needs to be audited. This can only be done by general administrator and system administrator. 

Parameters

Name

Type

Required

Default

Description

orderBystring
id
orderBy allows sorting by id.
orderstringdescorder sort: asc,desc
businessNamestring
The name of business for filtering result
pageint1The page number
pageSizeint10The page size of per page

Response code

Code

Description

200

Successfully.

422

Unprocessable Entity

500

Unexpected internal errors

Response parameters

Name

Type

Description

id

intID

businessName

stringThe name of business.

appName

stringThe name of application.

version

stringThe version of application

cluster

stringThe cluster that will be deployed to.

deployId

intThe ID of deployment.

deployType

intThe type of deployment, 1: new deployment, 2: upgrading, 3: rollbacking, 4: deleted

status

intThe status of audit.

comment

stringThe comment of audit.

createTime

intThe create time.

updateTime

intThe time of the audit.

Example

Code Block
collapsetrue
GET /v1/admin/deploy

Response:
{
    "data": [
        {
            "id": 6878,
            "businessName": "a",
            "appName": "dsdar2",
            "version": "1.2.1",
            "cluster":"bjct",
            "deployType":1,
            "status":0,
            "comment":"no pass",
            "createTime": 1551758321,
            "updateTime": 1551758321
        }
    ],
    "total": 1,
    "code": 200,
    "message": "success"
}