×
Description

MutatingAdmissionPolicyBinding binds the MutatingAdmissionPolicy with parametrized resources. MutatingAdmissionPolicyBinding and the optional parameter resource together define how cluster administrators configure policies for clusters.

For a given admission request, each binding will cause its policy to be evaluated N times, where N is 1 for policies/bindings that don’t use params, otherwise N is the number of parameters selected by the binding. Each evaluation is constrained by a [runtime cost budget](https://kubernetes.io/docs/reference/using-api/cel/#runtime-cost-budget).

Adding/removing policies, bindings, or params can not affect whether a given (policy, binding, param) combination is within its own CEL budget.

Type

object

Specification

Property Type Description

apiVersion

string

APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources

kind

string

Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds

metadata

ObjectMeta

metadata is the standard object metadata; More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata.

spec

object

MutatingAdmissionPolicyBindingSpec defines the specification of the MutatingAdmissionPolicyBinding.

.spec

Description

MutatingAdmissionPolicyBindingSpec defines the specification of the MutatingAdmissionPolicyBinding.

Type

object

Property Type Description

matchResources

object

MatchResources decides whether to run the admission control policy on an object based on whether it meets the match criteria. The exclude rules take precedence over include rules (if a resource matches both, it is excluded)

paramRef

object

ParamRef describes how to locate the params to be used as input to expressions of rules applied by a policy binding.

policyName

string

policyName references a MutatingAdmissionPolicy name which the MutatingAdmissionPolicyBinding binds to. If the referenced resource does not exist, this binding is considered invalid and will be ignored Required.

.spec.matchResources

Description

MatchResources decides whether to run the admission control policy on an object based on whether it meets the match criteria. The exclude rules take precedence over include rules (if a resource matches both, it is excluded)

Type

object

Property Type Description

excludeResourceRules

array

excludeResourceRules describes what operations on what resources/subresources the ValidatingAdmissionPolicy should not care about. The exclude rules take precedence over include rules (if a resource matches both, it is excluded)

excludeResourceRules[]

object

NamedRuleWithOperations is a tuple of Operations and Resources with ResourceNames.

matchPolicy

string

matchPolicy defines how the "MatchResources" list is used to match incoming requests. Allowed values are "Exact" or "Equivalent".

- Exact: match a request only if it exactly matches a specified rule. For example, if deployments can be modified via apps/v1, apps/v1beta1, and extensions/v1beta1, but "rules" only included apiGroups:["apps"], apiVersions:["v1"], resources: ["deployments"], a request to apps/v1beta1 or extensions/v1beta1 would not be sent to the ValidatingAdmissionPolicy.

- Equivalent: match a request if modifies a resource listed in rules, even via another API group or version. For example, if deployments can be modified via apps/v1, apps/v1beta1, and extensions/v1beta1, and "rules" only included apiGroups:["apps"], apiVersions:["v1"], resources: ["deployments"], a request to apps/v1beta1 or extensions/v1beta1 would be converted to apps/v1 and sent to the ValidatingAdmissionPolicy.

Defaults to "Equivalent"

Possible enum values: - "Equivalent" means requests should be sent to the webhook if they modify a resource listed in rules via another API group or version. - "Exact" means requests should only be sent to the webhook if they exactly match a given rule.

namespaceSelector

LabelSelector

namespaceSelector decides whether to run the admission control policy on an object based on whether the namespace for that object matches the selector. If the object itself is a namespace, the matching is performed on object.metadata.labels. If the object is another cluster scoped resource, it never skips the policy.

For example, to run the webhook on any objects whose namespace is not associated with "runlevel" of "0" or "1"; you will set the selector as follows: "namespaceSelector": { "matchExpressions": [ { "key": "runlevel", "operator": "NotIn", "values": [ "0", "1" ] } ] }

If instead you want to only run the policy on any objects whose namespace is associated with the "environment" of "prod" or "staging"; you will set the selector as follows: "namespaceSelector": { "matchExpressions": [ { "key": "environment", "operator": "In", "values": [ "prod", "staging" ] } ] }

See https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/ for more examples of label selectors.

Default to the empty LabelSelector, which matches everything.

objectSelector

LabelSelector

objectSelector decides whether to run the validation based on if the object has matching labels. objectSelector is evaluated against both the oldObject and newObject that would be sent to the cel validation, and is considered to match if either object matches the selector. A null object (oldObject in the case of create, or newObject in the case of delete) or an object that cannot have labels (like a DeploymentRollback or a PodProxyOptions object) is not considered to match. Use the object selector only if the webhook is opt-in, because end users may skip the admission webhook by setting the labels. Default to the empty LabelSelector, which matches everything.

resourceRules

array

resourceRules describes what operations on what resources/subresources the ValidatingAdmissionPolicy matches. The policy cares about an operation if it matches any Rule.

resourceRules[]

object

NamedRuleWithOperations is a tuple of Operations and Resources with ResourceNames.

.spec.matchResources.excludeResourceRules

Description

excludeResourceRules describes what operations on what resources/subresources the ValidatingAdmissionPolicy should not care about. The exclude rules take precedence over include rules (if a resource matches both, it is excluded)

Type

array

.spec.matchResources.excludeResourceRules[]

Description

NamedRuleWithOperations is a tuple of Operations and Resources with ResourceNames.

Type

object

Property Type Description

apiGroups

array (string)

apiGroups is the API groups the resources belong to. '' is all groups. If '' is present, the length of the slice must be one. Required.

apiVersions

array (string)

apiVersions is the API versions the resources belong to. '' is all versions. If '' is present, the length of the slice must be one. Required.

operations

array (string)

operations is the operations the admission hook cares about - CREATE, UPDATE, DELETE, CONNECT or * for all of those operations and any future admission operations that are added. If '*' is present, the length of the slice must be one. Required.

resourceNames

array (string)

resourceNames is an optional white list of names that the rule applies to. An empty set means that everything is allowed.

resources

array (string)

resources is a list of resources this rule applies to.

For example: 'pods' means pods. 'pods/log' means the log subresource of pods. '' means all resources, but not subresources. 'pods/' means all subresources of pods. '/scale' means all scale subresources. '/*' means all resources and their subresources.

If wildcard is present, the validation rule will ensure resources do not overlap with each other.

Depending on the enclosing object, subresources might not be allowed. Required.

scope

string

scope specifies the scope of this rule. Valid values are "Cluster", "Namespaced", and "" "Cluster" means that only cluster-scoped resources will match this rule. Namespace API objects are cluster-scoped. "Namespaced" means that only namespaced resources will match this rule. "" means that there are no scope restrictions. Subresources match the scope of their parent resource. Default is "".

Possible enum values: - "" means that all scopes are included. - "Cluster" means that scope is limited to cluster-scoped objects. Namespace objects are cluster-scoped. - "Namespaced" means that scope is limited to namespaced objects.

.spec.matchResources.resourceRules

Description

resourceRules describes what operations on what resources/subresources the ValidatingAdmissionPolicy matches. The policy cares about an operation if it matches any Rule.

Type

array

.spec.matchResources.resourceRules[]

Description

NamedRuleWithOperations is a tuple of Operations and Resources with ResourceNames.

Type

object

Property Type Description

apiGroups

array (string)

apiGroups is the API groups the resources belong to. '' is all groups. If '' is present, the length of the slice must be one. Required.

apiVersions

array (string)

apiVersions is the API versions the resources belong to. '' is all versions. If '' is present, the length of the slice must be one. Required.

operations

array (string)

operations is the operations the admission hook cares about - CREATE, UPDATE, DELETE, CONNECT or * for all of those operations and any future admission operations that are added. If '*' is present, the length of the slice must be one. Required.

resourceNames

array (string)

resourceNames is an optional white list of names that the rule applies to. An empty set means that everything is allowed.

resources

array (string)

resources is a list of resources this rule applies to.

For example: 'pods' means pods. 'pods/log' means the log subresource of pods. '' means all resources, but not subresources. 'pods/' means all subresources of pods. '/scale' means all scale subresources. '/*' means all resources and their subresources.

If wildcard is present, the validation rule will ensure resources do not overlap with each other.

Depending on the enclosing object, subresources might not be allowed. Required.

scope

string

scope specifies the scope of this rule. Valid values are "Cluster", "Namespaced", and "" "Cluster" means that only cluster-scoped resources will match this rule. Namespace API objects are cluster-scoped. "Namespaced" means that only namespaced resources will match this rule. "" means that there are no scope restrictions. Subresources match the scope of their parent resource. Default is "".

Possible enum values: - "" means that all scopes are included. - "Cluster" means that scope is limited to cluster-scoped objects. Namespace objects are cluster-scoped. - "Namespaced" means that scope is limited to namespaced objects.

.spec.paramRef

Description

ParamRef describes how to locate the params to be used as input to expressions of rules applied by a policy binding.

Type

object

Property Type Description

name

string

name is the name of the resource being referenced.

One of name or selector must be set, but name and selector are mutually exclusive properties. If one is set, the other must be unset.

A single parameter used for all admission requests can be configured by setting the name field, leaving selector blank, and setting namespace if paramKind is namespace-scoped.

namespace

string

namespace is the namespace of the referenced resource. Allows limiting the search for params to a specific namespace. Applies to both name and selector fields.

A per-namespace parameter may be used by specifying a namespace-scoped paramKind in the policy and leaving this field empty.

- If paramKind is cluster-scoped, this field MUST be unset. Setting this field results in a configuration error.

- If paramKind is namespace-scoped, the namespace of the object being evaluated for admission will be used when this field is left unset. Take care that if this is left empty the binding must not match any cluster-scoped resources, which will result in an error.

parameterNotFoundAction

string

parameterNotFoundAction controls the behavior of the binding when the resource exists, and name or selector is valid, but there are no parameters matched by the binding. If the value is set to Allow, then no matched parameters will be treated as successful validation by the binding. If set to Deny, then no matched parameters will be subject to the failurePolicy of the policy.

Allowed values are Allow or Deny

Required

selector

LabelSelector

selector can be used to match multiple param objects based on their labels. Supply selector: {} to match all resources of the ParamKind.

If multiple params are found, they are all evaluated with the policy expressions and the results are ANDed together.

One of name or selector must be set, but name and selector are mutually exclusive properties. If one is set, the other must be unset.

API endpoints

The following API endpoints are available:

  • /apis/admissionregistration.k8s.io/v1/mutatingadmissionpolicybindings

    • DELETE: delete collection of MutatingAdmissionPolicyBinding

    • GET: list or watch objects of kind MutatingAdmissionPolicyBinding

    • POST: create a MutatingAdmissionPolicyBinding

  • /apis/admissionregistration.k8s.io/v1/watch/mutatingadmissionpolicybindings

    • GET: watch individual changes to a list of MutatingAdmissionPolicyBinding. deprecated: use the 'watch' parameter with a list operation instead.

  • /apis/admissionregistration.k8s.io/v1/mutatingadmissionpolicybindings/{name}

    • DELETE: delete a MutatingAdmissionPolicyBinding

    • GET: read the specified MutatingAdmissionPolicyBinding

    • PATCH: partially update the specified MutatingAdmissionPolicyBinding

    • PUT: replace the specified MutatingAdmissionPolicyBinding

  • /apis/admissionregistration.k8s.io/v1/watch/mutatingadmissionpolicybindings/{name}

    • GET: watch changes to an object of kind MutatingAdmissionPolicyBinding. deprecated: use the 'watch' parameter with a list operation instead, filtered to a single item with the 'fieldSelector' parameter.

/apis/admissionregistration.k8s.io/v1/mutatingadmissionpolicybindings

HTTP method

DELETE

Description

delete collection of MutatingAdmissionPolicyBinding

Table 1. Query parameters
Parameter Type Description

dryRun

string

When present, indicates that modifications should not be persisted. An invalid or unrecognized dryRun directive will result in an error response and no further processing of the request. Valid values are: - All: all dry run stages will be processed

Table 2. HTTP responses
HTTP code Reponse body

200 - OK

Status schema

401 - Unauthorized

Empty

HTTP method

GET

Description

list or watch objects of kind MutatingAdmissionPolicyBinding

Table 3. HTTP responses
HTTP code Reponse body

200 - OK

MutatingAdmissionPolicyBindingList schema

401 - Unauthorized

Empty

HTTP method

POST

Description

create a MutatingAdmissionPolicyBinding

Table 4. Query parameters
Parameter Type Description

dryRun

string

When present, indicates that modifications should not be persisted. An invalid or unrecognized dryRun directive will result in an error response and no further processing of the request. Valid values are: - All: all dry run stages will be processed

fieldValidation

string

fieldValidation instructs the server on how to handle objects in the request (POST/PUT/PATCH) containing unknown or duplicate fields. Valid values are: - Ignore: This will ignore any unknown fields that are silently dropped from the object, and will ignore all but the last duplicate field that the decoder encounters. This is the default behavior prior to v1.23. - Warn: This will send a warning via the standard warning response header for each unknown field that is dropped from the object, and for each duplicate field that is encountered. The request will still succeed if there are no other errors, and will only persist the last of any duplicate fields. This is the default in v1.23+ - Strict: This will fail the request with a BadRequest error if any unknown fields would be dropped from the object, or if any duplicate fields are present. The error returned from the server will contain all unknown and duplicate fields encountered.

Table 5. Body parameters
Parameter Type Description

body

MutatingAdmissionPolicyBinding schema

Table 6. HTTP responses
HTTP code Reponse body

200 - OK

MutatingAdmissionPolicyBinding schema

201 - Created

MutatingAdmissionPolicyBinding schema

202 - Accepted

MutatingAdmissionPolicyBinding schema

401 - Unauthorized

Empty

/apis/admissionregistration.k8s.io/v1/watch/mutatingadmissionpolicybindings

HTTP method

GET

Description

watch individual changes to a list of MutatingAdmissionPolicyBinding. deprecated: use the 'watch' parameter with a list operation instead.

Table 7. HTTP responses
HTTP code Reponse body

200 - OK

WatchEvent schema

401 - Unauthorized

Empty

/apis/admissionregistration.k8s.io/v1/mutatingadmissionpolicybindings/{name}

Table 8. Global path parameters
Parameter Type Description

name

string

name of the MutatingAdmissionPolicyBinding

HTTP method

DELETE

Description

delete a MutatingAdmissionPolicyBinding

Table 9. Query parameters
Parameter Type Description

dryRun

string

When present, indicates that modifications should not be persisted. An invalid or unrecognized dryRun directive will result in an error response and no further processing of the request. Valid values are: - All: all dry run stages will be processed

Table 10. HTTP responses
HTTP code Reponse body

200 - OK

Status schema

202 - Accepted

Status schema

401 - Unauthorized

Empty

HTTP method

GET

Description

read the specified MutatingAdmissionPolicyBinding

Table 11. HTTP responses
HTTP code Reponse body

200 - OK

MutatingAdmissionPolicyBinding schema

401 - Unauthorized

Empty

HTTP method

PATCH

Description

partially update the specified MutatingAdmissionPolicyBinding

Table 12. Query parameters
Parameter Type Description

dryRun

string

When present, indicates that modifications should not be persisted. An invalid or unrecognized dryRun directive will result in an error response and no further processing of the request. Valid values are: - All: all dry run stages will be processed

fieldValidation

string

fieldValidation instructs the server on how to handle objects in the request (POST/PUT/PATCH) containing unknown or duplicate fields. Valid values are: - Ignore: This will ignore any unknown fields that are silently dropped from the object, and will ignore all but the last duplicate field that the decoder encounters. This is the default behavior prior to v1.23. - Warn: This will send a warning via the standard warning response header for each unknown field that is dropped from the object, and for each duplicate field that is encountered. The request will still succeed if there are no other errors, and will only persist the last of any duplicate fields. This is the default in v1.23+ - Strict: This will fail the request with a BadRequest error if any unknown fields would be dropped from the object, or if any duplicate fields are present. The error returned from the server will contain all unknown and duplicate fields encountered.

Table 13. HTTP responses
HTTP code Reponse body

200 - OK

MutatingAdmissionPolicyBinding schema

201 - Created

MutatingAdmissionPolicyBinding schema

401 - Unauthorized

Empty

HTTP method

PUT

Description

replace the specified MutatingAdmissionPolicyBinding

Table 14. Query parameters
Parameter Type Description

dryRun

string

When present, indicates that modifications should not be persisted. An invalid or unrecognized dryRun directive will result in an error response and no further processing of the request. Valid values are: - All: all dry run stages will be processed

fieldValidation

string

fieldValidation instructs the server on how to handle objects in the request (POST/PUT/PATCH) containing unknown or duplicate fields. Valid values are: - Ignore: This will ignore any unknown fields that are silently dropped from the object, and will ignore all but the last duplicate field that the decoder encounters. This is the default behavior prior to v1.23. - Warn: This will send a warning via the standard warning response header for each unknown field that is dropped from the object, and for each duplicate field that is encountered. The request will still succeed if there are no other errors, and will only persist the last of any duplicate fields. This is the default in v1.23+ - Strict: This will fail the request with a BadRequest error if any unknown fields would be dropped from the object, or if any duplicate fields are present. The error returned from the server will contain all unknown and duplicate fields encountered.

Table 15. Body parameters
Parameter Type Description

body

MutatingAdmissionPolicyBinding schema

Table 16. HTTP responses
HTTP code Reponse body

200 - OK

MutatingAdmissionPolicyBinding schema

201 - Created

MutatingAdmissionPolicyBinding schema

401 - Unauthorized

Empty

/apis/admissionregistration.k8s.io/v1/watch/mutatingadmissionpolicybindings/{name}

Table 17. Global path parameters
Parameter Type Description

name

string

name of the MutatingAdmissionPolicyBinding

HTTP method

GET

Description

watch changes to an object of kind MutatingAdmissionPolicyBinding. deprecated: use the 'watch' parameter with a list operation instead, filtered to a single item with the 'fieldSelector' parameter.

Table 18. HTTP responses
HTTP code Reponse body

200 - OK

WatchEvent schema

401 - Unauthorized

Empty