--- api_metadata: apiVersion: "v1" import: "k8s.io/api/core/v1" kind: "Endpoints" content_type: "api_reference" description: "Endpoints 是实现实际服务的端点的集合。" title: "Endpoints" weight: 2 --- `apiVersion: v1` `import "k8s.io/api/core/v1"` ## Endpoints {#Endpoints} Endpoints 是实现实际服务的端点的集合。举例: Name: "mysvc", Subsets: [ { Addresses: [{"ip": "10.10.1.1"}, {"ip": "10.10.2.2"}], Ports: [{"name": "a", "port": 8675}, {"name": "b", "port": 309}] }, { Addresses: [{"ip": "10.10.3.3"}], Ports: [{"name": "a", "port": 93}, {"name": "b", "port": 76}] }, ]
- **apiVersion**: v1 - **kind**: Endpoints - **metadata** (}}">ObjectMeta) 标准的对象元数据。更多信息: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata - **subsets** ([]EndpointSubset) 所有端点的集合是所有 subsets 的并集。不同地址会根据其 IP 地址被放入不同子集。 对于具有多个端口的单个地址,如果其中一些端口已就绪,而另一些端口未就绪(因为它们来自不同的容器), 将导致地址显示在不同端口的不同子集中。 任何地址都不可以同时出现在 addresses 和 notReadyAddress 中的相同子集内。 **EndpointSubset 是一组具有公共端口集的地址。扩展的端点集是 addresses 和 ports 的笛卡尔乘积。例如假设:** { Addresses: [{"ip": "10.10.1.1"}, {"ip": "10.10.2.2"}], Ports: [{"name": "a", "port": 8675}, {"name": "b", "port": 309}] } 则最终的端点集可以看作: a: [ 10.10.1.1:8675, 10.10.2.2:8675 ], b: [ 10.10.1.1:309, 10.10.2.2:309 ]* - **subsets.addresses** ([]EndpointAddress) 提供标记为就绪的相关端口的 IP 地址。 这些端点应该被认为是负载均衡器和客户端可以安全使用的。 **EndpointAddress 是描述单个 IP 地址的元组。** - **subsets.addresses.ip** (string), 必需 端点的 IP。不可以是本地回路(127.0.0.0/8)、链路本地(169.254.0.0/16)或链路本地多播(224.0.0.0/24)地址。 IPv6 也被接受,但并非在所有平台上都完全支持。 此外,诸如 kube-proxy 等某些 Kubernetes 组件还没有准备好支持 IPv6。 - **subsets.addresses.hostname** (string) 端点主机名称。 - **subsets.addresses.nodeName** (string) 可选:承载此端点的节点。此字段可用于确定一个节点的本地端点。 - **subsets.addresses.targetRef** (}}">ObjectReference) 对提供端点的对象的引用。 - **subsets.notReadyAddresses** ([]EndpointAddress) 提供相关端口但由于尚未完成启动、最近未通过就绪态检查或最近未通过活跃性检查而被标记为当前未就绪的 IP 地址。 **EndpointAddress 是描述单个 IP 地址的元组。** - **subsets.notReadyAddresses.ip** (string), 必需 端点的 IP。不可以是本地环路(127.0.0.0/8)、链路本地(169.254.0.0/16)或链路本地多播(224.0.0.0/24)地址。 IPv6 也被接受,但并非在所有平台上都完全支持。 此外,诸如 kube-proxy 等某些 Kubernetes 组件还没有准备好支持 IPv6。 - **subsets.notReadyAddresses.hostname** (string) 端点主机名称。 - **subsets.notReadyAddresses.nodeName** (string) 可选:承载此端点的节点。此字段可用于确定节点的本地端点。 - **subsets.notReadyAddresses.targetRef** (}}">ObjectReference) 对提供端点的对象的引用。 - **subsets.ports** ([]EndpointPort) 相关 IP 地址上可用的端口号。 **EndpointAddress 是描述单个 IP 地址的元组。** - **subsets.ports.port** (int32), 必需 端点的端口号。 - **subsets.ports.protocol** (string) 此端口的 IP 协议。必须是 UDP、TCP 或 SCTP。默认值为 TCP。 - **subsets.ports.name** (string) 端口的名称。此字段必须与相应 ServicePort 中的 `name` 字段匹配。必须是 DNS_LABEL。 仅当定义了一个端口时才可选。 - **subsets.ports.appProtocol** (string) 端口的应用程序协议。此字段遵循标准的 Kubernetes 标签语法。 未加前缀的名称保留给 IANA 标准服务名称(遵循 RFC-6335 和 https://www.iana.org/assignments/service-names)。 非标准协议应使用带前缀名称,如 `mycompany.com/my-custom-protocol`。 ## EndpointsList {#EndpointsList} EndpointsList 是端点列表。
- **apiVersion**: v1 - **kind**: EndpointsList - **metadata** (}}">ListMeta) 标准的列表元数据。更多信息: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds - **items** ([]}}">Endpoints), 必需 端点列表。 ## 操作 {#Operations}
### `get` 读取指定的 Endpoints #### HTTP 请求 GET /api/v1/namespaces/{namespace}/endpoints/{name} #### 参数 - **name** (**路径参数**):string,必需 Endpoints 的名称。 - **namespace** (**路径参数**):string,必需 }}">namespace - **pretty** (**查询参数**):string }}">pretty #### 响应 200 (}}">Endpoints): OK 401: Unauthorized ### `list` 列出或监测 Endpoints 类型的对象 #### HTTP 请求 GET /api/v1/namespaces/{namespace}/endpoints #### 参数 - **namespace** (**路径参数**):string,必需 }}">namespace - **allowWatchBookmarks** (**查询参数**):boolean }}">allowWatchBookmarks - **continue** (**查询参数**):string }}">continue - **fieldSelector** (**查询参数**):string }}">fieldSelector - **labelSelector** (**查询参数**):string }}">labelSelector - **limit** (**查询参数**):integer }}">limit - **pretty** (**查询参数**):string }}">pretty - **resourceVersion** (**查询参数**):string }}">resourceVersion - **resourceVersionMatch** (**查询参数**):string }}">resourceVersionMatch - **timeoutSeconds** (**查询参数**):integer }}">timeoutSeconds - **watch** (**查询参数**):boolean }}">watch #### 响应 200 (}}">EndpointsList): OK 401: Unauthorized ### `list` 列出或监测 Endpoints 类型的对象 #### HTTP 请求 GET /api/v1/endpoints #### 参数 - **allowWatchBookmarks** (**查询参数**):boolean }}">allowWatchBookmarks - **continue** (**查询参数**):string }}">continue - **fieldSelector** (**查询参数**):string }}">fieldSelector - **labelSelector** (**查询参数**):string }}">labelSelector - **limit** (**查询参数**):integer }}">limit - **pretty** (**查询参数**):string }}">pretty - **resourceVersion** (**查询参数**):string }}">resourceVersion - **resourceVersionMatch** (**查询参数**):string }}">resourceVersionMatch - **timeoutSeconds** (**查询参数**):integer }}">timeoutSeconds - **watch** (**查询参数**):boolean }}">watch #### 响应 200 (}}">EndpointsList): OK 401: Unauthorized ### `create` 创建 Endpoints #### HTTP 请求 POST /api/v1/namespaces/{namespace}/endpoints #### 参数 - **namespace** (**路径参数**):string,必需 }}">namespace - **body**: }}">Endpoints, 必需 - **dryRun** (**查询参数**):string }}">dryRun - **fieldManager** (**查询参数**):string }}">fieldManager - **fieldValidation** (**查询参数**):string }}">fieldValidation - **pretty** (**查询参数**):string }}">pretty #### 响应 200 (}}">Endpoints): OK 201 (}}">Endpoints): Created 202 (}}">Endpoints): Accepted 401: Unauthorized ### `update` 替换指定的 Endpoints #### HTTP 请求 PUT /api/v1/namespaces/{namespace}/endpoints/{name} #### 参数 - **name** (**路径参数**):string,必需 Endpoints 名称 - **namespace** (**路径参数**):string,必需 }}">namespace - **body**: }}">Endpoints, required - **dryRun** (**查询参数**):string }}">dryRun - **fieldManager** (**查询参数**):string }}">fieldManager - **fieldValidation** (**查询参数**):string }}">fieldValidation - **pretty** (**查询参数**):string }}">pretty #### 响应 200 (}}">Endpoints): OK 201 (}}">Endpoints): Created 401: Unauthorized ### `patch` 部分更新指定的 Endpoints #### HTTP 请求 PATCH /api/v1/namespaces/{namespace}/endpoints/{name} #### 参数 - **name** (**路径参数**):string,必需 Endpoints名称 - **namespace** (**路径参数**):string,必需 }}">namespace - **body**: }}">Patch, 必需 - **dryRun** (**查询参数**):string }}">dryRun - **fieldManager** (**查询参数**):string }}">fieldManager - **fieldValidation** (**查询参数**):string }}">fieldValidation - **force** (**查询参数**):boolean }}">force - **pretty** (**查询参数**):string }}">pretty #### 响应 200 (}}">Endpoints): OK 201 (}}">Endpoints): Created 401: Unauthorized ### `delete` 删除 Endpoints #### HTTP 请求 DELETE /api/v1/namespaces/{namespace}/endpoints/{name} #### 参数 - **name** (**路径参数**):string,必需 Endpoints 名称 - **namespace** (**路径参数**):string,必需 }}">namespace - **body**: }}">DeleteOptions - **dryRun** (**查询参数**):string }}">dryRun - **gracePeriodSeconds** (**查询参数**):integer }}">gracePeriodSeconds - **pretty** (**查询参数**):string }}">pretty - **propagationPolicy** (**查询参数**):string }}">propagationPolicy #### 响应 200 (}}">Status): OK 202 (}}">Status): Accepted 401: Unauthorized ### `deletecollection` 删除 Endpoints 组 #### HTTP 请求 DELETE /api/v1/namespaces/{namespace}/endpoints #### 参数 - **namespace** (**路径参数**):string,必需 }}">namespace - **body**: }}">DeleteOptions - **continue** (**查询参数**):string }}">continue - **dryRun** (**查询参数**):string }}">dryRun - **fieldSelector** (**查询参数**):string }}">fieldSelector - **gracePeriodSeconds** (**查询参数**):integer }}">gracePeriodSeconds - **labelSelector** (**查询参数**):string }}">labelSelector - **limit** (**查询参数**):integer }}">limit - **pretty** (**查询参数**):string }}">pretty - **propagationPolicy** (**查询参数**):string }}">propagationPolicy - **resourceVersion** (**查询参数**):string }}">resourceVersion - **resourceVersionMatch** (**查询参数**):string }}">resourceVersionMatch - **timeoutSeconds** (**查询参数**):integer }}">timeoutSeconds #### 响应 200 (}}">Status): OK 401: Unauthorized