@@ -33,13 +33,13 @@ Kubernetes **审计(Auditing)** 功能提供了与安全相关的、按时
33
33
- from where was it initiated?
34
34
- to where was it going?
35
35
-->
36
- - 发生了什么?
37
- - 什么时候发生的?
38
- - 谁触发的?
39
- - 活动发生在哪个(些)对象上?
40
- - 在哪观察到的?
41
- - 它从哪触发的?
42
- - 活动的后续处理行为是什么?
36
+ - 发生了什么?
37
+ - 什么时候发生的?
38
+ - 谁触发的?
39
+ - 活动发生在哪个(些)对象上?
40
+ - 在哪观察到的?
41
+ - 它从哪触发的?
42
+ - 活动的后续处理行为是什么?
43
43
44
44
<!-- body -->
45
45
@@ -55,7 +55,7 @@ include logs files and webhooks.
55
55
审计记录最初产生于
56
56
[ kube-apiserver] ( /zh-cn/docs/reference/command-line-tools-reference/kube-apiserver/ )
57
57
内部。每个请求在不同执行阶段都会生成审计事件;这些审计事件会根据特定策略被预处理并写入后端。
58
- 策略确定要记录的内容和用来存储记录的后端,当前的后端支持日志文件和 webhook 。
58
+ 策略确定要记录的内容和用来存储记录的后端,当前的后端支持日志文件和 Webhook 。
59
59
60
60
<!--
61
61
Each request can be recorded with an associated _stage_. The defined stages are:
@@ -87,8 +87,8 @@ is different from the
87
87
[Event](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#event-v1-core)
88
88
API object.
89
89
-->
90
- [ 审计事件配置] ( /zh-cn/docs/reference/config-api/apiserver-audit.v1/#audit-k8s-io-v1-Event )
91
- 的配置与 [ Event] (/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#event-v1-core)
90
+ [ 审计事件配置] ( /zh-cn/docs/reference/config-api/apiserver-audit.v1/#audit-k8s-io-v1-Event ) 的配置与
91
+ [ Event] (/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#event-v1-core)
92
92
API 对象不同。
93
93
{{< /note >}}
94
94
@@ -97,7 +97,7 @@ The audit logging feature increases the memory consumption of the API server
97
97
because some context required for auditing is stored for each request.
98
98
Memory consumption depends on the audit logging configuration.
99
99
-->
100
- 审计日志记录功能会增加 API server 的内存消耗 ,因为需要为每个请求存储审计所需的某些上下文。
100
+ 审计日志记录功能会增加 API 服务器的内存消耗 ,因为需要为每个请求存储审计所需的某些上下文。
101
101
内存消耗取决于审计日志记录的配置。
102
102
103
103
<!--
@@ -155,6 +155,15 @@ You can use a minimal audit policy file to log all requests at the `Metadata` le
155
155
-->
156
156
你可以使用最低限度的审计策略文件在 ` Metadata ` 级别记录所有请求:
157
157
158
+ <!--
159
+ ```yaml
160
+ # Log all requests at the Metadata level.
161
+ apiVersion: audit.k8s.io/v1
162
+ kind: Policy
163
+ rules:
164
+ - level: Metadata
165
+ ```
166
+ -->
158
167
``` yaml
159
168
# 在 Metadata 级别为所有请求生成日志
160
169
apiVersion : audit.k8s.io/v1beta1
@@ -199,8 +208,7 @@ In all cases, audit events follow a structure defined by the Kubernetes API in t
199
208
- Webhook 后端,将事件发送到外部 HTTP API
200
209
201
210
在这所有情况下,审计事件均遵循 Kubernetes API 在
202
- [`audit.k8s.io` API 组](/zh-cn/docs/reference/config-api/apiserver-audit.v1/#audit-k8s-io-v1-Event)
203
- 中定义的结构。
211
+ [`audit.k8s.io` API 组](/zh-cn/docs/reference/config-api/apiserver-audit.v1/#audit-k8s-io-v1-Event)中定义的结构。
204
212
205
213
{{< note >}}
206
214
<!--
@@ -334,23 +342,28 @@ Both log and webhook backends support batching. Using webhook as an example, her
334
342
available flags. To get the same flag for log backend, replace `webhook` with `log` in the flag
335
343
name. By default, batching is enabled in `webhook` and disabled in `log`. Similarly, by default
336
344
throttling is enabled in `webhook` and disabled in `log`.
345
+
346
+ Both `log` and `webhook` backends support batching. Below is a list of
347
+ available flags specific to each backend.
348
+ By default, batching and throttling are **enabled** for the `webhook` backend and **disabled** for the `log` backend.
337
349
-->
338
350
# # 事件批处理 {#batching}
339
351
340
- 日志和 Webhook 后端都支持批处理。以 Webhook 为例,以下是可用参数列表。要获取日志
341
- 后端的同样参数,请在参数名称中将 `webhook` 替换为 `log`。
342
- 默认情况下,在 `webhook` 中批处理是被启用的,在 `log` 中批处理是被禁用的。
343
- 同样,默认情况下,在 `webhook` 中启用带宽限制,在 `log` 中禁用带宽限制。
352
+ 日志和 Webhook 后端都支持批处理。以下是特定于每个后端的可用参数列表。
353
+ 默认情况下,在 `webhook` 后端中批处理和带宽限制是被启用的,
354
+ 在 `log` 后端中批处理和带宽限制是被禁用的。
344
355
356
+ {{< tabs name="tab_with_md" >}}
357
+ {{% tab name="webhook" %}}
345
358
<!--
346
359
- `--audit-webhook-mode` defines the buffering strategy. One of the following :
347
- - ` batch` - buffer events and asynchronously process them in batches. This is the default.
360
+ - ` batch` - buffer events and asynchronously process them in batches. This is the default mode for the `webhook` backend .
348
361
- ` blocking` - block API server responses on processing each individual event.
349
362
- ` blocking-strict` - Same as blocking, but when there is a failure during audit logging at the
350
- RequestReceived stage, the whole request to the kube-apiserver fails.
363
+ RequestReceived stage, the whole request to the kube-apiserver fails.
351
364
-->
352
365
- ` --audit-webhook-mode` 定义缓存策略,可选值如下:
353
- - ` batch` - 以批处理缓存事件和异步的过程。这是默认值 。
366
+ - ` batch` - 以批处理缓存事件和异步的过程。这对 `webhook` 后端来说是默认模式 。
354
367
- ` blocking` - 在 API 服务器处理每个单独事件时,阻塞其响应。
355
368
- ` blocking-strict` - 与 `blocking` 相同,不过当审计日志在 RequestReceived
356
369
阶段失败时,整个 API 服务请求会失效。
@@ -359,23 +372,67 @@ throttling is enabled in `webhook` and disabled in `log`.
359
372
The following flags are used only in the `batch` mode :
360
373
361
374
- ` --audit-webhook-batch-buffer-size` defines the number of events to buffer before batching.
362
- If the rate of incoming events overflows the buffer, events are dropped.
363
- - ` --audit-webhook-batch-max-size` defines the maximum number of events in one batch.
375
+ If the rate of incoming events overflows the buffer, events are dropped. The default value is 10000.
376
+ - ` --audit-webhook-batch-max-size` defines the maximum number of events in one batch. The default value is 400.
364
377
- ` --audit-webhook-batch-max-wait` defines the maximum amount of time to wait before unconditionally
365
- batching events in the queue.
378
+ batching events in the queue. The default value is 30 seconds.
379
+ - ` --audit-webhook-batch-throttle-enable` defines whether batching throttling is enabled. Throttling is enabled by default.
366
380
- ` --audit-webhook-batch-throttle-qps` defines the maximum average number of batches generated
367
- per second.
381
+ per second. The default value is 10.
368
382
- ` --audit-webhook-batch-throttle-burst` defines the maximum number of batches generated at the same
369
- moment if the allowed QPS was underutilized previously.
383
+ moment if the allowed QPS was underutilized previously. The default value is 15.
370
384
-->
371
385
以下参数仅用于 `batch` 模式:
372
386
373
387
- ` --audit-webhook-batch-buffer-size` 定义 batch 之前要缓存的事件数。
374
- 如果传入事件的速率溢出缓存区,则会丢弃事件。
375
- - ` --audit-webhook-batch-max-size` 定义一个 batch 中的最大事件数。
376
- - ` --audit-webhook-batch-max-wait` 无条件 batch 队列中的事件前等待的最大事件。
377
- - ` --audit-webhook-batch-throttle-qps` 每秒生成的最大批次数。
378
- - ` --audit-webhook-batch-throttle-burst` 在达到允许的 QPS 前,同一时刻允许存在的最大 batch 生成数。
388
+ 如果传入事件的速率溢出缓存区,则会丢弃事件。默认值是 10000。
389
+ - ` --audit-webhook-batch-max-size` 定义一个 batch 中的最大事件数。默认值是 400。
390
+ - ` --audit-webhook-batch-max-wait` 定义无条件批处理队列中的事件前等待的最大时间。默认值是 30 秒。
391
+ - ` --audit-webhook-batch-throttle-enable` 定义是否启用批处理带宽限制。带宽限制默认被启用。
392
+ - ` --audit-webhook-batch-throttle-qps` 定义每秒生成的最大平均批次数。默认值是 10。
393
+ - ` --audit-webhook-batch-throttle-burst` 定义在达到允许的 QPS 前,同一时刻允许存在的最大 batch 生成数。默认值是 15。
394
+ {{% /tab %}}
395
+ {{% tab name="log" %}}
396
+ <!--
397
+ - `--audit-log-mode` defines the buffering strategy. One of the following :
398
+ - ` batch` - buffer events and asynchronously process them in batches. Batching is not recommended for the `log` backend.
399
+ - ` blocking` - block API server responses on processing each individual event. This is the default mode for the `log` backend.
400
+ - ` blocking-strict` - Same as blocking, but when there is a failure during audit logging at the
401
+ RequestReceived stage, the whole request to the kube-apiserver fails.
402
+ -->
403
+ - ` --audit-log-mode` 定义缓存策略,可选值如下:
404
+ - ` batch` - 以批处理缓存事件并对它们作异步的批处理。不建议在 `log` 后端使用批处理。
405
+ - ` blocking` - 在处理每个单独事件时阻塞 API 服务器的响应。这是 `log` 后端的默认模式。
406
+ - ` blocking-strict` - 与 `blocking` 相同,但如果在 RequestReceived 阶段审计日志记录失败,
407
+ 则整个发往 kube-apiserver 的请求也会失败。
408
+
409
+ <!--
410
+ The following flags are used only in the `batch` mode (batching is **disabled** by default for the `log` backend, and when batching is disabled, all batching-related flags are ignored) :
411
+
412
+ - ` --audit-log-batch-buffer-size` defines the number of events to buffer before batching.
413
+ If the rate of incoming events overflows the buffer, events are dropped.
414
+ - ` --audit-log-batch-max-size` defines the maximum number of events in one batch.
415
+ - ` --audit-log-batch-max-wait` defines the maximum amount of time to wait before unconditionally
416
+ batching events in the queue.
417
+ -->
418
+ 以下参数仅在 `batch` 模式下使用(`log` 后端默认**禁用**批处理,当批处理被禁用时,所有与批处理相关的参数都会被忽略):
419
+
420
+ - ` --audit-log-batch-buffer-size` 定义在批处理之前缓存的事件数。
421
+ 如果传入事件的速率超过缓存区容量,多余的事件将被丢弃。
422
+ - ` --audit-log-batch-max-size` 定义一个 batch 中的最大事件数。
423
+ - ` --audit-log-batch-max-wait` 定义无条件批处理队列中的事件前等待的最长时间。
424
+ <!--
425
+ - ` --audit-log-batch-throttle-enable` defines whether batching throttling is enabled.
426
+ - ` --audit-log-batch-throttle-qps` defines the maximum average number of batches generated
427
+ per second.
428
+ - ` --audit-log-batch-throttle-burst` defines the maximum number of batches generated at the same
429
+ moment if the allowed QPS was underutilized previously.
430
+ -->
431
+ - ` --audit-log-batch-throttle-enable` 定义是否启用批处理带宽限制。
432
+ - ` --audit-log-batch-throttle-qps` 定义每秒生成的最大平均批次数。
433
+ - ` --audit-log-batch-throttle-burst` 定义在先前 QPS 未被充分使用的情况下,允许瞬时生成的最大批次数。
434
+ {{% /tab %}}
435
+ {{< /tabs >}}
379
436
380
437
<!--
381
438
# # Parameter tuning
0 commit comments