Skip to content

Commit 04ba39a

Browse files
committed
Clear UNRESOLVEDs, defer enforcement actions to phase 2
1 parent 6dcfbdc commit 04ba39a

File tree

1 file changed

+41
-80
lines changed
  • keps/sig-api-machinery/3488-cel-admission-control

1 file changed

+41
-80
lines changed

keps/sig-api-machinery/3488-cel-admission-control/README.md

Lines changed: 41 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
- [Singleton Policies](#singleton-policies)
2626
- [Limits](#limits)
2727
- [Phase 2](#phase-2)
28+
- [Enforcement Actions](#enforcement-actions)
2829
- [Namespace scoped policy binding](#namespace-scoped-policy-binding)
2930
- [CEL Expression Composition](#cel-expression-composition)
3031
- [Variables](#variables)
@@ -405,9 +406,7 @@ spec:
405406
- name: max-replicas
406407
expression: "object.spec.replicas <= params.maxReplicas"
407408
messageExpression: "'object.spec.replicas must be no greater than ' + string(params.maxReplicas)"
408-
enforcement:
409-
deny:
410-
reason: Invalid
409+
reason: Invalid
411410
# ...other rule related fields here...
412411
```
413412

@@ -851,16 +850,9 @@ Policy definitions:
851850
will be included in the failure message
852851
- If `messageExpression` results in an error: `expression` and `name` will be
853852
included in the failure message plus the arg evaluation failure
854-
- Each validation may set a `reason` or `code`
855-
856-
- Each validation may select `enforcement` options:
857-
- `deny { reason: ..., code: ... }`
858-
- If `reason` or `code` is provided, they use the same semantics as
859-
admission review. The reason clarifies the code but does not override it.
860-
- `warn {}` - Included as a warning in the response to the client AND logged.
861-
- Note: audit annotations is deferred until phase 2, see below "Audit
862-
Annotations" section for details.
863-
- (metrics will be emitted regardless of which enforcement options are set)
853+
- `reason` and/or `code` - these fields have same semantics as admission
854+
review; the reason clarifies the code but does not override it. If
855+
`reason` is well known (.e.g "Unauthorizied" is well known to be `code` 401), then the code will be inferred from the `reason` and use of a different code will not be allowed.
864856

865857
Example policy definition:
866858

@@ -876,51 +868,19 @@ spec:
876868
- expression: "self.name.startsWith('xyz-')"
877869
name: name-prefix
878870
messageExpression: "self.name + ' must start with xyz-'"
879-
enforcement:
880-
deny:
881-
code: 401
882-
reason: Unauthorized
871+
reason: Unauthorized
883872
- expression: "self.name.contains('bad')"
884873
name: bad-name
885874
message: "name contains 'bad' which is discouraged due to ..."
886-
enforcement:
887-
deny:
888-
code: 400
889-
reason: Invalid
875+
code: 400
876+
reason: Invalid
890877
- expression: "self.name.contains('suspicious')"
891878
name: suspicious-name
892879
messageExpression: "self.name + ' contains suspicious'"
893-
enforcement:
894-
warn: {}
895-
```
896-
897-
Policy bindings:
898-
899-
- `mode` may be set to one of:
900-
- `Enforce` (default) - the policy validation enforcements apply.
901-
- `DryRun` - for testing out a new binding during rollout, no failures or
902-
violations of any kind result in a deny, but are instead redirected to logs.
903-
This is a good mode for cluster administrators to use to check the potential
904-
impact of a policy before enabling it fully.
905-
906-
corresponding policy configuration:
907-
908-
```yaml
909-
kind: PolicyBinding
910-
...
911-
spec:
912-
...
913-
mode: DryRun
914-
...
880+
code: 400
881+
reason: Invalid
915882
```
916883

917-
Implementation note: When the same param object is bound multiple times to the
918-
same policy via different bindings, it is not necessary to evalute the CEL
919-
expressions for the policy for each of the bindings since the result will always
920-
be the same. But the bindings may have different enforcement settings, so we
921-
will need to apply those and attribute all violations to the appropriate
922-
binding.
923-
924884
xref:
925885

926886
- https://open-policy-agent.github.io/gatekeeper/website/docs/next/violations/
@@ -1021,7 +981,6 @@ spec:
1021981
- expression: "object.spec.replicas < 100"
1022982
singletonBinding:
1023983
matchResources: ...
1024-
mode: Enabled
1025984
```
1026985

1027986
Note that:
@@ -1059,6 +1018,29 @@ All these capabilities are required before Beta, but will not be implemented in
10591018
the first alpha release of this enhancement due to the size and complexity of
10601019
this enhancement.
10611020

1021+
#### Enforcement Actions
1022+
1023+
For phase 1, all violations implicitly result in a `deny` enforcement action.
1024+
1025+
For phase 2, we intend to support multiple enforcement actions.
1026+
1027+
Use cases:
1028+
1029+
- Cluster admin would like to rollout a policies, sometimes in bulk, without
1030+
knowing all the details of the policies. During rollout the cluster admin
1031+
needs a state where the policies being rolled out cannot result in admission
1032+
rejection.
1033+
- A policy framework needs different enforcement actions at different
1034+
enforcement points.
1035+
- Cluster admin would like to set specific enforcement actions for policy
1036+
violations.
1037+
1038+
We also intend to support multiple enforcement actions:
1039+
1040+
- Deny
1041+
- Audit annotation
1042+
- Client warnings
1043+
10621044
#### Namespace scoped policy binding
10631045

10641046
For phase 1, policy bindings were only allowed to be cluster scoped. We can
@@ -1104,11 +1086,6 @@ repeated evaluations if they are shared across validations.
11041086

11051087
#### Secondary Authz
11061088

1107-
<<[UNRESOLVED jpbetz, deads2k, tallclair, ?? ]>>
1108-
We have general agreement to include this as a feature, but need to provide a
1109-
more concrete design.
1110-
<<[/UNRESOLVED]>>
1111-
11121089
kube-apiserver authorizer checks (aka Secondary-authz checks) have been proposed
11131090
as a way of doing things like:
11141091

@@ -1154,11 +1131,6 @@ we should investigate with sig-auth.
11541131

11551132
#### Access to namespace metadata
11561133

1157-
<<[UNRESOLVED jpbetz]>>
1158-
This needs a concrete proposal and discussion before we commit to implementing
1159-
it (or not).
1160-
<<[/UNRESOLVED]>>
1161-
11621134
- Namespace labels and annotations are the most commonly needed fields not
11631135
already available in the resource being validated. Note that
11641136
namespaceSelectors already allow matches to examine namespace levels, but we
@@ -1209,9 +1181,7 @@ Constraints](https://github.com/kubernetes/enhancements/tree/master/keps/sig-api
12091181

12101182
#### Safety Features
12111183

1212-
<<[UNRESOLVED jpbetz, ?? ]>>
1213-
Decide exactly what we are willing to commit to here.
1214-
<<[/UNRESOLVED]>>
1184+
Additional safety features we should consider:
12151185

12161186
- Configurable admission blocking write requests made internally in
12171187
kube-apiserver during server startup (like RBAC default policy reconciliation)
@@ -1248,10 +1218,9 @@ To consider:
12481218

12491219
#### Audit Annotations
12501220

1251-
<<[UNRESOLVED ]>>
1252-
Would audit support in this enhancement become redundant if [Audit](https://kubernetes.io/docs/tasks/debug/debug-cluster/audit/) were also extended to support CEL?
1253-
If so, which should we invest in?
1254-
<<[/UNRESOLVED]>>
1221+
To consider: Would audit support in this enhancement become redundant if
1222+
[Audit](https://kubernetes.io/docs/tasks/debug/debug-cluster/audit/) were also
1223+
extended to support CEL? If so, which should we invest in?
12551224

12561225
Admission webhooks are able to include an associative array of audit annotations
12571226
in a review response. If we intend to provide parity with webhooks we would
@@ -1520,9 +1489,7 @@ spec:
15201489
object.namespaceSelectors[0].namespaceSelector.operator = 'In' &&
15211490
object.namespaceSelectors[0].namespaceSelector.values = ['true']
15221491
message: "The 1st namespaceSelector or ValidatingAdmissionWebhook and MutatingAdmissionWebhooks must be: {key: webhook-restricted, operator: In, values: ['true']}"
1523-
enforcement:
1524-
deny:
1525-
reason: Forbidden
1492+
reason: Forbidden
15261493
```
15271494

15281495
This approach would pair well with a admission mutation that adds the rule to
@@ -1550,17 +1517,11 @@ spec:
15501517
match: ...
15511518
validations:
15521519
- expression: "!(params.enforceLevel > 2) || <cel expression>"
1553-
enforcement:
1554-
deny:
1555-
reason: Invalid
1520+
reason: Invalid
15561521
- expression: "!(params.enforceLevel > 1) || <cel expression>"
1557-
enforcement:
1558-
deny:
1559-
reason: Invalid
1522+
reason: Invalid
15601523
- expression: "<cel expression>"
1561-
enforcement:
1562-
deny:
1563-
reason: Invalid
1524+
reason: Invalid
15641525
```
15651526

15661527

0 commit comments

Comments
 (0)