Skip to content

Commit f8e1821

Browse files
committed
updates after 1.26 release.
1 parent 7556fd1 commit f8e1821

File tree

1 file changed

+40
-36
lines changed
  • keps/sig-api-machinery/3488-cel-admission-control

1 file changed

+40
-36
lines changed

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

Lines changed: 40 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -359,8 +359,8 @@ This API separates policy _definition_ from policy _configuration_ by splitting
359359
responsibilities across resources. The resources involved are:
360360

361361
- Policy definitions (ValidatingAdmissionPolicy)
362-
- Policy bindings (PolicyBinding)
363-
- Policy param resources (custom resources)
362+
- Policy bindings (ValidatingAdmissionPolicyBinding)
363+
- Policy param resources (custom resources or config maps)
364364

365365
![Relatinships between policy resources](erd.png)
366366

@@ -394,7 +394,7 @@ kind: ValidatingAdmissionPolicy
394394
metadata:
395395
name: "replicalimit-policy.example.com"
396396
spec:
397-
paramSource:
397+
paramKind:
398398
group: rules.example.com
399399
kind: ReplicaLimit
400400
version: v1
@@ -412,7 +412,7 @@ spec:
412412
# ...other rule related fields here...
413413
```
414414

415-
The `spec.paramSource` field of the `ValidatingAdmissionPolicy` specifies the
415+
The `spec.paramKind` field of the `ValidatingAdmissionPolicy` specifies the
416416
kind of resources used to parameterize this policy. For this example, it is
417417
configured by `ReplicaLimit` custom resources. Note in this example how the CEL
418418
expression references to the parameters via the CEL `params` variable, e.g.
@@ -434,13 +434,15 @@ resource are created. For example:
434434

435435
```yaml
436436
# Policy binding
437-
apiVersion: admissionregistration.k8s.io/v1
438-
kind: PolicyBinding
437+
apiVersion: admissionregistration.k8s.io/v1alpha1
438+
kind: ValidatingAdmissionPolicyBinding
439439
metadata:
440440
name: "replicalimit-binding-test.example.com"
441441
spec:
442-
policy: "replicalimit-policy.example.com"
443-
params: "replica-limit-test.example.com"
442+
policyName: "replicalimit-policy.example.com"
443+
paramRef:
444+
name: "replica-limit-test.example.com"
445+
namespace: "default"
444446
matchResources:
445447
namespaceSelectors:
446448
- key: environment,
@@ -464,13 +466,15 @@ An admission policy may have multiple bindings. To bind all other environments
464466
environment to have a maxReplicas limit of 100, create another `PolicyBinding`:
465467

466468
```yaml
467-
apiVersion: admissionregistration.k8s.io/v1
468-
kind: PolicyBinding
469+
apiVersion: aadmissionregistration.k8s.io/v1alpha1
470+
kind: ValidatingAdmissionPolicyBinding
469471
metadata:
470472
name: "replicalimit-binding-nontest"
471473
spec:
472-
policy: "replicalimit-policy.example.com"
473-
params: "replica-limit-clusterwide.example.com"
474+
policyName: "replicalimit-policy.example.com"
475+
paramRef:
476+
name: "replica-limit-test.example.com"
477+
namespace: "default"
474478
matchResources:
475479
namespaceSelectors:
476480
- key: environment,
@@ -491,13 +495,14 @@ matching binding. In the above example, the "nontest" policy binding could
491495
instead have been defined as a global policy:
492496

493497
```yaml
494-
apiVersion: admissionregistration.k8s.io/v1
495-
kind: PolicyBinding
498+
apiVersion: aadmissionregistration.k8s.io/v1alpha1
499+
kind: ValidatingAdmissionPolicyBinding
496500
metadata:
497501
name: "replicalimit-binding-global"
498502
spec:
499-
policy: "replicalimit-policy.example.com"
500-
params: "replica-limit-clusterwide.example.com"
503+
policyName: "replicalimit-policy.example.com"
504+
paramRef:
505+
name: replica-limit-clusterwide.example.com"
501506
matchResources:
502507
namespaceSelectors:
503508
- key: environment,
@@ -534,7 +539,7 @@ organized into CEL variables as well as some other useful variables:
534539

