k8wiz
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.

Read more about Kyverno