---
title: "创建应用"
method: POST
path: "/v2/tenants/{tenant_name}/services"
tags: ["v2"]
---

# 创建应用

`POST /v2/tenants/{tenant_name}/services`

## Request

- The document declares no server URL.
- Auth: none declared

create service

## Path parameters

- `tenant_name` string, required

## Request body

- object
  - `category` string: 服务分类：application,cache,store in: body
  - `code_from` string: 代码来源:gitlab,github in: body
  - `comment` string: 服务描述 in: body
  - `container_cmd` string: 容器启动命令 in: body
  - `container_cpu` integer: 容器CPU权重 in: body
  - `container_env` string: 容器环境变量 in: body
  - `container_memory` integer: 容器最大内存 in: body
  - `depend_ids` TenantServiceRelation[]: 依赖id, 格式: []struct TenantServiceRelation in: body
    - `CreatedAt` unknown
    - `ID` integer
    - `dep_order` integer
    - `dep_service_type` string
    - `depend_service_id` string
    - `service_id` string
    - `tenant_id` string
  - `deploy_version` string: 部署版本 in: body
  - `envs_info` TenantServiceEnvVar[]: 环境变量信息, 格式: []struct TenantServiceEnvVar in: body
    - `CreatedAt` unknown
    - `ID` integer
    - `attr_name` string
    - `attr_value` string
    - `container_port` integer
    - `is_change` boolean
    - `name` string
    - `scope` string
    - `service_id` string
    - `tenant_id` string
  - `event_id` string: 最新操作ID in: body
  - `extend_method` string: 扩容方式；0:无状态；1:有状态；2:分区 in: body
  - `host_path` string: 宿主机目录 in: body
  - `image_name` string: 镜像名称 in: body
  - `namespace` string: 镜像来源 in: body
  - `node_label` string: 节点标签,格式: v1,v2 in: body
  - `operator` string: 操作人 in: body
  - `port_type` string: 端口类型，one_outer;dif_protocol;multi_outer in: body
  - `ports_info` TenantServicesPort[]: 端口信息, 格式: []struct TenantServicesPort in: body
    - `ID` integer
    - `container_port` integer
    - `is_inner_service` boolean
    - `is_outer_service` boolean
    - `mapping_port` integer
    - `port_alias` string
    - `protocol` string
    - `service_id` string
    - `tenant_id` string
  - `replicas` integer: 节点数 in: body
  - `service_alias` string, required: 服务别名 in: body
  - `service_id` string: 应用id in: body
  - `service_key` string: 服务key in: body
  - `service_label` string: 应用标签,value in: body
  - `service_origin` string: 服务创建类型cloud云市服务,assistant云帮服务 in: body
  - `service_type` string: 服务类型 in: body
  - `service_version` string: 服务版本 in: body
  - `tenant_id` string: 租户id in: body
  - `update_time` unknown
  - `volume_mount_path` string: 容器挂载目录 in: body
  - `volume_path` string: 卷名字 in: body
  - `volume_type` string: 共享类型shared、exclusive in: body
  - `volumes_info` TenantServiceVolume[]: 持久化目录信息, 格式: []struct TenantServiceVolume in: body
    - `CreatedAt` unknown
    - `ID` integer
    - `category` string: 服务类型
    - `host_path` string: 主机地址
    - `is_read_only` boolean: 是否只读
    - `service_id` string
    - `volume_name` string: 存储名称
    - `volume_path` string: 挂载地址
    - `volume_type` string: 存储类型（share,local,tmpfs）

## Response `default`

统一返回格式

- CommandResponse (unresolved $ref)

---

[API](https://skmtc.dev/goodrain/apis/goodrain-cmd-api.md) - [All operations](https://skmtc.dev/goodrain/apis/goodrain-cmd-api/llms.txt) - [OpenAPI document](https://skmtc.dev/goodrain/apis/goodrain-cmd-api/revisions/8c773e222448?raw)
