From 3bcc903271733b9935f1e0afd12037608a80cc6d Mon Sep 17 00:00:00 2001 From: windsonsea Date: Sat, 12 Oct 2024 15:58:38 +0800 Subject: [PATCH] [zh] update service-resources/service-v1.md --- .../service-resources/service-v1.md | 199 +++++++++--------- 1 file changed, 103 insertions(+), 96 deletions(-) diff --git a/content/zh-cn/docs/reference/kubernetes-api/service-resources/service-v1.md b/content/zh-cn/docs/reference/kubernetes-api/service-resources/service-v1.md index 6d66ec406d..2534299ad4 100644 --- a/content/zh-cn/docs/reference/kubernetes-api/service-resources/service-v1.md +++ b/content/zh-cn/docs/reference/kubernetes-api/service-resources/service-v1.md @@ -8,7 +8,6 @@ description: "Service 是软件服务(例如 mysql)的命名抽象,包含 title: Service weight: 1 --- - - Service 是软件服务(例如 mysql)的命名抽象,包含代理要侦听的本地端口(例如 3306)和一个选择算符, 选择算符用来确定哪些 Pod 将响应通过代理发送的请求。 @@ -45,8 +44,8 @@ Service 是软件服务(例如 mysql)的命名抽象,包含代理要侦听 Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata --> - 标准的对象元数据。 - 更多信息: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata + 标准的对象元数据。更多信息: + https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata - **spec** (}}">ServiceSpec) @@ -63,12 +62,12 @@ Service 是软件服务(例如 mysql)的命名抽象,包含代理要侦听 Most recently observed status of the service. Populated by the system. Read-only. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status --> - 最近观察到的 Service 状态。由系统填充。只读。 - 更多信息: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status + 最近观察到的 Service 状态。由系统填充。只读。更多信息: + https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status ## ServiceSpec {#ServiceSpec} - ServiceSpec 描述用户在服务上创建的属性。 @@ -77,18 +76,18 @@ ServiceSpec 描述用户在服务上创建的属性。 - **selector** (map[string]string) - 将 Service 流量路由到具有与此 selector 匹配的标签键值对的 Pod。 如果为空或不存在,则假定该服务有一个外部进程管理其端点,Kubernetes 不会修改该端点。 - 仅适用于 ClusterIP、NodePort 和 LoadBalancer 类型。如果类型为 ExternalName,则忽略。 - 更多信息: https://kubernetes.io/docs/concepts/services-networking/service/ + 仅适用于 ClusterIP、NodePort 和 LoadBalancer 类型。如果类型为 ExternalName,则忽略。更多信息: + https://kubernetes.io/zh-cn/docs/concepts/services-networking/service/ - **ports** ([]ServicePort) - - **Patch strategy:基于键 `type` 合并** + **补丁策略:基于键 `type` 合并** **Map:合并时将保留 type 键的唯一值** - 此 Service 公开的端口列表。 - 更多信息: https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies + 此 Service 公开的端口列表。更多信息: + https://kubernetes.io/zh-cn/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies **ServicePort 包含有关 ServicePort 的信息。** - @@ -153,7 +152,7 @@ ServiceSpec 描述用户在服务上创建的属性。 - **ports.name** (string) - @@ -164,7 +163,7 @@ ServiceSpec 描述用户在服务上创建的属性。 - **ports.nodePort** (int32) - @@ -172,8 +171,8 @@ ServiceSpec 描述用户在服务上创建的属性。 通常由系统分配。如果指定了一个在范围内且未使用的值,则将使用该值,否则操作将失败。 如果在创建的 Service 需要该端口时未指定该字段,则会分配端口。 如果在创建不需要该端口的 Service时指定了该字段,则会创建失败。 - 当更新 Service 时,如果不再需要此字段(例如,将类型从 NodePort 更改为 ClusterIP),这个字段将被擦除。 - 更多信息: https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport + 当更新 Service 时,如果不再需要此字段(例如,将类型从 NodePort 更改为 ClusterIP),这个字段将被擦除。更多信息: + https://kubernetes.io/zh-cn/docs/concepts/services-networking/service/#type-nodeport - **ports.appProtocol** (string) @@ -182,6 +181,7 @@ ServiceSpec 描述用户在服务上创建的属性。 richer behavior for protocols that they understand. This field follows standard Kubernetes label syntax. Valid values are either: --> + 此端口的应用协议,用作实现的提示,为他们理解的协议提供更丰富的行为。此字段遵循标准 Kubernetes 标签语法,有效值包括: @@ -208,7 +208,7 @@ ServiceSpec 描述用户在服务上创建的属性。 - **type** (string) - @@ -219,18 +219,18 @@ ServiceSpec 描述用户在服务上创建的属性。 如果 clusterIP 为 `None`,则不分配虚拟 IP,并且 Endpoints 作为一组端点而不是虚拟 IP 发布。 `NodePort` 建立在 ClusterIP 之上,并在每个节点上分配一个端口,该端口路由到与 clusterIP 相同的 Endpoints。 `LoadBalancer` 基于 NodePort 构建并创建一个外部负载均衡器(如果当前云支持),该负载均衡器路由到与 clusterIP 相同的 Endpoints。 - `externalName` 将此 Service 别名为指定的 externalName。其他几个字段不适用于 ExternalName Service。 - 更多信息: https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types + `externalName` 将此 Service 别名为指定的 externalName。其他几个字段不适用于 ExternalName Service。更多信息: + https://kubernetes.io/zh-cn/docs/concepts/services-networking/service/#publishing-services-service-types - **ipFamilies** ([]string) - **原子: 将在合并期间被替换** - @@ -252,7 +252,7 @@ ServiceSpec 描述用户在服务上创建的属性。 - **ipFamilyPolicy** (string) - @@ -266,7 +266,7 @@ ServiceSpec 描述用户在服务上创建的属性。 - **clusterIP** (string) - @@ -278,17 +278,18 @@ ServiceSpec 描述用户在服务上创建的属性。 clusterIP 为 “None” 时会生成“无头服务”(无虚拟 IP),这在首选直接 Endpoint 连接且不需要代理时很有用。 仅适用于 ClusterIP、NodePort、和 LoadBalancer 类型的服务。 如果在创建 ExternalName 类型的 Service 时指定了 clusterIP,则创建将失败。 - 更新 Service type 为 ExternalName 时,clusterIP 会被移除。 - 更多信息: https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies + 更新 Service type 为 ExternalName 时,clusterIP 会被移除。更多信息: + https://kubernetes.io/zh-cn/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies - **clusterIPs** ([]string) - + **原子: 将在合并期间被替换** - @@ -303,18 +304,18 @@ ServiceSpec 描述用户在服务上创建的属性。 更新 Service type 为 ExternalName 时,该字段将被移除。如果未指定此字段,则将从 clusterIP 字段初始化。 如果指定 clusterIPs,客户端必须确保 clusterIPs[0] 和 clusterIP 一致。 - clusterIPs 最多可包含两个条目(双栈系列,按任意顺序)。 这些 IP 必须与 ipFamilies 的值相对应。 - clusterIP 和 ipFamilies 都由 ipFamilyPolicy 管理。 - 更多信息: https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies + clusterIP 和 ipFamilies 都由 ipFamilyPolicy 管理。更多信息: + https://kubernetes.io/zh-cn/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies - **externalIPs** ([]string) - 支持 “ClientIP” 和 “None”。用于维护会话亲和性。 - 启用基于客户端 IP 的会话亲和性。必须是 ClientIP 或 None。默认为 None。 - 更多信息: https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies + 启用基于客户端 IP 的会话亲和性。必须是 ClientIP 或 None。默认为 None。更多信息: + https://kubernetes.io/zh-cn/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies - **loadBalancerIP** (string) - + 仅适用于服务类型:LoadBalancer。此功能取决于底层云提供商是否支持负载均衡器。 如果云提供商不支持该功能,该字段将被忽略。 已弃用:该字段信息不足,且其含义因实现而异。此字段是不可移植的,并且可能不支持双栈。。 @@ -348,7 +350,7 @@ ServiceSpec 描述用户在服务上创建的属性。 - **loadBalancerSourceRanges** ([]string) - @@ -377,7 +379,7 @@ ServiceSpec 描述用户在服务上创建的属性。 - **externalName** (string) - @@ -387,9 +389,10 @@ ServiceSpec 描述用户在服务上创建的属性。 - **externalTrafficPolicy** (string) - + externalTrafficPolicy 描述了节点如何分发它们在 Service 的“外部访问”地址 (NodePort、ExternalIP 和 LoadBalancer IP)接收到的服务流量。 如果设置为 “Local”,代理将以一种假设外部负载均衡器将负责在节点之间服务流量负载均衡, @@ -401,18 +404,20 @@ ServiceSpec 描述用户在服务上创建的属性。 - **internalTrafficPolicy** (string) - - InternalTrafficPolicy 描述节点如何分发它们在 ClusterIP 上接收到的服务流量。 + + internalTrafficPolicy 描述节点如何分发它们在 ClusterIP 上接收到的服务流量。 如果设置为 “Local”,代理将假定 Pod 只想与在同一节点上的服务端点通信,如果没有本地端点,它将丢弃流量。 “Cluster” 默认将流量路由到所有端点(可能会根据拓扑和其他特性进行修改)。 - **healthCheckNodePort** (int32) - + healthCheckNodePort 指定 Service 的健康检查节点端口。 仅适用于 type 为 LoadBalancer 且 externalTrafficPolicy 设置为 Local 的情况。 如果为此字段设定了一个值,该值在合法范围内且没有被使用,则使用所指定的值。 @@ -423,7 +428,7 @@ ServiceSpec 描述用户在服务上创建的属性。 - **publishNotReadyAddresses** (boolean) - @@ -436,12 +441,13 @@ ServiceSpec 描述用户在服务上创建的属性。 - **sessionAffinityConfig** (SessionAffinityConfig) - + sessionAffinityConfig 包含会话亲和性的配置。 @@ -449,7 +455,7 @@ ServiceSpec 描述用户在服务上创建的属性。 - **sessionAffinityConfig.clientIP** (ClientIPConfig) - @@ -472,7 +478,7 @@ ServiceSpec 描述用户在服务上创建的属性。 - **allocateLoadBalancerNodePorts** (boolean) - @@ -495,7 +501,7 @@ ServiceSpec 描述用户在服务上创建的属性。 ## ServiceStatus {#ServiceStatus} - ServiceStatus 表示 Service 的当前状态。 @@ -504,7 +510,7 @@ ServiceStatus 表示 Service 的当前状态。 - **conditions** ([]Condition) - - **conditions.message** (string),必需 - message 是人类可读的消息,有关转换的详细信息,可以是空字符串。 - - **conditions.reason** (string),必需 - @@ -569,33 +575,33 @@ ServiceStatus 表示 Service 的当前状态。 特定条件类型的生产者可以定义该字段的预期值和含义,以及这些值是否被视为有保证的 API。 该值应该是 CamelCase 字符串且不能为空。 - - **conditions.status** (string),必需 - condition 的状态,True、False、Unknown 之一。 - - **conditions.type** (string),必需 - - CamelCase 或 foo.example.com/CamelCase 中的条件类型。 + condition 的类型,格式为 CamelCase 或 foo.example.com/CamelCase。 - **conditions.observedGeneration** (int64) - @@ -605,7 +611,7 @@ ServiceStatus 表示 Service 的当前状态。 - **loadBalancer** (LoadBalancerStatus) - @@ -645,7 +651,7 @@ ServiceStatus 表示 Service 的当前状态。 - **loadBalancer.ingress.ip** (string) - @@ -659,6 +665,7 @@ ServiceStatus 表示 Service 的当前状态。 Setting this to "Proxy" indicates that traffic is delivered to the node or pod with the destination set to the node's IP and node port or the pod's IP and port. Service implementations may use this information to adjust traffic routing. --> + ipMode 指定负载平衡器 IP 的行为方式,并且只能在设置了 ip 字段时指定。 将其设置为 `VIP` 表示流量将传送到节点,并将目标设置为负载均衡器的 IP 和端口。 将其设置为 `Proxy` 表示将流量传送到节点或 Pod,并将目标设置为节点的 IP 和节点端口或 Pod 的 IP 和端口。 @@ -666,46 +673,47 @@ ServiceStatus 表示 Service 的当前状态。 - **loadBalancer.ingress.ports** ([]PortStatus) - - **Atomic:将在合并期间被替换** + **原子:将在合并期间被替换** - + ports 是 Service 的端口列表。如果设置了此字段,Service 中定义的每个端口都应该在此列表中。 - - **loadBalancer.ingress.ports.port** (int32),必需 - port 是所记录的服务端口状态的端口号。 - - **loadBalancer.ingress.ports.protocol** (string),必需 - - protocol 是所记录的服务端口状态的协议。支持的值为:`TCP`、`UDP`、`SCTP`。 + protocol 是所记录的服务端口状态的协议。支持的值为:“TCP”、“UDP”、“SCTP”。 - **loadBalancer.ingress.ports.error** (string) - @@ -733,14 +741,14 @@ ServiceList 包含一个 Service 列表。 - **metadata** (}}">ListMeta) - 标准的列表元数据。更多信息: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds - @@ -762,7 +770,6 @@ ServiceList 包含一个 Service 列表。 #### HTTP Request --> - ### `get` 读取指定的 Service #### HTTP 请求 @@ -807,7 +814,7 @@ GET /api/v1/namespaces/{namespace}/services/{name} 401: Unauthorized -