查询 pod 资源池#

功能介绍#

K8s 上部署 openYuanrong 集群时,查询已创建的 pod 资源池。

URI#

GET /serverless/v1/podpools?id={id}&group={group}&offset={offset}&limit={limit}

查询参数

参数

是否必选

参数类型

描述

id

String

pod 资源池 ID, 精准匹配。

group

String

pod 资源池组, 精准匹配。

offset

int

查询起始页。
取值: 大于等于 0,小于 0 时返回空。不填或填 0 时, 默认值为 1

limit

int

查询页的大小。
取值: 大于 0,小于等于 0 时返回空。不填时, 默认值为 10

请求参数#

响应参数#

参数

是否必选

参数类型

描述

code

int

返回码,0 表示成功,非 0 表示失败。

message

String

错误信息。

result

QueryResult object

查询结果。


QueryResult 类型参数

参数

是否必选

参数类型

描述

count

int

符合查询条件的资源池数。

pools

Array of PoolInfo objects

pool 信息列表。


PoolInfo 类型参数

参数

是否必选

参数类型

描述

id

String

pool 池 ID。

group

String

所属组。

reuse

bool

pool 池是否复用。当 pod 被函数实例使用并独占时,如果 reuse 为 false,池子会立即补充新的 pod,否则需要等到实例 pod 被销毁时,才会补充新的 pod。

status

int

资源池状态。
取值: 0(待创建)、1(创建中)、2(待更新)、3(更新中)、4(运行中)、5(创建失败)、6(待删除)。

msg

String

资源池状态信息。

ready_count

int

running 状态的 pod 数量。

size

int

pool 池子大小。

max_size

int

pool 池最大副本数。

image

String

runtime-manager 组件镜像 tag。

init_image

String

function-agent-init 组件镜像 tag。

labels

Map[String,String]

自定义 pool 池标签。

environment

Map[String,String]

自定义 runtime-manager 容器环境变量。

volumes

String

pool 池需要声明的 volume 卷,支持 HostPath 及 PVC。

volume_mounts

String

pool 池需要声明的 volumeMount 卷挂载。

resources

ResourceRequirement object

pool 池使用资源声明。

affinities

String

pool 池亲和声明。

node_selector

Map[String,String]

节点标签匹配,pool 池将选择特定节点调度。

runtime_class_name

String

容器运行时名称。

tolerations

String

pool 池可以容忍的污点。

horizontal_pod_autoscaler_spec

String

pool 池配置 HPA 声明。

topology_spread_constraints

String

pool 池配置拓扑分布约束。

idle_recycle_time

IdleRecyclePolicy object

配置的自动扩缩 pod 空闲回收时间。


IdleRecyclePolicy 类型参数

参数

是否必选

参数类型

描述

reserved

int

预留 pod 空闲回收时间。单位为秒。-1 表示永不回收,0 表示未配置空闲回收。

scaled

int

弹性 pod 空闲回收时间。单位为秒。-1 表示永不回收,0 表示未配置空闲回收。


ResourceRequirement 类型参数

参数

是否必选

参数类型

描述

requests

Map[String,String]

Pod request 资源定义。cpu 单位 m,表示毫核;mem 单位 Mi 或 Gi。

limits

Map[String,String]

Pod limit 资源定义。cpu 单位 m,表示毫核;mem 单位 Mi 或 Gi。

请求示例#

GET {meta service endpoint}/serverless/v1/podpools?id=pool1&group=rg1

响应示例#

状态码:200

创建查询成功。

{
    "code": 0,
    "message": "",
    "result": {
        "count": 1,
        "pools": [
            {
                "id": "pool1",
                "group": "rg1",
                "size": 1,
                "max_size": 3,
                "ready_count": 1,
                "status": 4,
                "msg": "Running",
                "image": "cd-docker-hub.szxy5.artifactory.cd-cloud-artifact.tools.xxx.com/yuanrong_euleros_x86/runtime-manager:201.2.0.B992.20240301163827-zyw-1",
                "init_image": "",
                "reuse": true,
                "labels": null,
                "environment": null,
                "resources": {
                    "requests": {
                        "cpu": "600m",
                        "memory": "512Mi"
                    },
                    "limits": {
                        "cpu": "600m",
                        "memory": "512Mi"
                    }
                },
                "volumes": "",
                "volume_mounts": "",
                "pod_anti_affinities": "",
                "horizontal_pod_autoscaler_spec": "",
                "topology_spread_constraints": "",
                "idle_recycle_time": {
                    "reserved": 80,
                    "scaled": 20
                }
            }
        ]
    }
}

错误码#

请参见错误码