Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MutatingAdmissionPolicy implementation #123332

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

alexzielenski
Copy link
Contributor

@alexzielenski alexzielenski commented Feb 16, 2024

What type of PR is this?

/kind feature

What this PR does / why we need it:

Implmentation of mutating admission policy with major missing features:

  1. API types (@cici37)
  2. Generation of patch from CEL (@jiahuif)
  3. SSA patch application
  4. Reinvocation
  5. Unit Tests
  6. Integration Tests
  7. Feature gate
  8. Plugin Wiring

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

/cc @cici37
/cc @jiahuif

Does this PR introduce a user-facing change?

NONE

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


@k8s-ci-robot k8s-ci-robot added the release-note-none Denotes a PR that doesn't merit a release note. label Feb 16, 2024
@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. kind/feature Categorizes issue or PR as related to a new feature. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. area/apiserver sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. approved Indicates a PR has been approved by an approver from all required OWNERS files. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Feb 16, 2024
@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Feb 16, 2024
@alexzielenski alexzielenski force-pushed the apiserver/policy/mutating-fw-imp branch 2 times, most recently from b35e987 to fc84831 Compare February 20, 2024 18:09
@k8s-ci-robot k8s-ci-robot removed the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 21, 2024
cici37 and others added 2 commits February 21, 2024 08:00
need this to know when to invalidate the cache
to be used by mutating dispatcher
@alexzielenski alexzielenski force-pushed the apiserver/policy/mutating-fw-imp branch 3 times, most recently from f9e04db to ff6a155 Compare February 26, 2024 23:25
and account for the fact we will need separate evaluator for each mutation to handle reinvocation
@alexzielenski alexzielenski force-pushed the apiserver/policy/mutating-fw-imp branch 2 times, most recently from ce34c1e to 327983a Compare February 28, 2024 01:02
// ParamKind specifies the kind of resources used to parameterize this policy.
// If absent, there are no parameters for this policy and the param CEL variable will not be provided to validation expressions.
// If ParamKind refers to a non-existent kind, this policy definition is mis-configured and the FailurePolicy is applied.
// If paramKind is specified but paramRef is unset in ValidatingAdmissionPolicyBinding, the params variable will be null.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// If paramKind is specified but paramRef is unset in ValidatingAdmissionPolicyBinding, the params variable will be null.
// If paramKind is specified but paramRef is unset in MutatingAdmissionPolicyBinding, the params variable will be null.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review. Updated :)

MatchConstraints *MatchResources

// Mutations contain CEL expressions which is used to apply the mutation.
// Mutations may be empty; a minimum of one Mutations is required.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

may not be?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

// * mutations that use this option may be reordered to minimize the number of additional invocations.
// * to validate an object after all mutations are guaranteed complete, use a validating admission policy instead.
//
// Defaults to "Never".
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to default to IfNeeded so that by default every check will be able to see mutations made by other admission plugins.

alexzielenski and others added 6 commits February 28, 2024 15:12
and resolve linter issues

This makes it more clear how we handle errors for policy plugins. Two types of errors: policy errors, and internal error. Internal error raises internal k8s status immediately and aborts operation. Policy error is handled according to the failure policy of the policy raising the error.
* WIP compilation.

* compile during creation not invocation.
@alexzielenski alexzielenski changed the title [WIP] MutatingAdmissionPolicy implementation MutatingAdmissionPolicy implementation Feb 29, 2024
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Feb 29, 2024
@k8s-triage-robot
Copy link

This PR may require API review.

If so, when the changes are ready, complete the pre-review checklist and request an API review.

Status of requested reviews is tracked in the API Review project.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 2, 2024
@jiahuif jiahuif force-pushed the apiserver/policy/mutating-fw-imp branch from 8e5bb14 to baba3f9 Compare March 4, 2024 18:42
@jiahuif
Copy link
Member

jiahuif commented Mar 4, 2024

re-based due to introduction of workspace.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: alexzielenski
Once this PR has been reviewed and has the lgtm label, please assign deads2k for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 4, 2024
@k8s-ci-robot
Copy link
Contributor

PR needs rebase.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 5, 2024
@leilajal
Copy link
Contributor

/triage accepted

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Mar 26, 2024
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +k8s:prerelease-lifecycle-gen:introduced=1.30
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

today,it's 1.31

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/apiserver area/code-generation area/test cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API kind/feature Categorizes issue or PR as related to a new feature. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. release-note-none Denotes a PR that doesn't merit a release note. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/testing Categorizes an issue or PR as relevant to SIG Testing. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants