Skip to content

Commit 1ef982c

Browse files
committed
[zh-cn] sync1.25 /services-networking/service.md
1 parent bef3a43 commit 1ef982c

File tree

1 file changed

+26
-35
lines changed
  • content/zh-cn/docs/concepts/services-networking

1 file changed

+26
-35
lines changed

content/zh-cn/docs/concepts/services-networking/service.md

Lines changed: 26 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ to, so that the frontend can use the backend part of the workload?
5454
5555
Enter _Services_.
5656
-->
57-
5857
## 动机
5958

6059
创建和销毁 Kubernetes {{< glossary_tooltip term_id="pod" text="Pod" >}} 以匹配集群的期望状态。
@@ -132,7 +131,6 @@ The name of a Service object must be a valid
132131
For example, suppose you have a set of Pods where each listens on TCP port 9376
133132
and contains a label `app=MyApp`:
134133
-->
135-
136134
## 定义 Service
137135

138136
Service 在 Kubernetes 中是一个 REST 对象,和 Pod 类似。
@@ -149,16 +147,16 @@ metadata:
149147
name: my-service
150148
spec:
151149
selector:
152-
app: MyApp
150+
app.kubernetes.io/name: MyApp
153151
ports:
154152
- protocol: TCP
155153
port: 80
156154
targetPort: 9376
157155
```
158156
159157
<!--
160-
This specification creates a new Service object named my-service, which
161-
targets TCP port 9376 on any Pod with the `app=MyApp` label.
158+
This specification creates a new Service object named "my-service", which
159+
targets TCP port 9376 on any Pod with the `app.kubernetes.io/name=MyApp` label.
162160

163161
Kubernetes assigns this Service an IP address (sometimes called the "cluster IP"),
164162
which is used by the Service proxies
@@ -169,7 +167,7 @@ match its selector, and then POSTs any updates to an Endpoint object
169167
also named "my-service".
170168
-->
171169
上述配置创建一个名称为 "my-service" 的 Service 对象,它会将请求代理到使用
172-
TCP 端口 9376,并且具有标签 `"app=MyApp"` 的 Pod 上。
170+
TCP 端口 9376,并且具有标签 `app.kubernetes.io/name=MyApp` 的 Pod 上。
173171

174172
Kubernetes 为该服务分配一个 IP 地址(有时称为 “集群 IP”),该 IP 地址由服务代理使用。
175173
(请参见下面的 [VIP 和 Service 代理](#virtual-ips-and-service-proxies)).
@@ -209,7 +207,7 @@ spec:
209207
ports:
210208
- containerPort: 80
211209
name: http-web-svc
212-
210+
213211
---
214212
apiVersion: v1
215213
kind: Service
@@ -337,8 +335,8 @@ Endpoint IP addresses cannot be the cluster IPs of other Kubernetes Services,
337335
because {{< glossary_tooltip term_id="kube-proxy" >}} doesn't support virtual IPs
338336
as a destination.
339337
-->
340-
端点 IPs _必须不可以_ 是:本地回路(IPv4 的 127.0.0.0/8, IPv6 的 ::1/128)
341-
本地链接(IPv4 的 169.254.0.0/16 和 224.0.0.0/24,IPv6 的 fe80::/64)。
338+
端点 IPs **必须不可以** 是:本地回路(IPv4 的 127.0.0.0/8, IPv6 的 ::1/128)
339+
或本地链接(IPv4 的 169.254.0.0/16 和 224.0.0.0/24,IPv6 的 fe80::/64)。
342340

343341
端点 IP 地址不能是其他 Kubernetes 服务的集群 IP,因为
344342
{{< glossary_tooltip term_id ="kube-proxy">}} 不支持将虚拟 IP 作为目标。
@@ -666,7 +664,7 @@ metadata:
666664
name: my-service
667665
spec:
668666
selector:
669-
app: MyApp
667+
app.kubernetes.io/name: MyApp
670668
ports:
671669
- name: http
672670
protocol: TCP
@@ -1100,7 +1098,7 @@ metadata:
11001098
spec:
11011099
type: NodePort
11021100
selector:
1103-
app: MyApp
1101+
app.kubernetes.io/name: MyApp
11041102
ports:
11051103
# 默认情况下,为了方便起见,`targetPort` 被设置为与 `port` 字段相同的值。
11061104
- port: 80
@@ -1136,7 +1134,7 @@ metadata:
11361134
name: my-service
11371135
spec:
11381136
selector:
1139-
app: MyApp
1137+
app.kubernetes.io/name: MyApp
11401138
ports:
11411139
- protocol: TCP
11421140
port: 80
@@ -1146,7 +1144,7 @@ spec:
11461144
status:
11471145
loadBalancer:
11481146
ingress:
1149-
- ip: 192.0.2.127
1147+
- ip: 192.0.2.127
11501148
```
11511149

11521150
<!--
@@ -2061,22 +2059,22 @@ Kubernetes 通过在为 API 服务器配置的 `service-cluster-ip-range` CIDR
20612059
<!--
20622060
#### IP address ranges for `type: ClusterIP` Services {#service-ip-static-sub-range}
20632061

