<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>ClusterPolicy on Kyverno</title><link>https://release-1-16-0--kyverno.netlify.app/docs/policy-types/cluster-policy/</link><description>Recent content in ClusterPolicy on Kyverno</description><generator>Hugo</generator><language>en</language><atom:link href="https://release-1-16-0--kyverno.netlify.app/docs/policy-types/cluster-policy/index.xml" rel="self" type="application/rss+xml"/><item><title>Policy Settings</title><link>https://release-1-16-0--kyverno.netlify.app/docs/policy-types/cluster-policy/policy-settings/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://release-1-16-0--kyverno.netlify.app/docs/policy-types/cluster-policy/policy-settings/</guid><description>&lt;p>A &lt;a href="https://release-1-16-0--kyverno.netlify.app/docs/policy-types/cluster-policy/policy_rule">policy&lt;/a> contains one or more rules, and the following common settings which apply to all rules in the policy:&lt;/p>
&lt;ul>
&lt;li>
&lt;p>&lt;strong>admission&lt;/strong>: determines whether rules in this policy should be applied during admission control. This is an optional field with a default of &lt;code>true&lt;/code>. If set to &lt;code>false&lt;/code> then policies should be applied in background mode only (see further below).&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>applyRules&lt;/strong>: states how many of the rules in the parent policy should be applied to a matching resource. Values are &lt;code>One&lt;/code> and &lt;code>All&lt;/code> (default). If set to &lt;code>One&lt;/code>, the first matching rule to be applied will stop further rules from being evaluated.&lt;/p></description></item><item><title>Selecting Resources</title><link>https://release-1-16-0--kyverno.netlify.app/docs/policy-types/cluster-policy/match-exclude/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://release-1-16-0--kyverno.netlify.app/docs/policy-types/cluster-policy/match-exclude/</guid><description>&lt;p>The &lt;code>match&lt;/code> and &lt;code>exclude&lt;/code> filters control the scope to which rules are applied. They have the same structure and can each contain &lt;strong>only one&lt;/strong> of the two elements:&lt;/p>
&lt;ul>
&lt;li>&lt;code>any&lt;/code>: specify &lt;a href="https://release-1-16-0--kyverno.netlify.app/docs/policy-types/cluster-policy/match-exclude/#resource-filters">resource filters&lt;/a> on which Kyverno will perform the logical &lt;strong>OR&lt;/strong> operation while choosing resources&lt;/li>
&lt;li>&lt;code>all&lt;/code>: specify &lt;a href="https://release-1-16-0--kyverno.netlify.app/docs/policy-types/cluster-policy/match-exclude/#resource-filters">resource filters&lt;/a> on which Kyverno will perform the logical &lt;strong>AND&lt;/strong> operation while choosing resources&lt;/li>
&lt;/ul>
&lt;h2 id="resource-filters">
 Resource Filters
 &lt;a href="#resource-filters">
 &lt;svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" width="24" height="24" viewBox="0 0 24 24">&lt;path d="M0 0h24v24H0z" fill="none">&lt;/path>&lt;path d="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z">&lt;/path>&lt;/svg>
 &lt;/a>
