Skip to content

Commit 45cd6fb

Browse files
committed
Address feedback
1 parent c408bc8 commit 45cd6fb

File tree

1 file changed

+31
-18
lines changed
  • keps/sig-api-machinery/3716-webhook-predicates

1 file changed

+31
-18
lines changed

keps/sig-api-machinery/3716-webhook-predicates/README.md

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# KEP-3716: Webhook Predicates
1+
# KEP-3716: Admission Webhook Predicates
22

33
<!-- toc -->
44
- [Release Signoff Checklist](#release-signoff-checklist)
@@ -35,6 +35,7 @@
3535
- [Implementation History](#implementation-history)
3636
- [Drawbacks](#drawbacks)
3737
- [Alternatives](#alternatives)
38+
- [Exclusion Expressions](#exclusion-expressions)
3839
- [Resource Exclusions](#resource-exclusions)
3940
- [CEL Admission Control](#cel-admission-control)
4041
<!-- /toc -->
@@ -90,6 +91,12 @@ avoid circular-dependencies and exclude critical system resources, a webhook out
9091
major impact on cluster availability. This proposal aims to mitigate (but not eliminate) these
9192
issues by allowing webhooks to be more narrowly scoped and targeted.
9293

94+
95+
The same benefits also apply to bootstrapping a new cluster, or in a disaster-recovery scenario
96+
where objects in a cluster need to be recreated from source code. Being able to define and deploy a
97+
webhook before any workload Pods are defined means that admins don't need to bypass security
98+
controls to fix things, and helps to ensure there's never a security gap when restoring service.
99+
93100
**Performance:** Admission webhooks sit in the critical request path for write-requests. Validating
94101
webhooks can be run in parallel, but Mutating webhooks must be run in serial (up to 2 times!). This
95102
makes webhooks extremely latency sensitive, and even a webhook that doesn't do any work still needs
@@ -217,6 +224,8 @@ type Predicate struct {
217224
// ref: https://github.com/google/cel-spec
218225
// CEL expressions have access to the contents of the AdmissionRequest, organized into CEL variables:
219226
//
227+
//'object' - The object from the incoming request. The value is null for DELETE requests.
228+
//'oldObject' - The existing object. The value is null for CREATE requests.
220229
//'request' - Attributes of the admission request([ref](/pkg/apis/admission/types.go#AdmissionRequest)).
221230
//
222231
// The `apiVersion`, `kind`, `metadata.name` and `metadata.generateName` are always accessible from the root of the
@@ -233,7 +242,7 @@ type Predicate struct {
233242
// "import", "let", "loop", "package", "namespace", "return".
234243
// Examples:
235244
// - Expression accessing a property named "namespace": {"Expression": "object.__namespace__ > 0"}
236-
// - Expression accessing a property named "x-p
245+
// - Expression accessing a property named "x-prop": {"Expression": "object.x__dash__prop > 0"}
237246
// - Expression accessing a property named "redact__d": {"Expression": "object.redact__underscores__d > 0"}
238247
//
239248
// Equality on arrays with list type of 'set' or 'map' ignores element order, i.e. [1, 2] == [2, 1].
@@ -253,15 +262,6 @@ The predicate expression has access to the contents of the `AdmissionRequest` ob
253262
additional information (such as a paramater object) must be performed in the webhook, and are out of
254263
scope for this proposal.
255264

256-
<<[UNRESOLVED api structure ]>>
257-
Do we need the predicate struct? Or should we just inline it instead? That is:
258-
```go
259-
type ValidatingWebhook struct {
260-
Predicates []string `json:"predicates,omitempty"`
261-
}
262-
```
263-
<<[/UNRESOLVED]>>
264-
265265
### Risks and Mitigations
266266

267267
#### Security
@@ -830,15 +830,28 @@ Why should this KEP _not_ be implemented?
830830

831831
## Alternatives
832832

833+
### Exclusion Expressions
834+
835+
The `predicate` expression could be inverted, so that requests that match are excluded rather than
836+
included. In this case, we would probably also want to change from requiring all expressions to
837+
match, to excluding the request if any match.
838+
839+
Although this approach would simplify some usecases, such as
840+
[excluding resources from a wildcard rule](#exclude-resources-from-a-wildcard-rule) or
841+
[exempting system users from a security policy](#exempt-system-users-from-security-policy), it
842+
means other expressions would become double-negatives, which generally goes against API design
843+
best-practices.
844+
833845
### Resource Exclusions
834846

835-
https://github.com/kubernetes/enhancements/pull/3694 Proposes an alternative approach using a more
836-
structured format for expressing resource exclusions. This approach may be more approachable to
837-
users who are not comfortable writing CEL expressions, but it is significantly less powerful.
838-
This would address [Exclude resources from a wildcard rule](#exclude-resources-from-a-wildcard-rule),
839-
and could be extended with subject exclusions to address
840-
[Exempt system users from security policy](#exempt-system-users-from-security-policy),
841-
but would not be sufficient to address
847+
[KEP-3693](https://github.com/kubernetes/enhancements/issues/3693) Proposes an alternative approach
848+
using a more structured format for expressing resource exclusions. This approach may be more
849+
approachable to users who are not comfortable writing CEL expressions, but it is significantly less
850+
powerful. This would address
851+
[Exclude resources from a wildcard rule](#exclude-resources-from-a-wildcard-rule),
852+
and could be extended with subject exclusions to
853+
address [Exempt system users from security policy](#exempt-system-users-from-security-policy), but
854+
would not be sufficient to address
842855
[Scope an NFS access management webhook to Pods mounting NFS volumes](#scope-an-nfs-access-management-webhook-to-pods-mounting-nfs-volumes).
843856

844857
These two approaches are not mutually exclusive.

0 commit comments

Comments
 (0)