Pod 开放端口列表
查询分布式训练任务下指定 Pod(容器组)当前已开放的端口,返回结果按来源分为系统端口与自定义端口两类,并给出每个端口对应的外部访问 IP 与外部端口,便于从集群外部访问 Pod 内服务。端口的开放与关闭分别使用 Pod 开放端口 和 Pod 关闭端口。
GET
https://api.alayanew.com/v1/training/instance/{id}/{podName}/open-port/list鉴权(Authorizations)
bearerAuthAuthorizationString必填用户可通过已获取的 Open API Key 做验证。例如:Bearer [YOUR_API_KEY]。
Path Parameters
idString必填训练任务 ID(来自任务列表的 id)。例如:1234567890。
podNameString必填Pod(容器组)名称,标识任务下具体的某个容器组。例如:llama3-8b-sft-worker-0。
Response
application/json · 200statusInteger业务状态码,200 表示成功。
messageString接口响应信息。例如:"OK"。
dataObject开放端口响应对象,按来源分为系统端口与自定义端口两组。
显示 properties
portsArray系统端口列表,由平台自动开放,此类端口没有协议字段。
显示 properties
protocolString协议,取值 http 或 https。系统端口通常不返回此字段。
portInteger容器内端口号。例如:80。
externalHostString外部访问 IP,用于从集群外部访问该端口。例如:"192.168.1.1"。
externalPortInteger外部访问端口,与 externalHost 组合后即为对外访问地址。例如:31443。
customPortsArray自定义端口列表,由用户通过 Pod 开放端口 手动开放。
显示 properties
protocolString协议,取值 http 或 https。例如:"http"。
portInteger容器内端口号。例如:7778。
externalHostString外部访问 IP。例如:"192.168.1.1"。
externalPortInteger外部访问端口。例如:31443。
curl -X 'GET' \
'https://api.alayanew.com/v1/training/instance/1234567890/llama3-8b-sft-worker-0/open-port/list' \
-H 'accept: application/json' \
-H 'Authorization: Bearer [YOUR_API_KEY]'import requests
task_id = "1234567890"
pod_name = "llama3-8b-sft-worker-0"
url = f"https://api.alayanew.com/v1/training/instance/{task_id}/{pod_name}/open-port/list"
headers = {
"accept": "application/json",
"Authorization": "Bearer [YOUR_API_KEY]"
}
response = requests.get(url, headers=headers)
print(response.json())const taskId = '1234567890';
const podName = 'llama3-8b-sft-worker-0';
fetch(`https://api.alayanew.com/v1/training/instance/${taskId}/${podName}/open-port/list`, {
method: 'GET',
headers: {
'accept': 'application/json',
'Authorization': 'Bearer [YOUR_API_KEY]'
}
})
.then(res => res.json())
.then(console.log)
.catch(console.error);{
"status": 200,
"message": "OK",
"data": {
"ports": [
{
"protocol": "http/https",
"port": 80,
"externalHost": "192.168.1.1",
"externalPort": 31443
}
],
"customPorts": [
{
"protocol": "http/https",
"port": 80,
"externalHost": "192.168.1.1",
"externalPort": 31443
}
]
}
}{
"status": 403,
"message": "Forbidden",
"data": {}
}{
"status": 500,
"message": "Internal Server Error",
"data": {}
}最后更新于