&lt;/h2>
&lt;p>The following resource filters can be specified under an &lt;code>any&lt;/code> or &lt;code>all&lt;/code> clause.&lt;/p></description></item><item><title>Validate Rules</title><link>https://release-1-16-0--kyverno.netlify.app/docs/policy-types/cluster-policy/validate/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://release-1-16-0--kyverno.netlify.app/docs/policy-types/cluster-policy/validate/</guid><description>&lt;p>Validation rules are probably the most common and practical types of rules you will be working with, and the main use case for admission controllers such as Kyverno. In a typical validation rule, one defines the mandatory properties with which a given resource should be created. When a new resource is created by a user or process, the properties of that resource are checked by Kyverno against the validate rule. If those properties are validated, meaning there is agreement, the resource is allowed to be created. If those properties are different, the creation is blocked. The behavior of how Kyverno responds to a failed validation check is determined by the &lt;code>failureAction&lt;/code> field. It can either be blocked (&lt;code>Enforce&lt;/code>) or allowed yet recorded in a &lt;a href="https://release-1-16-0--kyverno.netlify.app/docs/policy-reports/">policy report&lt;/a> (&lt;code>Audit&lt;/code>). Validation rules in &lt;code>Audit&lt;/code> mode can also be used to get a report on matching resources which violate the rule(s), both upon initial creation and when Kyverno initiates periodic scans of Kubernetes resources. Resources in violation of an existing rule placed in &lt;code>Audit&lt;/code> mode will also surface in an event on the resource in question.&lt;/p></description></item><item><title>Mutate Rules</title><link>https://release-1-16-0--kyverno.netlify.app/docs/policy-types/cluster-policy/mutate/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://release-1-16-0--kyverno.netlify.app/docs/policy-types/cluster-policy/mutate/</guid><description>&lt;p>A &lt;code>mutate&lt;/code> rule can be used to modify matching resources and is written as either a RFC 6902 JSON Patch or a strategic merge patch.&lt;/p>
&lt;p>By using a patch in the &lt;a href="http://jsonpatch.com/">JSONPatch - RFC 6902&lt;/a> format, you can make precise changes to the resource being created. A strategic merge patch is useful for controlling merge behaviors on elements with lists. Regardless of the method, a &lt;code>mutate&lt;/code> rule is used when an object needs to be modified in a given way.&lt;/p></description></item><item><title>Generate Rules</title><link>https://release-1-16-0--kyverno.netlify.app/docs/policy-types/cluster-policy/generate/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://release-1-16-0--kyverno.netlify.app/docs/policy-types/cluster-policy/generate/</guid><description>&lt;p>A generate rule can be used to create new Kubernetes resources in response to some other event including things like resource creation, update, or delete, or even by creating or updating a policy itself. This is useful to create supporting resources, such as new RoleBindings or NetworkPolicies for a Namespace or perform other automation tasks that may either require other tools or be scripted.&lt;/p>
&lt;p>Some common use cases for generate rules include:&lt;/p></description></item><item><title>Variables</title><link>https://release-1-16-0--kyverno.netlify.app/docs/policy-types/cluster-policy/variables/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://release-1-16-0--kyverno.netlify.app/docs/policy-types/cluster-policy/variables/</guid><description>&lt;p>Variables make policies smarter and reusable by enabling references to data in the policy definition, the &lt;a href="https://kubernetes.io/docs/reference/access-authn-authz/extensible-admission-controllers/#webhook-request-and-response">admission review request&lt;/a>, and external data sources like ConfigMaps, the Kubernetes API Server, OCI image registries, and even external service calls.&lt;/p>
&lt;p>In Kyverno, for a plain JMESPath variable, no double curly brackets are needed but for nested variables you need to use the double braces syntax.&lt;/p>
&lt;p>For example:&lt;/p>
&lt;pre tabindex="0">&lt;code>- name: mountpath
 variable:
 jmesPath: request.object.metadata.annotations.optional || &amp;#39;/custom/string/{{request.object.metadata.annotations.mandatory&amp;#34;}}&amp;#39;
&lt;/code>&lt;/pre>&lt;p>Here, no double curly brackets are needed in &lt;code>request.object.metadata.annotations.optional&lt;/code> but for nested variables like &lt;code>/custom/string/{{request.object.metadata.annotations.mandatory&amp;quot;}}&lt;/code>, you need wrap variable with &lt;code>{{}}&lt;/code>. For variables in policy declarations the &lt;code>$( ... )&lt;/code> syntax is used instead.&lt;/p></description></item><item><title>External Data Sources</title><link>https://release-1-16-0--kyverno.netlify.app/docs/policy-types/cluster-policy/external-data-sources/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://release-1-16-0--kyverno.netlify.app/docs/policy-types/cluster-policy/external-data-sources/</guid><description>&lt;p>The &lt;a href="https://release-1-16-0--kyverno.netlify.app/docs/policy-types/cluster-policy/variables/">Variables&lt;/a> section discusses how variables can help create smarter and reusable policy definitions and introduced the concept of a rule &lt;a href="https://release-1-16-0--kyverno.netlify.app/docs/policy-types/cluster-policy/variables/#variables-from-external-data-sources">context&lt;/a> that stores all variables.&lt;/p>
&lt;p>This section provides details on using ConfigMaps, API calls, service calls, and image registries to reference external data as variables in policies.&lt;/p>
&lt;h2 id="variables-from-configmaps">
 Variables from ConfigMaps
 &lt;a href="#variables-from-configmaps">
 &lt;svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" width="24" height="24" viewBox="0 0 24 24">&lt;path d="M0 0h24v24H0z" fill="none">&lt;/path>&lt;path d="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z">&lt;/path>&lt;/svg>
 &lt;/a>
