1
1
---
2
2
title : 服务内部流量策略
3
3
content_type : concept
4
- weight : 75
4
+ weight : 120
5
5
description : >-
6
6
如果集群中的两个 Pod 想要通信,并且两个 Pod 实际上都在同一节点运行,
7
7
**服务内部流量策略** 可以将网络流量限制在该节点内。
@@ -13,7 +13,7 @@ reviewers:
13
13
- maplain
14
14
title: Service Internal Traffic Policy
15
15
content_type: concept
16
- weight: 75
16
+ weight: 120
17
17
description: >-
18
18
If two Pods in your cluster want to communicate, and both Pods are actually running on
19
19
the same node, _Service Internal Traffic Policy_ to keep network traffic within that node.
@@ -24,7 +24,7 @@ description: >-
24
24
25
25
<!-- overview -->
26
26
27
- {{< feature-state for_k8s_version="v1.23 " state="beta " >}}
27
+ {{< feature-state for_k8s_version="v1.26 " state="stable " >}}
28
28
29
29
<!--
30
30
_Service Internal Traffic Policy_ enables internal traffic restrictions to only route
@@ -43,20 +43,16 @@ cluster. This can help to reduce costs and improve performance.
43
43
-->
44
44
## 使用服务内部流量策略 {#using-service-internal-traffic-policy}
45
45
46
- <!--
47
- The `ServiceInternalTrafficPolicy` [feature gate](/docs/reference/command-line-tools-reference/feature-gates/)
48
- is a Beta feature and enabled by default.
49
- When the feature is enabled, you can enable the internal-only traffic policy for a
46
+ <!--
47
+ You can enable the internal-only traffic policy for a
50
48
{{< glossary_tooltip text="Service" term_id="service" >}}, by setting its
51
- `.spec.internalTrafficPolicy` to `Local`.
52
- This tells kube-proxy to only use node local endpoints for cluster internal traffic.
49
+ `.spec.internalTrafficPolicy` to `Local`. This tells kube-proxy to only use node local
50
+ endpoints for cluster internal traffic.
53
51
-->
54
- ` ServiceInternalTrafficPolicy `
55
- [ 特性门控] ( /zh-cn/docs/reference/command-line-tools-reference/feature-gates/ ) 是 Beta 功能,默认启用。
56
- 启用该功能后,你就可以通过将 {{< glossary_tooltip text="Service" term_id="service" >}} 的
52
+ 你可以通过将 {{< glossary_tooltip text="Service" term_id="service" >}} 的
57
53
` .spec.internalTrafficPolicy ` 项设置为 ` Local ` ,
58
54
来为它指定一个内部专用的流量策略。
59
- 此设置就相当于告诉 kube-proxy 对于集群内部流量只能使用本地的服务端口 。
55
+ 此设置就相当于告诉 kube-proxy 对于集群内部流量只能使用节点本地的服务端口 。
60
56
61
57
<!--
62
58
For pods on nodes with no endpoints for a given Service, the Service
@@ -97,28 +93,23 @@ spec:
97
93
-->
98
94
## 工作原理 {#how-it-works}
99
95
100
- <!--
96
+ <!--
101
97
The kube-proxy filters the endpoints it routes to based on the
102
98
` spec.internalTrafficPolicy` setting. When it's set to `Local`, only node local
103
- endpoints are considered. When it's `Cluster` or missing, all endpoints are
104
- considered.
105
- When the [feature gate](/docs/reference/command-line-tools-reference/feature-gates/)
106
- ` ServiceInternalTrafficPolicy` is enabled, `spec.internalTrafficPolicy` defaults to "Cluster".
99
+ endpoints are considered. When it's `Cluster` (the default), or is not set,
100
+ Kubernetes considers all endpoints.
107
101
-->
108
102
kube-proxy 基于 `spec.internalTrafficPolicy` 的设置来过滤路由的目标服务端点。
109
- 当它的值设为 `Local` 时,只选择节点本地的服务端点。
110
- 当它的值设为 `Cluster` 或缺省时,则选择所有的服务端点。
111
- 启用[特性门控](/zh-cn/docs/reference/command-line-tools-reference/feature-gates/)
112
- ` ServiceInternalTrafficPolicy` 后,
113
- ` spec.internalTrafficPolicy` 的值默认设为 `Cluster`。
103
+ 当它的值设为 `Local` 时,只会选择节点本地的服务端点。
104
+ 当它的值设为 `Cluster` 或缺省时,Kubernetes 会选择所有的服务端点。
114
105
115
106
# # {{% heading "whatsnext" %}}
116
107
117
108
<!--
118
109
* Read about [Topology Aware Hints](/docs/concepts/services-networking/topology-aware-hints)
119
110
* Read about [Service External Traffic Policy](/docs/tasks/access-application-cluster/create-external-load-balancer/#preserving-the-client-source-ip)
120
- * Read [Connecting Applications with Services](/docs/concepts /services-networking /connect-applications-service/)
111
+ * Follow the [Connecting Applications with Services](/docs/tutorials /services/connect-applications-service/) tutorial
121
112
-->
122
113
* 请阅读[拓扑感知提示](/zh-cn/docs/concepts/services-networking/topology-aware-hints)
123
114
* 请阅读 [Service 的外部流量策略](/zh-cn/docs/tasks/access-application-cluster/create-external-load-balancer/#preserving-the-client-source-ip)
124
- * 请阅读[用 Service 连接应用 ](/zh-cn/docs/concepts /services-networking /connect-applications-service/)
115
+ * 遵循[使用 Service 连接到应用 ](/zh-cn/docs/tutorials /services/connect-applications-service/)教程
0 commit comments