更新时间:2023-11-23 GMT+08:00

查询应用实例列表

功能介绍

该API用于查询应用实例列表。

URI

GET /v3/{project_id}/edgemgr/pods?{node_id=xxx,limit=xxx,offset=xxx}

URI中需要至少携带一个ID查询参数,即node_id、group_id、deployment_id、deployment_ids四选一,详细说明请参见表2

表1 Path参数

参数

是否必选

参数类型

描述

project_id

String

项目ID,获取方法请参见获取项目ID

表2 查询参数

参数

是否必选

参数类型

描述

node_id

String

指定节点查询应用实例,可选。

与group_id、deployment_id、deployment_ids四选一

group_id

String

指定节点组查询应用实例,可选。

与node_id、deployment_id、deployment_ids四选一

deployment_id

String

指定应用部署ID查询应用实例,可选。

与node_id、group_id、deployment_ids四选一

deployment_ids

String

指定应用部署ID列表查询应用实例,多个ID使用逗号分隔,可选。

与node_id、group_id、deployment_id四选一

limit

Integer

查询返回记录的数量限制

offset

Integer

偏移量,表示查询该偏移量后面的记录

请求参数

表3 请求Header参数

参数

是否必选

类型

描述

Content-Type

String

消息体的类型(格式)

推荐您使用默认值application/json。

X-Auth-Token

String

用户Token。通过调用IAM服务获取用户Token接口获取(响应消息头中X-Subject-Token的值)。

响应参数

状态码为 200 时:

表4 响应Body参数

参数

参数类型

描述

count

Long

应用实例总数

pods

Array of PodResponse objects

-

表5 PodResponse

参数

参数类型

描述

id

String

应用实例uuid

name

String

应用实例名称

configs

PodConfigs object

应用实例配置

affinity

affinity object

应用实例亲和性规则,仅铂金版支持

init_containers

Array of ContainerResp objects

应用实例init容器

containers

Array of ContainerResp objects

应用实例业务容器

node_id

String

应用实例所在节点

deployment_id

String

应用ID

project_id

String

项目ID

reason

String

应用实例故障原因

message

String

应用实例故障详情

created_at

String

应用实例创建时间

updated_at

String

应用实例更新时间

state

String

应用实例状态

表6 ContainerResp

参数

参数类型

描述

args

Array of strings

容器启动参数

command

Array of strings

容器启动命令

name

String

容器名称,只允许英文小写字母、数字、中划线,最大长度32,英文小写字母或数字开头和结尾

envs

Array of Env objects

容器环境变量键值对

image_url

String

容器镜像URL

version

String

容器镜像版本

liveness_probe

Probe object

工作负载存活探针配置

readiness_probe

Probe object

工作负载业务探针配置

ports

Array of HostContainerPortMapping objects

容器端口映射

resources

ResQuest object

资源量

volumes

Array of Volume objects

容器挂载卷

restarts

Long

容器重启次数

message

String

容器故障详情

reason

String

容器故障原因

is_ready

String

健康检查结果

privileged

Boolean

容器特权模式,默认值为false

container_id

String

容器ID

state

String

容器状态

npu_type

String

npu类型,支持D310类型。

  • D310表示D310类型
  • 不填表示为D310类型
表7 Volume

参数

参数类型

描述

name

String

卷名称,小写字母或数字,最长63个字符

type

String

卷的类型,支持configMap、secret、emptyDir、hostPath

read_only

Boolean

读写权限,默认读

source

String

卷来源,type为hostPath时输入路径,要求以/开头,后面可包含中划线、反斜杠、下划线、点号、字母、数字。

secret时输入secret名称,configMap时输入configMap名称,emptyDir时输入disk或memory。

destination

String

卷挂载路径,必须是合法的路径

表8 ResQuest

参数

参数类型

描述

limits

Res object

资源限制量

requests

Res object

资源申请量

表9 Res

参数

参数类型

描述

cpu

String

cpu核数,大于等于0.01,最大1000

memory

String

内存大小,单位兆,大于等于0.01,最大1024000。注意:内存的limits值最小为4

gpu

String

Gpu显存大小,单位兆,大于等于0.01,最大1024000

npu

String

Npu个数,大于0,最大1000

表10 HostContainerPortMapping

参数

参数类型

描述

container_port

Long

容器端口,1到65535之间的整数

host_port

Long

容器端口,1到65535之间的整数

host_ip

String

对应主机网卡地址

表11 Probe

参数

参数类型

描述

http_get

HttpGet object