&lt;/h2>
&lt;p>A &lt;a href="https://kubernetes.io/docs/concepts/configuration/configmap/">ConfigMap&lt;/a> resource in Kubernetes is commonly used as a source of configuration details which can be consumed by applications. This data can be written in multiple formats, stored in a Namespace, and accessed easily. Kyverno supports using a ConfigMap as a data source for variables. When a policy referencing a ConfigMap resource is evaluated, the ConfigMap data is checked at that time ensuring that references to the ConfigMap are always dynamic. Should the ConfigMap be updated, subsequent policy lookups will pick up the latest data at that point.&lt;/p></description></item><item><title>Auto-Gen Rules</title><link>https://release-1-16-0--kyverno.netlify.app/docs/policy-types/cluster-policy/autogen/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://release-1-16-0--kyverno.netlify.app/docs/policy-types/cluster-policy/autogen/</guid><description>&lt;p>Pods are one of the most common object types in Kubernetes and as such are the focus of most types of validation rules. But creation of Pods directly is almost never done as it is considered an anti-pattern. Instead, Kubernetes has many higher-level controllers that directly or indirectly manage Pods, namely the Deployment, DaemonSet, StatefulSet, Job, and CronJob resources. Third-party custom resources may also &amp;ldquo;wrap&amp;rdquo; or leverage the Pod template as part of their resources as well. Writing policy that targets Pods but must be written for every one of these controllers would be tedious and inefficient. Kyverno solves this issue by supporting automatic generation of policy rules for higher-level controllers from a rule written exclusively for a Pod. For rules which match on Pods in addition to other kinds, auto-generation is not activated.&lt;/p></description></item><item><title>Preconditions</title><link>https://release-1-16-0--kyverno.netlify.app/docs/policy-types/cluster-policy/preconditions/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://release-1-16-0--kyverno.netlify.app/docs/policy-types/cluster-policy/preconditions/</guid><description>&lt;p>Preconditions allow for more fine-grained selection of resources than the options allowed by &lt;code>match&lt;/code> and &lt;code>exclude&lt;/code> statements. Preconditions consist of one or more expressions which are evaluated after a resource has been successfully matched (and not excluded) by a rule. They are powerful in that they allow you access to variables, JMESPath filters, operators, and other constructs which can be used to precisely select when a rule should be evaluated. When preconditions are evaluated to an overall TRUE result, processing of the rule body begins.&lt;/p></description></item><item><title>JMESPath</title><link>https://release-1-16-0--kyverno.netlify.app/docs/policy-types/cluster-policy/jmespath/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://release-1-16-0--kyverno.netlify.app/docs/policy-types/cluster-policy/jmespath/</guid><description>&lt;p>&lt;a href="https://jmespath.org/">JMESPath&lt;/a> (pronounced &amp;ldquo;James path&amp;rdquo;) is a JSON query language created by James Saryerwinnie and is the language that Kyverno supports to perform more complex selections of fields and values and also manipulation thereof by using one or more &lt;a href="https://jmespath.org/specification.html#filter-expressions">filters&lt;/a>. If you&amp;rsquo;re familiar with &lt;code>kubectl&lt;/code> and Kubernetes already, this might ring a bell in that it&amp;rsquo;s similar to &lt;a href="https://github.com/json-path/JsonPath">JSONPath&lt;/a>. JMESPath can be used almost anywhere in Kyverno although is an optional component depending on the type and complexity of a Kyverno policy or rule that is being written. While many policies can be written with simple overlay patterns, others require more detailed selection and transformation. The latter is where JMESPath is useful.&lt;/p></description></item><item><title>Tips &amp; Tricks</title><link>https://release-1-16-0--kyverno.netlify.app/docs/policy-types/cluster-policy/tips/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://release-1-16-0--kyverno.netlify.app/docs/policy-types/cluster-policy/tips/</guid><description>&lt;p>These are some tips and tricks you can use when putting together your Kyverno policies.&lt;/p>
&lt;h2 id="general">
 General
 &lt;a href="#general">
 &lt;svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" width="24" height="24" viewBox="0 0 24 24">&lt;path d="M0 0h24v24H0z" fill="none">&lt;/path>&lt;path d="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z">&lt;/path>&lt;/svg>
 &lt;/a>
&lt;/h2>
&lt;ul>
&lt;li>
&lt;p>Need more examples or struggling to see a practical use case? Remember to check out the extensive &lt;a href="https://release-1-16-0--kyverno.netlify.app/docs/policies/">community samples library&lt;/a> for ideas on how to author certain types, as well as to kickstart your own needs. Very often, you may not need to start from scratch but can instead use one of the samples as a starting point to further customize.&lt;/p></description></item></channel></rss>