Skip to content

Commit 074917f

Browse files
authored
Merge pull request #40633 from windsonsea/systrac
[zh] sync 1.27 system-traces.md
2 parents f6cf4cd + e5c5374 commit 074917f

File tree

1 file changed

+82
-26
lines changed

1 file changed

+82
-26
lines changed

content/zh-cn/docs/concepts/cluster-administration/system-traces.md

Lines changed: 82 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ weight: 90
1414

1515
<!-- overview -->
1616

17-
{{< feature-state for_k8s_version="v1.22" state="alpha" >}}
17+
{{< feature-state for_k8s_version="v1.27" state="beta" >}}
1818

1919
<!--
2020
System component traces record the latency of and relationships between operations in the cluster.
@@ -57,10 +57,25 @@ the following receiver configuration will collect spans and log them to standard
5757
-->
5858
默认情况下,Kubernetes 组件使用 gRPC 的 OTLP 导出器来导出追踪信息,将信息写到
5959
[IANA OpenTelemetry 端口](https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml?search=opentelemetry)
60-
举例来说,如果收集器以 Kubernetes 组件的边车模式运行,以下接收器配置会收集 span 信息,并将它们写入到标准输出。
60+
举例来说,如果收集器以 Kubernetes 组件的边车模式运行,
61+
以下接收器配置会收集 span 信息,并将它们写入到标准输出。
6162