2064-
{{< feature-state for_k8s_version="v1.24" state="alpha" >}}
2062+
{{< feature-state for_k8s_version="v1.25" state="beta" >}}
20652063
However, there is a problem with this `ClusterIP` allocation strategy, because a user
20662064
can also [choose their own address for the service](#choosing-your-own-ip-address).
20672065
This could result in a conflict if the internal allocator selects the same IP address
20682066
for another Service.
20692067
-->
20702068
#### `type: ClusterIP` 服务的 IP 地址范围 {#service-ip-static-sub-range}
20712069

2072-
{{< feature-state for_k8s_version="v1.24" state="alpha" >}}
2070+
{{< feature-state for_k8s_version="v1.25" state="beta" >}}
20732071
但是,这种 `ClusterIP` 分配策略存在一个问题,因为用户还可以[为服务选择自己的地址](#choosing-your-own-ip-address)。
20742072
如果内部分配器为另一个服务选择相同的 IP 地址,这可能会导致冲突。
20752073

20762074
<!--
2077-
If you enable the `ServiceIPStaticSubrange`
2078-
[feature gate](/docs/reference/command-line-tools-reference/feature-gates/),
2079-
the allocation strategy divides the `ClusterIP` range into two bands, based on
2075+
The `ServiceIPStaticSubrange`
2076+
[feature gate](/docs/reference/command-line-tools-reference/feature-gates/) is enabled by default in v1.25
2077+
and later, using an allocation strategy that divides the `ClusterIP` range into two bands, based on
20802078
the size of the configured `service-cluster-ip-range` by using the following formula
20812079
`min(max(16, cidrSize / 16), 256)`, described as _never less than 16 or more than 256,
20822080
with a graduated step function between them_. Dynamic IP allocations will be preferentially
@@ -2085,8 +2083,8 @@ assigned from the lower band.
20852083
This allows users to use the lower band of the `service-cluster-ip-range` for their
20862084
Services with static IPs assigned with a very low risk of running into conflicts.
20872085
-->
2088-
如果启用 `ServiceIPStaticSubrange`[特性门控](/zh-cn/docs/reference/command-line-tools-reference/feature-gates/)
2089-
分配策略根据配置的 `service-cluster-ip-range` 的大小,使用以下公式
2086+
`ServiceIPStaticSubrange` [特性门控](/zh-cn/docs/reference/command-line-tools-reference/feature-gates/)
2087+
v1.25 及后续版本中默认启用,其分配策略根据配置的 `service-cluster-ip-range` 的大小,使用以下公式
20902088
`min(max(16, cidrSize / 16), 256)` 进行划分,该公式可描述为
20912089
“在不小于 16 且不大于 256 之间有一个步进量(Graduated Step)”,将
20922090
`ClusterIP` 范围分成两段。动态 IP 分配将优先从上半段地址中选择,
@@ -2225,11 +2223,8 @@ depends on the cloud provider offering this facility.
22252223
你可以将 UDP 用于大多数服务。 对于 type=LoadBalancer 服务,对 UDP 的支持取决于提供此功能的云提供商。
22262224

22272225
<!--
2228-
22292226
### SCTP
22302227

2231-
{{< feature-state for_k8s_version="v1.20" state="stable" >}}
2232-
22332228
When using a network plugin that supports SCTP traffic, you can use SCTP for
22342229
most Services. For type=LoadBalancer Services, SCTP support depends on the cloud
22352230
provider offering this facility. (Most do not).
@@ -2250,42 +2245,38 @@ provider offering this facility. (Most do not).
22502245

22512246
##### 支持多宿主 SCTP 关联 {#caveat-sctp-multihomed}
22522247

2253-
<!--
22542248
{{< warning >}}
2249+
<!--
22552250
The support of multihomed SCTP associations requires that the CNI plugin can support the assignment of multiple interfaces and IP addresses to a Pod.
22562251

22572252
NAT for multihomed SCTP associations requires special logic in the corresponding kernel modules.
2258-
{{< /warning >}}
22592253
-->
2260-
{{< warning >}}
22612254
支持多宿主SCTP关联要求 CNI 插件能够支持为一个 Pod 分配多个接口和 IP 地址。
22622255

22632256
用于多宿主 SCTP 关联的 NAT 在相应的内核模块中需要特殊的逻辑。
22642257
{{< /warning >}}
22652258

22662259
<!--
22672260
##### Windows {#caveat-sctp-windows-os}
2268-
2269-
{{< note >}}
2270-
SCTP is not supported on Windows based nodes.
2271-
{{< /note >}}
22722261
-->
22732262
##### Windows {#caveat-sctp-windows-os}
22742263

22752264
{{< note >}}
2265+
<!--
2266+
SCTP is not supported on Windows based nodes.
2267+
-->
22762268
基于 Windows 的节点不支持 SCTP。
22772269
{{< /note >}}
22782270

22792271
<!--
22802272
##### Userspace kube-proxy {#caveat-sctp-kube-proxy-userspace}
2281-
2282-
{{< warning >}}
2283-
The kube-proxy does not support the management of SCTP associations when it is in userspace mode.
2284-
{{< /warning >}}
22852273
-->
22862274
##### 用户空间 kube-proxy {#caveat-sctp-kube-proxy-userspace}
22872275

22882276
{{< warning >}}
2277+
<!--
2278+
The kube-proxy does not support the management of SCTP associations when it is in userspace mode.
2279+
-->
22892280
当 kube-proxy 处于用户空间模式时,它不支持 SCTP 关联的管理。
22902281
{{< /warning >}}
22912282

@@ -2343,7 +2334,7 @@ followed by the data from the client.
23432334
<!--
23442335
* Read [Connecting Applications with Services](/docs/concepts/services-networking/connect-applications-service/)
23452336
* Read about [Ingress](/docs/concepts/services-networking/ingress/)
2346-
* Read about [Endpoint Slices](/docs/concepts/services-networking/endpoint-slices/)
2337+
* Read about [EndpointSlices](/docs/concepts/services-networking/endpoint-slices/)
23472338
-->
23482339
* 阅读[使用服务访问应用](/zh-cn/docs/concepts/services-networking/connect-applications-service/)
23492340
* 阅读了解 [Ingress](/zh-cn/docs/concepts/services-networking/ingress/)

0 commit comments

Comments
 (0)