|
19 | 19 | - [Proposed Change](#proposed-change)
|
20 | 20 | - [Alternatives](#alternatives)
|
21 | 21 | - [Implementation History](#implementation-history)
|
| 22 | + - [API Audit](#api-audit) |
22 | 23 | - [Production Readiness Review Questionnaire](#production-readiness-review-questionnaire)
|
23 | 24 | - [Feature Enablement and Rollback](#feature-enablement-and-rollback)
|
24 | 25 | - [Rollout, Upgrade and Rollback Planning](#rollout-upgrade-and-rollback-planning)
|
@@ -286,6 +287,67 @@ The conversion between the two and creating the diff was complex and would have
|
286 | 287 |
|
287 | 288 | - 12/2019 [#86083](https://github.com/kubernetes/kubernetes/pull/86083) implementing a poc for the described approach
|
288 | 289 |
|
| 290 | + |
| 291 | +#### API Audit |
| 292 | + |
| 293 | +The `ManagedFields` fields of an object in the API audit log may not be very useful. We want to provide a mechanism, |
| 294 | +so the cluster operator can opt in so that the managed fields can be omitted from the audit log. |
| 295 | + |
| 296 | +We propose the following changes to the `audit.k8s.io/Policy` API that provides the cluster operator with a more |
| 297 | +granular way to control the omission of managed fields in audit log: |
| 298 | +```go |
| 299 | +type Policy struct { |
| 300 | + // +optional |
| 301 | + OmitManagedFields bool `json:"omitManagedFields,omitempty"` |
| 302 | +} |
| 303 | + |
| 304 | +type PolicyRule struct { |
| 305 | + // +optional |
| 306 | + OmitManagedFields *bool `json:"omitManagedFields,omitempty"` |
| 307 | +} |
| 308 | +``` |
| 309 | +The above API changes will be introduced in `v1`, `v1beta1` and `v1alpha1` of `audit.k8s.io` |
| 310 | + |
| 311 | +A new field `OmitManagedFields` is added to both `Policy` and `PolicyRule` making the following possible: |
| 312 | +- `Policy.OmitManagedFields` sets the default policy for omitting managed fields globally. |
| 313 | + - the default value is `false`, managed fields are not omitted, this retains the current behavior. |
| 314 | + - a value of `true` will omit managed fields from being written to the API audit log unless `PolicyRule` overrides. |
| 315 | +- `PolicyRule:OmitManagedFields` can be used to override the global default for a particular set of request(s), |
| 316 | + it has three possible values: |
| 317 | + - `nil` (default value): the cluster operator did not specify any value, |
| 318 | + the global default specified in `Policy.OmitManagedFields` is in effect. |
| 319 | + - `true`: the cluster operator opted in to omit managed fields for a given set of request(s), and it overrides the global default. |
| 320 | + - `false`: the cluster operator opted in to not omit managed fields for a given set of request(s), and it overrides the global default. |
| 321 | + |
| 322 | +This ensures the following: |
| 323 | +- with an existing `Policy` object, the new version of the apiserver will maintain current behavior which |
| 324 | + is to include managed fields in audit log |
| 325 | +- the cluster operator must opt in to enable omission of managed fields |
| 326 | + |
| 327 | +Let's look at a few examples: |
| 328 | +```yaml |
| 329 | + # omit managed fields for all request and all response bodies |
| 330 | + apiVersion: audit.k8s.io/v1 |
| 331 | + kind: Policy |
| 332 | + omitManagedFields: true |
| 333 | + rules: |
| 334 | + - level: RequestResponse |
| 335 | +``` |
| 336 | +
|
| 337 | +```yaml |
| 338 | + # omit managed fields for all request and all response bodies |
| 339 | + # except for Pod for which we want to include managed fields in audit log |
| 340 | + apiVersion: audit.k8s.io/v1 |
| 341 | + kind: Policy |
| 342 | + omitManagedFields: true |
| 343 | + rules: |
| 344 | + - level: RequestResponse |
| 345 | + omitManagedFields: false |
| 346 | + resources: ["pods"] |
| 347 | + |
| 348 | + - level: RequestResponse |
| 349 | +``` |
| 350 | +
|
289 | 351 | ## Production Readiness Review Questionnaire
|
290 | 352 |
|
291 | 353 | <!--
|
|
0 commit comments