You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -123,7 +122,7 @@ API](/keps/sig-api-machinery/3488-cel-admission-control/README.md) for
123
122
validating admission policies.
124
123
125
124
This enhancement proposes an approach where mutations are declared in CEL by
126
-
combining CEL's object instantiation and Server Side Apply's merge algorithms.
125
+
combining CEL's object instantiation, JSON Patch, and Server Side Apply's merge algorithms.
127
126
128
127
## Motivation
129
128
@@ -180,18 +179,18 @@ Very similar to what we have in ValidatingAdmissionPolicy, this API separates po
180
179
- Policy param resources (custom resources or config maps)
181
180
182
181
The idea is to leverage the CEL power of the object construction and allow users to define how they want to mutate the admission request through CEL expression.
183
-
This proposal aims to allow mutations to be expressed using the "apply configuration" introduced by Server Side Apply.
182
+
This proposal aims to allow mutations to be expressed using JSON Patch, or the "apply configuration" introduced by Server Side Apply.
184
183
And users would be able to define only the fields they care about inside MutatingAdmissionPolicy, the object will be constructed using CEL which would be similar to a Server Side Apply configuration patch and then be merged into the request object using the structural merge strategy.
185
184
See sigs.k8s.io/structured-merge-diff for more details.
186
185
187
186
Note: See the alternative consideration section for the alternatives.
188
187
189
188
Pros:
190
-
-Consistent with Server Side Apply so that we will continue investing SSA as the best way to do patch updates to resources;
191
-
-Does not require the users to learn a new syntax;
192
-
- Inherit the declarative nature;
193
-
- Existing merging strategy to be leverage without rewritten and the effort of maintaining multiple systems;
194
-
- Support the existing makers/openapi extensions.
189
+
-JSON Patch provides a migration path from mutating admission webhooks, which must use JSON Patch.
190
+
-Also build on Server Side Apply so that we will continue investing SSA as the best way to do patch updates to resources;
191
+
- Does not require the users to learn a new syntax;
192
+
- Inherit the declarative nature;
193
+
- Leverages existing merging strategy, markers and openapi extensions.
195
194
196
195
Cons:
197
196
- Lack of deletion support (see the unsetting values section for the details and workaround);
When "ApplyConfiguration" specified, the expression evaluates to an object that has the same type as the incoming object, and the type alias Object refers to the type (see Type Handling for details).
262
290
@@ -460,7 +488,8 @@ For example, to remove the env of a sidecar container, filter by its name.
460
488
461
489
```yaml
462
490
mutations:
463
-
- mutaton: >
491
+
- patchType: "ApplyConfiguration"
492
+
expression: >
464
493
Object{
465
494
spec: Object.spec{
466
495
containers: object.spec.containers{
@@ -496,7 +525,8 @@ List with "map" merge type:
496
525
- For associatedList with multiple keys like example above, a directive field added could be used to indicate the deletion.
497
526
```yaml
498
527
mutations:
499
-
- mutaton: >
528
+
- patchType: "ApplyConfiguration"
529
+
expression: >
500
530
Object{
501
531
spec: Object.spec{
502
532
assocListField: [Object.spec.assocListField{
@@ -512,7 +542,8 @@ mutations:
512
542
For examples of removing item from List with Map filtered by a subfield:
#### Use case: modify deprecated field under CRD versions
827
-
Support atomic list modification through JSONPatch
866
+
Support atomic list modification through JSON Patch
828
867
829
868
830
869
#### Use Case - mutation VS controller fight
@@ -1523,21 +1562,8 @@ What other approaches did you consider, and why did you rule them out? These do
1523
1562
not need to be as detailed as the proposal, but should include enough
1524
1563
information to express the idea and why it was not acceptable.
1525
1564
-->
1526
-
Here are the alternative considerations compared to using the apply configurations introduced by Server Side Apply.
1565
+
Here are the alternative considerations compared to using JSON Patch and the apply configurations introduced by Server Side Apply.
1527
1566
1528
-
### Alternative 1: JSONPatch
1529
-
1530
-
Mutating Admission Webhooks express intended mutation in JSONPatch. Previous attempt by Andrew Sy Kim proposed a similar solution. However, because MutatingAdmissionPolicy, running inside the API server, no longer requires a remote call, modification can apply without serialization as JSONPatch.
1531
-
- Pros:
1532
-
- Same as the current way Mutation Webhook used
1533
-
- Support most of the existing use cases
1534
-
- Low learning curve while migration from Mutation Webhook
1535
-
- Cons:
1536
-
- No type checking
1537
-
- Long JSON in declarative API
1538
-
- Do not support types like `strategicMergePatch`, `JSONMergePatch` and `ApplyConfigurations`
1539
-
- Low learning curve while setting up mutations from scratch
1540
-
1541
1567
### Alternative 2: Introduce new syntax
1542
1568
1543
1569
Another alternative consideration would be rewriting your own merge algorithm which is a lot of duplicated effort.
0 commit comments