Skip to content

Commit da481d5

Browse files
committed
Apply feedback
1 parent 21cade5 commit da481d5

File tree

1 file changed

+38
-31
lines changed
  • keps/sig-api-machinery/3488-cel-admission-control

1 file changed

+38
-31
lines changed

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

Lines changed: 38 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,21 +1024,9 @@ this enhancement.
10241024

10251025
#### Enforcement Actions
10261026

1027-
For parity with admission webhooks, a validating policy may also emit audit
1028-
annotations and warnings:
1029-
1030-
- [Audit
1027+
`ValidatingAdmissionPolicy` may declare [Audit
10311028
annotations](https://github.com/kubernetes/kubernetes/blob/97bbf07d3f3f20332912ee411fdf75ce84425e28/staging/src/k8s.io/api/admission/v1/types.go#L142)
1032-
are key/value pairs included in the audit event for an admission request. The
1033-
audit annotation key supplied by the policy definition author will be prefixed
1034-
with the name of the `ValidatingAdmissionPolicy` and policy binding, e.g.:
1035-
`mypolicy.mygroup.example.com/mybinding.mygroup.example.com/<annotation-key>`.
1036-
- [Warnings](https://kubernetes.io/blog/2020/09/03/warnings/#admission-webhooks)
1037-
are string messages that are returned to API clients. Warning are returned for
1038-
both requests that are accepted and requests that are rejected.
1039-
1040-
`ValidatingAdmissionPolicy` may declare audit annotations in the policy
1041-
definition. E.g.:
1029+
in the policy definition. E.g.:
10421030

10431031
```yaml
10441032
apiVersion: admissionregistration.k8s.io/v1alpha1
@@ -1049,39 +1037,50 @@ spec:
10491037
validations:
10501038
- expression: <expression>
10511039
auditAnnotations:
1052-
- includeWhen: <expression> # optional field
1053-
key: "my-audit-key"
1040+
- key: "my-audit-key"
10541041
valueExpression: <expression that evaluates to a string>
10551042
```
10561043

1057-
Additionally, `ValidatingAdmissionPolicyBinding` resource may control how
1058-
admission is enforced. This is performed using a single field. E.g.:
1044+
The published annotation key will be of the form `<ValidatingPolicyDefinition
1045+
name>/<auditAnnotation key>` and will be validated as a
1046+
[QualifiedName]https://github.com/kubernetes/kubernetes/blob/dfa4143086bf504c6c72d5eee8a2210b8ed41b9a/staging/src/k8s.io/apimachinery/pkg/util/validation/validation.go#L43).
1047+
1048+
The validation rule will be: `len(key) < QualifierName.maxLength - len(policy
1049+
name) - 1` to accommodate the `<ValidatingPolicyDefinition
1050+
name>/<auditAnnotation key>` audit annotation key format.
1051+
1052+
If `valueExpression` returns a string, the audit annotation is published. If
1053+
`valueExpression` returns null, the audit annotation is omitted. No other return
1054+
types will be supported.
1055+
1056+
`ValidatingAdmissionPolicyBinding` resources may control how admission is
1057+
enforced. This is performed using a single field. E.g.:
10591058

10601059
```yaml
10611060
apiVersion: admissionregistration.k8s.io/v1alpha1
10621061
kind: ValidatingAdmissionPolicyBinding
10631062
...
10641063
spec:
1065-
enforcement: warn # optional field
1064+
validationActions: [warn, audit] # optional field
10661065
```
10671066

1067+
The enum options will be:
1068+
10681069
- `deny`: Validation failures result in a denied request. (default beahvior if
10691070
field is unset)
1070-
- `warn`: Validation failures are reported as warnings to the client.
1071-
- `silent`: Validation failures are not reported to clients. Audit annotations
1072-
for any failed validations are still included in audit events (see
1073-
below).
1074-
- (To disable audit annotations, delete the binding)
1071+
- `warn`: Validation failures are reported as warnings to the client. (xref: [Admisssion Webhook Warnings](https://kubernetes.io/blog/2020/09/03/warnings/#admission-webhooks))
1072+
- `audit`: Validation failures are published as audit events (see below Audit
1073+
Annotations section for details).
10751074

10761075
Systems that need to aggregate validation failures may implement an [audit
10771076
webhook
10781077
backend](https://kubernetes.io/docs/tasks/debug/debug-cluster/audit/#webhook-backend). See
10791078
below "Audit Events" for details.
10801079

1081-
For singleton policies, the enforcement field will be set on the policy definition.
1080+
For singleton policies, the `validationActions` field will be set on the policy definition.
10821081

1083-
Metrics will include enforcement so that cluster administrators can monitor the
1084-
validation failures of a binding before setting enforcement to `deny`.
1082+
Metrics will include validation action so that cluster administrators can monitor the
1083+
validation failures of a binding before setting `validationActions` to `deny`.
10851084

10861085
Supported use cases:
10871086

@@ -1102,10 +1101,18 @@ Supported use cases:
11021101
enforcement point, higher level constructs can map to this enforcement point
11031102
as needed.
11041103

1104+
1105+
Future work:
1106+
1107+
ValidatingAdmissionPolicy resources might, in the future, add a `warnings` field
1108+
adjacent to the `validations` and `auditAnnotations` fields to declare
1109+
expressions only ever result in warnings. This would allow
1110+
ValidatingAdmissionPolicy authors to declare a expression as non-enforcing
1111+
regardless of `validationActions`.
1112+
11051113
#### Audit Events
11061114

1107-
All audit event keys are prefixed by
1108-
`<ValidatingPolicyDefinition name>/<ValidatingPolicyDefinitionBinding name>/`.
1115+
All audit event keys are prefixed by `<ValidatingPolicyDefinition name>/`.
11091116

11101117
At Metadata audit level or higher, when a validating admission binding fails any
11111118
validation expression, details are included in the audit annotations
@@ -1117,7 +1124,7 @@ for the audit event under the key `validation_failures`. E.g.:
11171124
"kind": "Event",
11181125
"apiVersion": "audit.k8s.io/v1",
11191126
"annotations": {
1120-
"mypolicy.mygroup.example.com/mybinding.mygroup.example.com/validation_failure": "{\"expression\": 1, \"message\": \"x must be greater than y\", \"enforcement\": \"deny\"}"
1127+
"mypolicy.mygroup.example.com/validation_failure": "{\"expression\": 1, \"message\": \"x must be greater than y\", \"enforcement\": \"deny\", \"binding\": \"mybinding.mygroup.example.com\"}"
11211128
# other annotations
11221129
...
11231130
}
@@ -1135,7 +1142,7 @@ are included with the key provided. E.g.:
11351142
"kind": "Event",
11361143
"apiVersion": "audit.k8s.io/v1",
11371144
"annotations": {
1138-
"mypolicy.mygroup.example.com/mybinding.mygroup.example.com/myauditkey": "my audit value"
1145+
"mypolicy.mygroup.example.com/myauditkey": "my audit value"
11391146
# other annotations
11401147
...
11411148
}

0 commit comments

Comments
 (0)