@@ -14,7 +14,7 @@ weight: 90
14
14
15
15
<!-- overview -->
16
16
17
- {{< feature-state for_k8s_version="v1.22 " state="alpha " >}}
17
+ {{< feature-state for_k8s_version="v1.27 " state="beta " >}}
18
18
19
19
<!--
20
20
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
57
57
-->
58
58
默认情况下,Kubernetes 组件使用 gRPC 的 OTLP 导出器来导出追踪信息,将信息写到
59
59
[ 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 信息,并将它们写入到标准输出。
61
62
62
63
<!--
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
+ ```
64
79
-->
65
80
``` yaml
66
81
receivers :
@@ -105,38 +120,43 @@ kube-apiserver 为传入的 HTTP 请求、传出到 webhook 和 etcd 的请求
105
120
#### 在 kube-apiserver 中启用追踪 {#enabling-tracing-in-the-kube-apiserver}
106
121
107
122
<!--
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
111
124
with ` --tracing-config-file=<path-to-config>`. This is an example config that records
112
125
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 端口。
118
126
119
127
` ` ` yaml
120
- apiVersion: apiserver.config.k8s.io/v1alpha1
128
+ apiVersion: apiserver.config.k8s.io/v1beta1
121
129
kind: TracingConfiguration
122
130
# default value
123
131
#endpoint: localhost:4317
124
132
samplingRatePerMillion: 100
125
133
` ` `
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
+ ` ` `
126
146
127
147
<!--
128
148
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).
130
150
-->
131
151
有关 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)。
133
153
134
154
<!--
135
155
# ## kubelet traces
136
156
-->
137
- # ## kubelet 追踪 {#kubelet-traces}
157
+ # ## kubelet 追踪 {#kubelet-traces}
138
158
139
- {{< feature-state for_k8s_version="v1.25 " state="alpha " >}}
159
+ {{< feature-state for_k8s_version="v1.27 " state="beta " >}}
140
160
141
161
<!--
142
162
The kubelet CRI interface and authenticated http servers are instrumented to generate
@@ -149,23 +169,31 @@ kubelet CRI 接口和实施身份验证的 HTTP 服务器被插桩以生成追
149
169
与 API 服务器一样,端点和采样率是可配置的。
150
170
追踪上下文传播也是可以配置的。始终优先采用父 span 的采样决策。
151
171
用户所提供的追踪配置采样率将被应用到不带父级的 span。
152
- 如果在没有配置端点的情况下启用,将使用默认的 OpenTelemetry Collector 接收器地址 “localhost:4317”。
172
+ 如果在没有配置端点的情况下启用,将使用默认的 OpenTelemetry Collector
173
+ 接收器地址 “localhost:4317”。
153
174
154
175
<!--
155
176
# ### Enabling tracing in the kubelet
156
177
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).
161
179
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
+ ` ` `
162
191
-->
163
192
# ### 在 kubelet 中启用追踪 {#enabling-tracing-in-the-kubelet}
164
193
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 端点:
169
197
170
198
` ` ` yaml
171
199
apiVersion: kubelet.config.k8s.io/v1beta1
@@ -178,6 +206,34 @@ tracing:
178
206
samplingRatePerMillion: 100
179
207
` ` `
180
208
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
+
181
237
<!--
182
238
# # Stability
183
239
-->
@@ -198,4 +254,4 @@ there are no guarantees of backwards compatibility for tracing instrumentation.
198
254
<!--
199
255
* Read about [Getting Started with the OpenTelemetry Collector](https://opentelemetry.io/docs/collector/getting-started/)
200
256
-->
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