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

# 获取Service详情

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

获取指定Service的详细信息

## Path parameters

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

## Headers

- `Authorization` string, required

## Response `200`

OK

- object
  - `code` integer — 状态码
  - `data` object — 返回的数据
    - `clusterIP` string — 集群IP
    - `createdAt` string — 创建时间
    - `endpoints` ModelServiceEndpoint[] — 端点信息
      - `hostname` string — 主机名
      - `ip` string — 端点IP
      - `nodeName` string — 节点名称
      - `ports` ModelEndpointPort[] — 端口信息
        - `name` string — 端口名称
        - `port` integer — 端口号
        - `protocol` string — 协议
      - `ready` boolean — 就绪状态
    - `events` ModelK8sEvent[] — 相关事件
      - `count` integer — 发生次数
      - `firstTime` string — 首次时间
      - `lastTime` string — 最后时间
      - `message` string — 消息
      - `reason` string — 原因
      - `source` string — 事件源
      - `type` string — 事件类型
    - `externalIPs` string[] — 外部IP列表
    - `labels` object — 标签
    - `name` string — 服务名称
    - `namespace` string — 命名空间
    - `pods` ModelK8sPodInfo[] — 关联的Pod列表
      - `containers` ModelContainerInfo[] — 容器信息
        - `env` ModelEnvVar[] — 环境变量
          - `name` string — 变量名
          - `value` string — 变量值
        - `image` string — 镜像
        - `name` string — 容器名称
        - `ports` ModelContainerPort[] — 端口配置
          - `containerPort` integer — 容器端口
          - `name` string — 端口名称
          - `protocol` string — 协议
        - `ready` boolean — 就绪状态
        - `resources` ModelWorkloadResources
          - `limits` ModelResourceSpec
            - `cpu` string — CPU
            - `memory` string — 内存
          - `requests` ModelResourceSpec
            - `cpu` string — CPU
            - `memory` string — 内存
        - `restartCount` integer — 重启次数
        - `state` string — 状态
      - `createdAt` string — 创建时间
      - `hostIP` string — 主机IP
      - `labels` object — 标签
      - `name` string — 实例名称
      - `nodeName` string — 节点名称
      - `phase` string — 阶段
      - `podIP` string — Pod IP
      - `resources` ModelWorkloadResources
        - `limits` ModelResourceSpec
          - `cpu` string — CPU
          - `memory` string — 内存
        - `requests` ModelResourceSpec
          - `cpu` string — CPU
          - `memory` string — 内存
      - `restartCount` integer — 重启次数
      - `runningTime` string — 运行时间
      - `status` string — 状态
    - `ports` ModelServicePort[] — 端口配置
      - `name` string — 端口名称
      - `nodePort` integer — 节点端口(NodePort类型时使用)
      - `port` integer — 服务端口
      - `protocol` string — 协议 TCP/UDP
      - `targetPort` string — 目标端口
    - `selector` object — 选择器
    - `spec` unknown
    - `status` string — 状态
    - `type` string — 服务类型 ClusterIP/NodePort/LoadBalancer/ExternalName
  - `message` string — 提示信息

## Other responses

- `400` — Bad Request
- `401` — Unauthorized
- `404` — Not Found
- `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)
