---
title: "获取Service列表"
method: GET
path: "/k8s/cluster/{id}/namespaces/{namespaceName}/services"
tags: ["K8s Service管理"]
---

# 获取Service列表

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

获取指定命名空间的Service列表

## Path parameters

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

## Headers

- `Authorization` string, required

## Response `200`

OK

- object
  - `code` integer — 状态码
  - `data` object — 返回的数据
    - `services` ModelK8sService[]
      - `clusterIP` string — 集群IP
      - `createdAt` string — 创建时间
      - `endpoints` ModelServiceEndpoint[] — 端点信息
        - `hostname` string — 主机名
        - `ip` string — 端点IP
        - `nodeName` string — 节点名称
        - `ports` ModelEndpointPort[] — 端口信息
          - `name` string — 端口名称
          - `port` integer — 端口号
          - `protocol` string — 协议
        - `ready` boolean — 就绪状态
      - `externalIPs` string[] — 外部IP列表
      - `labels` object — 标签
      - `name` string — 服务名称
      - `namespace` string — 命名空间
      - `ports` ModelServicePort[] — 端口配置
        - `name` string — 端口名称
        - `nodePort` integer — 节点端口(NodePort类型时使用)
        - `port` integer — 服务端口
        - `protocol` string — 协议 TCP/UDP
        - `targetPort` string — 目标端口
      - `selector` object — 选择器
      - `status` string — 状态
      - `type` string — 服务类型 ClusterIP/NodePort/LoadBalancer/ExternalName
    - `total` integer
  - `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)
