---
title: "通过YAML创建Pod"
method: POST
path: "/k8s/cluster/{id}/namespaces/{namespaceName}/pods/yaml"
tags: ["Pod管理"]
---

# 通过YAML创建Pod

`POST /k8s/cluster/{id}/namespaces/{namespaceName}/pods/yaml`

通过提供的YAML内容创建Pod，支持校验模式和DryRun模式

## Path parameters

- `id` integer, required
- `namespaceName` string, required

## Headers

- `Authorization` string, required

## Request body

- ModelCreatePodFromYAMLRequest
  - `dryRun` boolean — 是否只进行校验不实际创建
  - `validateOnly` boolean — 是否只校验YAML格式
  - `yamlContent` string, required — YAML内容

## Response `200`

OK

- object
  - `code` integer — 状态码
  - `data` object — 返回的数据
    - `message` string — 响应消息
    - `namespace` string — Pod所在的命名空间
    - `parsedObject` object — 解析的对象信息
    - `podName` string — 创建的Pod名称
    - `success` boolean — 是否创建成功
    - `validationResult` ModelValidateYAMLResponse
      - `errors` string[] — 错误列表
      - `parsedObject` object — 解析后的对象
      - `suggestions` string[] — 建议列表
      - `valid` boolean — 是否有效
      - `warnings` string[] — 警告列表
  - `message` string — 提示信息

## Other responses

- `400` — Bad Request
- `401` — Unauthorized
- `500` — Internal Server Error

---

[API](https://skmtc.net/opsre/apis/devops.md) · [All operations](https://skmtc.net/opsre/apis/devops/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/opsre/devops/revisions/25cac8835c4c/schema)
