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
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.:
1042
-
1043
-
```yaml
1044
-
apiVersion: admissionregistration.k8s.io/v1alpha1
1045
-
kind: ValidatingAdmissionPolicy
1046
-
...
1047
-
spec:
1048
-
...
1049
-
validations:
1050
-
- expression: <expression>
1051
-
auditAnnotations:
1052
-
- includeWhen: <expression> # optional field
1053
-
key: "my-audit-key"
1054
-
valueExpression: <expression that evaluates to a string>
1055
-
```
1056
-
1057
-
Additionally, `ValidatingAdmissionPolicyBinding` resource may control how
1058
-
admission is enforced. This is performed using a single field. E.g.:
1028
+
`ValidatingAdmissionPolicyBinding`resources may control how admission is
1029
+
enforced. This is performed using a single field. E.g.:
1059
1030
1060
1031
```yaml
1061
1032
apiVersion: admissionregistration.k8s.io/v1alpha1
1062
1033
kind: ValidatingAdmissionPolicyBinding
1063
1034
...
1064
1035
spec:
1065
-
enforcement: warn # optional field
1036
+
validationActions: [warn, audit] # optional field
1066
1037
```
1067
1038
1039
+
The enum options will be:
1040
+
1068
1041
- `deny`: Validation failures result in a denied request. (default beahvior if
1069
1042
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)
1043
+
- `warn`: Validation failures are reported as warnings to the client. (xref: [Admisssion Webhook Warnings](https://kubernetes.io/blog/2020/09/03/warnings/#admission-webhooks))
1044
+
- `audit`: Validation failures are published as audit events (see below Audit
1045
+
Annotations section for details).
1075
1046
1076
1047
Systems that need to aggregate validation failures may implement an [audit
1077
1048
webhook
1078
1049
backend](https://kubernetes.io/docs/tasks/debug/debug-cluster/audit/#webhook-backend). See
1079
1050
below "Audit Events" for details.
1080
1051
1081
-
For singleton policies, the enforcement field will be set on the policy definition.
1052
+
For singleton policies, the `validationActions` field will be set on the policy definition.
1082
1053
1083
-
Metrics will include enforcement so that cluster administrators can monitor the
1084
-
validation failures of a binding before setting enforcement to `deny`.
1054
+
Metrics will include validation action so that cluster administrators can monitor the
1055
+
validation failures of a binding before setting `validationActions` to `deny`.
1085
1056
1086
-
Supported use cases:
1057
+
This enables the following use cases:
1087
1058
1088
1059
- A policy framework captures enforcement violations during dry run and
1089
1060
aggregates them. (E.g. When in DryRun mode, OPA Gatekeeper aggregates
@@ -1094,18 +1065,56 @@ Supported use cases:
1094
1065
knowing all the details of the policies. During rollout the cluster admin
1095
1066
needs a state where the policies being rolled out cannot result in admission
1096
1067
rejection. With the enforcement field on bindings, cluster admins can decide
1097
-
between `silent` and `warn` as the initial state and then transition through
1098
-
the states until the binding reaches `deny`, monitoring metricsand audit
1099
-
events along the way.
1068
+
which initial actions to enable and then add actions until `deny` is enabled.
1069
+
The cluster admin may monitoring metrics, warnings and audit events along the
1070
+
way.
1100
1071
- A policy framework needs different enforcement actions at different
1101
1072
enforcement points. Since this API defines the behavior of only the admission
1102
-
enforcement point, higher level constructs can map to this enforcement point
1103
-
as needed.
1073
+
enforcement point, higher level constructs can map to the actions of this
1074
+
enforcement point as needed.
1075
+
1076
+
Future work:
1077
+
1078
+
ValidatingAdmissionPolicy resources might, in the future, add a `warnings` field
1079
+
adjacent to the `validations` and `auditAnnotations` fields to declare
1080
+
expressions only ever result in warnings. This would allow
1081
+
ValidatingAdmissionPolicy authors to declare a expression as non-enforcing
All audit event keys are prefixed by `<ValidatingPolicyDefinition name>/`.
1109
1118
1110
1119
At Metadata audit level or higher, when a validating admission binding fails any
1111
1120
validation expression, details are included in the audit annotations
@@ -1117,7 +1126,7 @@ for the audit event under the key `validation_failures`. E.g.:
1117
1126
"kind": "Event",
1118
1127
"apiVersion": "audit.k8s.io/v1",
1119
1128
"annotations": {
1120
-
"mypolicy.mygroup.example.com/mybinding.mygroup.example.com/validation_failure": "{\"expression\": 1, \"message\": \"x must be greater than y\", \"enforcement\": \"deny\"}"
1129
+
"mypolicy.mygroup.example.com/validation_failure": "{\"expression\": 1, \"message\": \"x must be greater than y\", \"enforcement\": \"deny\", \"binding\": \"mybinding.mygroup.example.com\"}"
1121
1130
# other annotations
1122
1131
...
1123
1132
}
@@ -1135,7 +1144,7 @@ are included with the key provided. E.g.:
1135
1144
"kind": "Event",
1136
1145
"apiVersion": "audit.k8s.io/v1",
1137
1146
"annotations": {
1138
-
"mypolicy.mygroup.example.com/mybinding.mygroup.example.com/myauditkey": "my audit value"
1147
+
"mypolicy.mygroup.example.com/myauditkey": "my audit value"
0 commit comments