@@ -4,14 +4,12 @@ content_type: concept
4
4
weight : 60
5
5
---
6
6
<!--
7
- ---
8
7
title: Traces For Kubernetes System Components
9
8
reviewers:
10
9
- logicalhan
11
10
- lilic
12
11
content_type: concept
13
12
weight: 60
14
- ---
15
13
-->
16
14
17
15
<!-- overview -->
@@ -59,7 +57,7 @@ the following receiver configuration will collect spans and log them to standard
59
57
-->
60
58
默认情况下,Kubernetes 组件使用 gRPC 的 OTLP 导出器来导出追踪信息,将信息写到
61
59
[ IANA OpenTelemetry 端口] ( https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml?search=opentelemetry ) 。
62
- 举例来说,如果收集器以 Kubernetes 组件的边车模式运行,以下接收器配置会收集 spans 信息,并将它们写入到标准输出。
60
+ 举例来说,如果收集器以 Kubernetes 组件的边车模式运行,以下接收器配置会收集 span 信息,并将它们写入到标准输出。
63
61
64
62
<!--
65
63
# Replace this exporter with the exporter for your backend
@@ -96,7 +94,7 @@ to webhooks, etcd, and re-entrant requests. It propagates the
96
94
but does not make use of the trace context attached to incoming requests,
97
95
as the kube-apiserver is often a public endpoint.
98
96
-->
99
- kube-apiserver 为传入的 HTTP 请求、传出到 webhook 和 etcd 的请求以及重入的请求生成 spans 。
97
+ kube-apiserver 为传入的 HTTP 请求、传出到 webhook 和 etcd 的请求以及重入的请求生成 span 。
100
98
由于 kube-apiserver 通常是一个公开的端点,所以它通过出站的请求传播
101
99
[W3C 追踪上下文](https://www.w3.org/TR/trace-context/),
102
100
但不使用入站请求的追踪上下文。
@@ -109,7 +107,7 @@ kube-apiserver 为传入的 HTTP 请求、传出到 webhook 和 etcd 的请求
109
107
<!--
110
108
To enable tracing, enable the ` APIServerTracing`
111
109
[feature gate](/docs/reference/command-line-tools-reference/feature-gates/)
112
- on the kube-apiserver. Also, provide the kube-apiserver with a tracing configration file
110
+ on the kube-apiserver. Also, provide the kube-apiserver with a tracing configuration file
113
111
with `--tracing-config-file=<path-to-config>`. This is an example config that records
114
112
spans for 1 in 10000 requests, and uses the default OpenTelemetry endpoint :
115
113
-->
@@ -130,10 +128,56 @@ samplingRatePerMillion: 100
130
128
For more information about the `TracingConfiguration` struct, see
131
129
[API server config API (v1alpha1)](/docs/reference/config-api/apiserver-config.v1alpha1/#apiserver-k8s-io-v1alpha1-TracingConfiguration).
132
130
-->
133
-
134
- 有关 TracingConfiguration 结构体的更多信息,请参阅
131
+ 有关 TracingConfiguration 结构体的更多信息,请参阅
135
132
[API 服务器配置 API (v1alpha1)](/zh-cn/docs/reference/config-api/apiserver-config.v1alpha1/#apiserver-k8s-io-v1alpha1-TracingConfiguration)。
136
133
134
+ <!--
135
+ # ## kubelet traces
136
+ -->
137
+ # ## kubelet 追踪 {#kubelet-traces}
138
+
139
+ {{< feature-state for_k8s_version="v1.25" state="alpha" >}}
140
+
141
+ <!--
142
+ The kubelet CRI interface and authenticated http servers are instrumented to generate
143
+ trace spans. As with the apiserver, the endpoint and sampling rate are configurable.
144
+ Trace context propagation is also configured. A parent span's sampling decision is always respected.
145
+ A provided tracing configuration sampling rate will apply to spans without a parent.
146
+ Enabled without a configured endpoint, the default OpenTelemetry Collector reciever address of "localhost:4317" is set.
147
+ -->
148
+ kubelet CRI 接口和实施身份验证的 HTTP 服务器被插桩以生成追踪 span。
149
+ 与 API 服务器一样,端点和采样率是可配置的。
150
+ 追踪上下文传播也是可以配置的。始终优先采用父 span 的采样决策。
151
+ 用户所提供的追踪配置采样率将被应用到不带父级的 span。
152
+ 如果在没有配置端点的情况下启用,将使用默认的 OpenTelemetry Collector 接收器地址 “localhost:4317”。
153
+
154
+ <!--
155
+ # ### Enabling tracing in the kubelet
156
+
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).
161
+ This is an example snippet of a kubelet config that records spans for 1 in 10000 requests, and uses the default OpenTelemetry endpoint :
162
+ -->
163
+ # ### 在 kubelet 中启用追踪 {#enabling-tracing-in-the-kubelet}
164
+
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 端点:
169
+
170
+ ` ` ` yaml
171
+ apiVersion: kubelet.config.k8s.io/v1beta1
172
+ kind: KubeletConfiguration
173
+ featureGates:
174
+ KubeletTracing: true
175
+ tracing:
176
+ # 默认值
177
+ #endpoint: localhost:4317
178
+ samplingRatePerMillion: 100
179
+ ` ` `
180
+
137
181
<!--
138
182
# # Stability
139
183
-->
0 commit comments