535540
- 'object'
536541
- 'oldObject'
537-
- 'review'
542+
- 'request'
538543
- 'requestResource' (GVR)
539544
- 'resource' (GVR)
540545
- 'name'
@@ -543,35 +548,35 @@ organized into CEL variables as well as some other useful variables:
543548
- 'userInfo'
544549
- 'dryRun'
545550
- 'options'
546-
- 'config' - configuration data of the policy configuration being validated
551+
- 'params' - referred params object, maybe null if no object is referred
547552

548553
See below "Decisions and Enforcement" for more detail about how the
549554
`spec.validations` field works and how violations are reported.
550555

551556
##### Policy Configuration
552557

553-
`PolicyBinding` resources and parameter CRDs together define how cluster
558+
`ValidatingAdmissionPolicyBinding` resources and parameter CRDs together define how cluster
554559
administrators configure policies for clusters.
555560

556-
Each `PolicyBinding` contains:
561+
Each `ValidatingAdmissionPolicyBinding` contains:
557562

558-
- `spec.policy` - A reference to the policy being configured
563+
- `spec.policyName` - A reference to the policy being configured
559564
- `spec.matchResources` - Match criteria for which resources the policy should
560565
validate
561-
- `spec.params` - Reference to the custom resource containing the params to use
566+
- `spec.paramKind` - Reference to the custom resource containing the params to use
562567
when validating resources
563-
- `spec.mode` - See "Decisions and Enforcement" for details.
564568

565569
Example:
566570

567571
```yaml
568-
apiVersion: admissionregistration.k8s.io/v1
569-
kind: PolicyBinding
572+
apiVersion: aadmissionregistration.k8s.io/v1alpha1
573+
kind: ValidatingAdmissionPolicyBinding
570574
metadata:
571575
name: "xyzlimit-scale.example.com"
572576
spec:
573-
policy: xyzlimit-scale.example.com
574-
params: xyzlimit-scale-settings.example.com
577+
policyName: xyzlimit-scale.example.com
578+
paramRef:
579+
name: xyzlimit-scale-settings.example.com
575580
matchResources:
576581
namespaceSelectors:
577582
- key: environment,
@@ -962,8 +967,8 @@ higher level. This could be added later.
962967

963968
#### Singleton Policies
964969

965-
For simple policies that apply cluster wide, a policy can be authored using a
966-
single `ValidatingAdmissionPolicy` resource.
970+
For simple policies that does not refer to a param, a policy can be authored using a
971+
single `ValidatingAdmissionPolicy` resource without a `paramKind` field.
967972

968973
This is only available for cases where there is no need to have multiple
969974
bindings, and where all params can be inlined in CEL.
@@ -975,17 +980,16 @@ apiVersion: admissionregistration.k8s.io/v1
975980
kind: ValidatingAdmissionPolicy
976981
...
977982
spec:
983+
# no paramKind
978984
matchConstraints: ...
979985
validations:
980986
- expression: "object.spec.replicas < 100"
981-
singletonBinding:
982-
matchResources: ...
983987
```
984988

985989
Note that:
986990

987-
- `spec.paramSource` must be absent and validations may not reference `params`
988-
- If `spec.singletonBinding` is present policy binding support is disabled.
991+
- `spec.paramKind` must be absent
992+
- validation expressions may not refer `params`
989993

990994
Safety features:
991995

@@ -1536,7 +1540,7 @@ Steps:
15361540

15371541
1. Webhook is configured and in-use.
15381542
2. `ValidatingAdmissionPolicy` created with `FailPolicy: Ignore`
1539-
3. `ValidatingAdmissionPolicy` is monitored to ensure it behaves the same as te webhook (logs or audit annotations can be used)
1543+
3. `ValidatingAdmissionPolicy` is monitored to ensure it behaves the same as the webhook (logs or audit annotations can be used)
15401544
4. `ValidatingAdmissionPolicy` is updated to `FailPolicy: Fail`
15411545
5. Verify the webhook never denies any requests. If the admission policy is
15421546
equivalent, then policy will be run first and deny the request before
@@ -1716,7 +1720,7 @@ metadata:
17161720
generation: 2
17171721
...
17181722
status:
1719-
paramSource:
1723+
paramKind:
17201724
apiVersion: "example.com/v1"
17211725
kind: "fooLimits"
17221726
generation: 5
@@ -2475,7 +2479,7 @@ kind: ValidatingAdmissionPolicy
24752479
metadata:
24762480
name: "validate-xyz.example.com"
24772481
spec:
2478-
paramSource:
2482+
paramKind:
24792483
group: rules.example.com
24802484
kind: ReplicaLimit
24812485
version: v1

0 commit comments

Comments
 (0)