ClusterPolicy declares validation, mutation, and generation behaviors for matching resources.
5 top-level fields, 1 required · last changed in Kyverno v1.3.0
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 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
Spec declares policy behaviors.
Background controls if rules are applied to existing resources during a background scan. Optional. Default value is "true". The value must be set to "false" if the policy rule uses variables that are only available in the admission review request (e.g. user name).
Rules is a list of Rule instances. A Policy contains multiple rules and each rule can validate, mutate, or generate resources.
Context defines variables and data sources that can be used during rule execution.
ConfigMapReference refers to a ConfigMap
ExcludeResources defines when this policy rule should not be applied. The exclude criteria can include resource information (e.g. kind, name, namespace, labels) and admission review request information like the name or role.
ClusterRoles is the list of cluster-wide role names for the user.
ResourceDescription contains information about the resource being created or modified.
Annotations is a map of annotations (key-value pairs of type string). Annotation keys and values support the wildcard characters "*" (matches zero or many characters) and "?" (matches at least one character).
Kinds is a list of resource kinds.
Name is the name of the resource. The name supports wildcard characters "*" (matches zero or many characters) and "?" (at least one character).
Namespaces is a list of namespaces names. Each name supports wildcard characters "*" (matches zero or many characters) and "?" (at least one character).
Selector is a label selector. Label keys and values in `matchLabels` support the wildcard characters `*` (matches zero or many characters) and `?` (matches one character). Wildcards allows writing label selectors like ["storage.k8s.io/*": "*"]. Note that using ["*" : "*"] matches any key and value but does not match an empty label set.
matchExpressions is a list of label selector requirements. The requirements are ANDed.
key is the label key that the selector applies to.
operator represents a key's relationship to a set of values. Valid operators are In, NotIn, Exists and DoesNotExist.
values is an array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty. This array is replaced during a strategic merge patch.
matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is "key", the operator is "In", and the values array contains only "value". The requirements are ANDed.
Roles is the list of namespaced role names for the user.
Subjects is the list of subject names like users, user groups, and service accounts.
APIGroup holds the API group of the referenced subject. Defaults to "" for ServiceAccount subjects. Defaults to "rbac.authorization.k8s.io" for User and Group subjects.
Kind of object being referenced. Values defined by this API group are "User", "Group", and "ServiceAccount". If the Authorizer does not recognized the kind value, the Authorizer should report an error.
Name of the object being referenced.
Namespace of the referenced object. If the object kind is non-namespace, such as "User" or "Group", and this value is not empty the Authorizer should report an error.
Generation is used to create new resources.
APIVersion specifies resource apiVersion.
Clone specifies the source resource used to populate each generated resource. At most one of Data or Clone can be specified. If neither are provided, the generated resource will be created with default data only.
Name specifies name of the resource.
Namespace specifies source resource namespace.
Data provides the resource declaration used to populate each generated resource. At most one of Data or Clone must be specified. If neither are provided, the generated resource will be created with default data only.
Kind specifies resource kind.
Name specifies the resource name.
Namespace specifies resource namespace.
Synchronize controls if generated resources should be kept in-sync with their source resource. If Synchronize is set to "true" changes to generated resources will be overwritten with resource data from Data or the resource specified in the Clone declaration. Optional. Defaults to "false" if not specified.
MatchResources defines when this policy rule should be applied. The match criteria can include resource information (e.g. kind, name, namespace, labels) and admission review request information like the user name or role. At least one kind is required.
ClusterRoles is the list of cluster-wide role names for the user.
ResourceDescription contains information about the resource being created or modified.
Annotations is a map of annotations (key-value pairs of type string). Annotation keys and values support the wildcard characters "*" (matches zero or many characters) and "?" (matches at least one character).
Kinds is a list of resource kinds.
Name is the name of the resource. The name supports wildcard characters "*" (matches zero or many characters) and "?" (at least one character).
Namespaces is a list of namespaces names. Each name supports wildcard characters "*" (matches zero or many characters) and "?" (at least one character).
Selector is a label selector. Label keys and values in `matchLabels` support the wildcard characters `*` (matches zero or many characters) and `?` (matches one character). Wildcards allows writing label selectors like ["storage.k8s.io/*": "*"]. Note that using ["*" : "*"] matches any key and value but does not match an empty label set.
matchExpressions is a list of label selector requirements. The requirements are ANDed.
key is the label key that the selector applies to.
operator represents a key's relationship to a set of values. Valid operators are In, NotIn, Exists and DoesNotExist.
values is an array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty. This array is replaced during a strategic merge patch.
matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is "key", the operator is "In", and the values array contains only "value". The requirements are ANDed.
Roles is the list of namespaced role names for the user.
Subjects is the list of subject names like users, user groups, and service accounts.
APIGroup holds the API group of the referenced subject. Defaults to "" for ServiceAccount subjects. Defaults to "rbac.authorization.k8s.io" for User and Group subjects.
Kind of object being referenced. Values defined by this API group are "User", "Group", and "ServiceAccount". If the Authorizer does not recognized the kind value, the Authorizer should report an error.
Name of the object being referenced.
Namespace of the referenced object. If the object kind is non-namespace, such as "User" or "Group", and this value is not empty the Authorizer should report an error.
Mutation is used to modify matching resources.
Overlay specifies an overlay pattern to modify resources. DEPRECATED. Use PatchStrategicMerge instead. Scheduled for removal in release 1.5+.
PatchStrategicMerge is a strategic merge patch used to modify resources. See https://kubernetes.io/docs/tasks/manage-kubernetes-objects/update-api-object-kubectl-patch/ and https://kubectl.docs.kubernetes.io/references/kustomize/patchesstrategicmerge/.
Patches specifies a RFC 6902 JSON Patch to modify resources. DEPRECATED. Use PatchesJSON6902 instead. Scheduled for removal in release 1.5+.
Operation specifies operations supported by JSON Patch. i.e:- add, replace and delete.
Path specifies path of the resource.
Value specifies the value to be applied.
PatchesJSON6902 is a list of RFC 6902 JSON Patch declarations used to modify resources. See https://tools.ietf.org/html/rfc6902 and https://kubectl.docs.kubernetes.io/references/kustomize/patchesjson6902/.
Name is a label to identify the rule, It must be unique within the policy.
Conditions enable variable-based conditional rule execution. This is useful for finer control of when an rule is applied. A condition can reference object data using JMESPath notation.
Key is the context entry (using JMESPath) for conditional rule evaluation.
Operator is the operation to perform.
Value is the conditional value, or set of values. The values can be fixed set or can be variables declared using using JMESPath.
Validation is used to validate matching resources.
AnyPattern specifies list of validation patterns. At least one of the patterns must be satisfied for the validation rule to succeed.
Deny defines conditions to fail the validation rule.
Specifies set of condition to deny.
Key is the context entry (using JMESPath) for conditional rule evaluation.
Operator is the operation to perform.
Value is the conditional value, or set of values. The values can be fixed set or can be variables declared using using JMESPath.
Message specifies a custom message to be displayed on failure.
Pattern specifies an overlay-style pattern used to check resources.
ValidationFailureAction controls if a validation policy rule failure should disallow the admission review request (enforce), or allow (audit) the admission review request and report an error in a policy report. Optional. The default value is "audit".
Status contains policy runtime data.
AvgExecutionTime is the average time taken to process the policy rules on a resource.
ResourcesBlockedCount is the total count of admission review requests that were blocked by this policy.
ResourcesGeneratedCount is the total count of resources that were generated by this policy.
ResourcesMutatedCount is the total count of resources that were mutated by this policy.
Rules provides per rule statistics
AppliedCount is the total number of times this rule was applied.
ExecutionTime is the average time taken to execute this rule.
FailedCount is the total count of policy error results for this rule.
ResourcesBlockedCount is the total count of admission review requests that were blocked by this rule.
ResourcesGeneratedCount is the total count of resources that were generated by this rule.
ResourcesMutatedCount is the total count of resources that were mutated by this rule.
Name is the rule name.
ViolationCount is the total count of policy failure results for this rule.
RulesAppliedCount is the total number of times this policy was applied.
RulesFailedCount is the total count of policy execution errors for this policy.
ViolationCount is the total count of policy failure results for this policy.
Source: kyverno.io_clusterpolicies.yaml
Changes to ClusterPolicy (kyverno.io/v1) in each Kyverno version, compared to the version before it.
15 properties have been added
1 property has changed type
1 property is now required
13 properties are no longer required
The description of ClusterPolicy has changed
72 properties have changed the description
Released · View ClusterPolicy in v1.3.0
2 properties have been added
Released · View ClusterPolicy in v1.1.10
3 properties have been added
Released · View ClusterPolicy in v1.1.9
ClusterPolicy was already present in this version of Kyverno, the oldest one on kubespec.dev
Released · View ClusterPolicy in v1.1.7
No examples of ClusterPolicy yet. Contribute one on GitHub.