Kyverno
Medium
Policies
Which of the following is a valid way to use a variable in a Kyverno policy pattern?
Select your answer:
Show answer and explanation
Answer: metadata.name: {{var1}}
Explanation
Kyverno variables are JMESPath expressions in double braces. A context entry named var1 is referenced as {{var1}}, and request data as {{request.object.metadata.name}}. ${var1} is Flux and shell syntax, and $( ) in a pattern refers to another field of the same resource, not to a variable.
More medium Kyverno questions
- What is the purpose of the 'kyverno.io/generated-by' annotation?
- In a kyverno-test.yaml results entry, which field marks the result as coming from a CEL-based ValidatingPolicy?
- The Kyverno 1.20 Helm chart refuses to upgrade because legacy kyverno.io policies exist. Which value lets the upgrade proceed?
- A GeneratingPolicy that clones a Secret into new namespaces fails with a forbidden error. Which label on a ClusterRole merges its rules into the Kyverno background controller's permissions?
- A Kyverno MutatingPolicy ApplyConfiguration can't set a container's args because the list is atomic. Which setting allows the change?
- What happens when a resource violates a Kyverno validation policy with 'validationFailureAction' set to 'enforce'?