http健康检查

exec

表13 object

执行命令检查

initial_delay_seconds

Long

表示从工作负载启动后从多久开始探测,大于0且不大于3600的整数,默认为10

timeout_seconds

Long

表示探测超时时间,大于0且不大于3600的整数,默认为1

表12 HttpGet

参数

参数类型

描述

path

String

必须要以/开头,构造结果为:协议类型://主机地址:端口路径

port

Integer

探测的http端口,1到65535之间的整数

host

String

主机地址,默认为容器IP

scheme

String

协议类型,HTTP或HTTPS,默认HTTP

表13 Exec

参数

参数类型

描述

command

String

探针执行命令,最大长度10240个字符

表14 Env

参数

参数类型

描述

name

String

环境变量的key,由大小写字母或下划线开头,由数字、大小写字母、下划线组成,最大长度2048个字符

value

String

环境变量的value,最大长度20480个字符

表15 PodConfigs

参数

参数类型

描述

host_network

Boolean

应用实例是否启用主机网络,不启用则使用端口映射,默认值false

host_pid

Boolean

应用实例是否与主机共PID命名空间,默认值false

migration

Boolean

应用实例故障是否迁移,指定节点组部署时必选,默认值false

restart_policy

String

应用实例重启策略,可选值Always、OnFailure、Never

toleration_seconds

Integer

应用实例故障容忍时间,容忍时间到达后迁移应用实例,只在指定节点组部署时生效

状态码为 400 时:

表16 响应Body参数

参数

参数类型

描述

error_code

String

错误码

error_msg

String

错误描述信息

状态码为 500 时:

表17 响应Body参数

参数

参数类型

描述

error_code

String

错误码

error_msg

String

错误描述信息

请求示例

GET https://{endpoint}//v3/{project_id}/edgemgr/pods?deployment_ids=a71077f0-a491-4e1c-a41a-7d6910da26cb,77340b19-b52e-4708-83fd-3ca86f5a292e

响应示例

状态码为 200 时:

{
    "count": 1,
    "pods": [
        {
            "id": "3e64d98a-37c5-43a6-9bfe-052b9083e362",
            "name": "app-test-69f9dc4b67-wfwn6",
            "description": "this is a test pod",
            "configs": {
                "host_network": true,
                "host_pid": true,
                "migration": true,
                "restart_policy": "Always",
                "toleration_seconds": 300
            },
            "containers": [
                {
                    "args": [
                        "-c",
                        "sleep 1000"
                    ],
                    "command": [
                        "/bin/bash"
                    ],
                    "name": "container-0",
                    "envs": [
                        {
                            "name": "CERT_PATH",
                            "value": "/opt/cert"
                        }
                    ],
                    "image_url": "",
                    "npu_type": "",
                    "liveness_probe": {
                        "http_get": {
                            "path": "/",
                            "port": 80,
                            "scheme": "http"
                        },
                        "initial_delay_seconds": 10,
                        "timeout_seconds": 10
                    },
                    "readiness_probe": {
                        "http_get": {
                            "path": "/",
                            "port": 80,
                            "scheme": "http"
                        },
                        "initial_delay_seconds": 10,
                        "timeout_seconds": 10
                    },
                    "ports": [
                        {
                            "container_port": 80,
                            "host_port": 80
                        }
                    ],
                    "resources": {
                        "limits": {
                            "cpu": 0.25,
                            "memory": 500,
                            "gpu": 500
                        },
                        "requests": {
                            "cpu": 0.25,
                            "memory": 500,
                            "gpu": 500
                        }
                    },
                    "volumes": [
                        {
                            "name": "log-volume",
                            "type": "hostPath",
                            "read_only": false,
                            "source": "/var/IEF",
                            "destination": "/var/IEF"
                        }
                    ],
                    "restarts": 0,
                    "message": "",
                    "reason": ""
                }
            ],
            "node_id": "ff5f5129-f53f-4129-9f7f-ca7837063b5f",
            "project_id": "bcd83056c918480f8f190844bd425b23",
            "reason": "",
            "message": "",
            "created_at": "2019-10-10T02:24:02.325Z",
            "updated_at": "2019-10-10T02:24:02.325Z",
            "state": "RUNNING"
        }
    ]
}

状态码为 400 时:

{
	"error_code" : "IEF.100001",
	"error_msg" : "PROJECT_ID not found"
}

状态码为 500 时:

{
	"error_code" : "IEF.100158",
	"error_msg" : "Fail to extract gpu information"
}

错误码

请参见错误码