6263
<!--
63-
# Replace this exporter with the exporter for your backend
64+
```yaml
65+
receivers:
66+
otlp:
67+
protocols:
68+
grpc:
69+
exporters:
70+
# Replace this exporter with the exporter for your backend
71+
logging:
72+
logLevel: debug
73+
service:
74+
pipelines:
75+
traces:
76+
receivers: [otlp]
77+
exporters: [logging]
78+
```
6479
-->
6580
```yaml
6681
receivers:
@@ -105,38 +120,43 @@ kube-apiserver 为传入的 HTTP 请求、传出到 webhook 和 etcd 的请求
105120
#### 在 kube-apiserver 中启用追踪 {#enabling-tracing-in-the-kube-apiserver}
106121
107122
<!--
108-
To enable tracing, enable the `APIServerTracing`
109-
[feature gate](/docs/reference/command-line-tools-reference/feature-gates/)
110-
on the kube-apiserver. Also, provide the kube-apiserver with a tracing configuration file
123+
To enable tracing, provide the kube-apiserver with a tracing configuration file
111124
with `--tracing-config-file=<path-to-config>`. This is an example config that records
112125
spans for 1 in 10000 requests, and uses the default OpenTelemetry endpoint:
113-
-->
114-
要启用追踪特性,需要启用 kube-apiserver 上的 `APIServerTracing`
115-
[特性门控](/zh-cn/docs/reference/command-line-tools-reference/feature-gates/)。
116-
然后,使用 `--tracing-config-file=<<配置文件路径>` 为 kube-apiserver 提供追踪配置文件。
117-
下面是一个示例配置,它为万分之一的请求记录 spans,并使用了默认的 OpenTelemetry 端口。
118126

119127
```yaml
120-
apiVersion: apiserver.config.k8s.io/v1alpha1
128+
apiVersion: apiserver.config.k8s.io/v1beta1
121129
kind: TracingConfiguration
122130
# default value
123131
#endpoint: localhost:4317
124132
samplingRatePerMillion: 100
125133
```
134+
-->
135+
要启用追踪特性,需要使用 `--tracing-config-file=<<配置文件路径>` 为
136+
kube-apiserver 提供追踪配置文件。下面是一个示例配置,它为万分之一的请求记录
137+
span,并使用了默认的 OpenTelemetry 端点。
138+
139+
```yaml
140+
apiVersion: apiserver.config.k8s.io/v1beta1
141+
kind: TracingConfiguration
142+
# 默认值
143+
#endpoint: localhost:4317
144+
samplingRatePerMillion: 100
145+
```
126146

127147
<!--
128148
For more information about the `TracingConfiguration` struct, see
129-
[API server config API (v1alpha1)](/docs/reference/config-api/apiserver-config.v1alpha1/#apiserver-k8s-io-v1alpha1-TracingConfiguration).
149+
[API server config API (v1beta1)](/docs/reference/config-api/apiserver-config.v1beta1/#apiserver-k8s-io-v1beta1-TracingConfiguration).
130150
-->
131151
有关 TracingConfiguration 结构体的更多信息,请参阅
132-
[API 服务器配置 API (v1alpha1)](/zh-cn/docs/reference/config-api/apiserver-config.v1alpha1/#apiserver-k8s-io-v1alpha1-TracingConfiguration)。
152+
[API 服务器配置 API (v1beta1)](/zh-cn/docs/reference/config-api/apiserver-config.v1beta1/#apiserver-k8s-io-v1beta1-TracingConfiguration)。
133153

134154
<!--
135155
### kubelet traces
136156
-->
137-
### kubelet 追踪 {#kubelet-traces}
157+
### kubelet 追踪 {#kubelet-traces}
138158

139-
{{< feature-state for_k8s_version="v1.25" state="alpha" >}}
159+
{{< feature-state for_k8s_version="v1.27" state="beta" >}}
140160

141161
<!--
142162
The kubelet CRI interface and authenticated http servers are instrumented to generate
@@ -149,23 +169,31 @@ kubelet CRI 接口和实施身份验证的 HTTP 服务器被插桩以生成追
149169
与 API 服务器一样,端点和采样率是可配置的。
150170
追踪上下文传播也是可以配置的。始终优先采用父 span 的采样决策。
151171
用户所提供的追踪配置采样率将被应用到不带父级的 span。
152-
如果在没有配置端点的情况下启用,将使用默认的 OpenTelemetry Collector 接收器地址 “localhost:4317”。
172+
如果在没有配置端点的情况下启用,将使用默认的 OpenTelemetry Collector
173+
接收器地址 “localhost:4317”。
153174

154175
<!--
155176
#### Enabling tracing in the kubelet
156177

157-
To enable tracing, enable the `KubeletTracing`
158-
[feature gate](/docs/reference/command-line-tools-reference/feature-gates/)
159-
on the kubelet. Also, provide the kubelet with a
160-
[tracing configuration](https://github.com/kubernetes/component-base/blob/release-1.25/tracing/api/v1/types.go).
178+
To enable tracing, apply the [tracing configuration](https://github.com/kubernetes/component-base/blob/release-1.27/tracing/api/v1/types.go).
161179
This is an example snippet of a kubelet config that records spans for 1 in 10000 requests, and uses the default OpenTelemetry endpoint:
180+
181+
```yaml
182+
apiVersion: kubelet.config.k8s.io/v1beta1
183+
kind: KubeletConfiguration
184+
featureGates:
185+
KubeletTracing: true
186+
tracing:
187+
# default value
188+
#endpoint: localhost:4317
189+
samplingRatePerMillion: 100
190+
```
162191
-->
163192
#### 在 kubelet 中启用追踪 {#enabling-tracing-in-the-kubelet}
164193

165-
要启用 span,需在 kubelet 上启用 `KubeletTracing`
166-
[特性门控](/zh-cn/docs/reference/command-line-tools-reference/feature-gates/)。
167-
另外,为 kubelet 提供[追踪配置](https://github.com/kubernetes/component-base/blob/release-1.25/tracing/api/v1/types.go)。
168-
以下是 kubelet 配置的示例代码片段,每 10000 个请求中记录一个请求的 span,并使用默认的 OpenTelemetry 端点:
194+
要启用追踪,需应用[追踪配置](https://github.com/kubernetes/component-base/blob/release-1.27/tracing/api/v1/types.go)。
195+
以下是 kubelet 配置的示例代码片段,每 10000 个请求中记录一个请求的
196+
span,并使用默认的 OpenTelemetry 端点:
169197

170198
```yaml
171199
apiVersion: kubelet.config.k8s.io/v1beta1
@@ -178,6 +206,34 @@ tracing:
178206
samplingRatePerMillion: 100
179207
```
180208

209+
<!--
210+
If the `samplingRatePerMillion` is set to one million (`1000000`), then every
211+
span will be sent to the exporter.
212+
-->
213+
如果 `samplingRatePerMillion` 被设置为一百万 (`1000000`),则所有 span 都将被发送到导出器。
214+
215+
<!--
216+
The kubelet in Kubernetes v{{< skew currentVersion >}} collects spans from
217+
the garbage collection, pod synchronization routine as well as every gRPC
218+
method. Connected container runtimes like CRI-O and containerd can link the
219+
traces to their exported spans to provide additional context of information.
220+
-->
221+
Kubernetes v{{< skew currentVersion >}} 中的 kubelet 从垃圾回收、Pod
222+
同步例程以及每个 gRPC 方法中收集 span。CRI-O 和 containerd
223+
这类关联的容器运行时可以将链路链接到其导出的 span,以提供更多上下文信息。
224+
225+
<!--
226+
Please note that exporting spans always comes with a small performance overhead
227+
on the networking and CPU side, depending on the overall configuration of the
228+
system. If there is any issue like that in a cluster which is running with
229+
tracing enabled, then mitigate the problem by either reducing the
230+
`samplingRatePerMillion` or disabling tracing completely by removing the
231+
configuration.
232+
-->
233+
请注意导出 span 始终会对网络和 CPU 产生少量性能开销,具体取决于系统的总体配置。
234+
如果在启用追踪的集群中出现类似性能问题,可以通过降低 `samplingRatePerMillion`
235+
或通过移除此配置来彻底禁用追踪来缓解问题。
236+
181237
<!--
182238
## Stability
183239
-->
@@ -198,4 +254,4 @@ there are no guarantees of backwards compatibility for tracing instrumentation.
198254
<!--
199255
* Read about [Getting Started with the OpenTelemetry Collector](https://opentelemetry.io/docs/collector/getting-started/)
200256
-->
201-
* 阅读[Getting Started with the OpenTelemetry Collector](https://opentelemetry.io/docs/collector/getting-started/)
257+
* 阅读 [Getting Started with the OpenTelemetry Collector](https://opentelemetry.io/docs/collector/getting-started/)

0 commit comments

Comments
 (0)