Skip to content

Commit c8441d9

Browse files
authored
Merge pull request #2982 from tkashem/ssa-drop-managed-fields
KEP-555: omit managed fields from audit log
2 parents e7feb06 + 70b5394 commit c8441d9

File tree

2 files changed

+64
-1
lines changed

2 files changed

+64
-1
lines changed

keps/sig-api-machinery/555-server-side-apply/README.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
- [Proposed Change](#proposed-change)
2020
- [Alternatives](#alternatives)
2121
- [Implementation History](#implementation-history)
22+
- [API Audit](#api-audit)
2223
- [Production Readiness Review Questionnaire](#production-readiness-review-questionnaire)
2324
- [Feature Enablement and Rollback](#feature-enablement-and-rollback)
2425
- [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
286287

287288
- 12/2019 [#86083](https://github.com/kubernetes/kubernetes/pull/86083) implementing a poc for the described approach
288289

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+
289351
## Production Readiness Review Questionnaire
290352
291353
<!--

keps/sig-api-machinery/555-server-side-apply/kep.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ title: Apply
22
kep-number: 555
33
authors:
44
- "@lavalamp"
5+
- "@tkashem"
56
owning-sig: sig-api-machinery
67
participating-sigs:
78
- sig-api-machinery
@@ -15,7 +16,7 @@ prr-approvers:
1516
- "@deads2k"
1617
editor: TBD
1718
creation-date: 2018-03-28
18-
last-updated: 2021-02-21
19+
last-updated: 2021-09-21
1920
status: implementable
2021
see-also:
2122
- n/a

0 commit comments

Comments
 (0)