---
title: "获取工作负载列表"
method: GET
path: "/k8s/cluster/{id}/namespaces/{namespaceName}/workloads"
tags: ["K8s工作负载管理"]
---

# 获取工作负载列表

`GET /k8s/cluster/{id}/namespaces/{namespaceName}/workloads`

获取指定命名空间的工作负载列表

## Path parameters

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

## Query parameters

- `type` 'deployment' | 'statefulset' | 'daemonset' | 'job' | 'cronjob' | 'all'

## Headers

- `Authorization` string, required

## Response `200`

OK

- object
  - `code` integer — 状态码
  - `data` object — 返回的数据
    - `total` integer
    - `workloads` ModelK8sWorkload[]
      - `createdAt` string — 创建时间
      - `images` string[] — 镜像列表
      - `labels` object — 标签
      - `name` string — 名称
      - `namespace` string — 命名空间
      - `readyReplicas` integer — 就绪副本数
      - `replicas` integer — 副本数
      - `resources` ModelWorkloadResources
        - `limits` ModelResourceSpec
          - `cpu` string — CPU
          - `memory` string — 内存
        - `requests` ModelResourceSpec
          - `cpu` string — CPU
          - `memory` string — 内存
      - `status` string — 状态
      - `type` 'Deployment' | 'StatefulSet' | 'DaemonSet' | 'Job' | 'CronJob' | 'Pod'
      - `updatedAt` 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)
