---
title: "更新工作负载的YAML配置"
method: PUT
path: "/k8s/cluster/{id}/namespaces/{namespaceName}/workloads/yaml"
tags: ["工作负载YAML管理"]
---

# 更新工作负载的YAML配置

`PUT /k8s/cluster/{id}/namespaces/{namespaceName}/workloads/yaml`

通过YAML内容更新指定的工作负载配置，支持deployment,statefulset,daemonset,job,cronjob

## Path parameters

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

## Headers

- `Authorization` string, required

## Request body

- ModelUpdateWorkloadYAMLRequest
  - `dryRun` boolean — 是否只进行校验不实际更新
  - `force` boolean — 是否强制更新
  - `validateOnly` boolean — 是否只校验YAML格式
  - `workloadName` string, required — 工作负载名称
  - `workloadType` string, required — 工作负载类型: deployment,statefulset,daemonset,job,cronjob
  - `yamlContent` string, required — YAML内容

## Response `200`

OK

- object
  - `code` integer — 状态码
  - `data` object — 返回的数据
    - `appliedAt` string — 应用时间
    - `changes` string[] — 变更说明
    - `message` string — 响应消息
    - `namespace` string — 命名空间
    - `success` boolean — 是否更新成功
    - `updateStrategy` string — 更新策略 (patch/update/rolling)
    - `validationResult` ModelValidateYAMLResponse
      - `errors` string[] — 错误列表
      - `parsedObject` object — 解析后的对象
      - `suggestions` string[] — 建议列表
      - `valid` boolean — 是否有效
      - `warnings` string[] — 警告列表
    - `warnings` string[] — 警告信息
    - `workloadName` string — 工作负载名称
    - `workloadType` string — 工作负载类型
  - `message` string — 提示信息

## Other responses

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

---

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