[Bug] Kyverno CLI test
examples fail unless background: true
is added or clusterRoles
is removed from disallow-latest-tag
policy
#1244
Labels
bug
Something isn't working
Page link
https://kyverno.io/docs/kyverno-cli/usage/test/#examples
Description
I am new to Kyverno (not new to the Kubernetes ecosystem, though, if that is relevant) and am trying to set up some policies and test cases so that I can validate Kubernetes manifests outside of a cluster (the goal is to implement GitHub Actions pull request checks in a repository managed by ArgoCD).
I am working through the Examples section of the documentation on the
kyverno test
CLI command (https://kyverno.io/docs/kyverno-cli/usage/test/#examples) and I wasn't seeing the same output that the documentation showed.I copied the YAML files provided by that documentation page (have them in a MWE git repo here too):
Contents of
disallow_latest_tag.yaml
:Contents of
resource.yaml
:Contents of
kyverno-test.yaml
:With these three files, the documentation shows
kyverno test .
returning this success response:However, when I run the same
kyverno test .
command, I get this failure response:I searched the Kyverno discussions (link to search) and came across this comment, which suggested adding the
-v=8
flag for more detailed output.When I pass
-v=8
, I get an additionalERROR
log message in the output:Full output:
If I remove the clusterRoles property from the
require-image-tag
rule:Then I get the same behavior (success) as the documentation example:
There is still a difference between the output in the documentation and my local output, in that the documentation shows the
default
namespace in output (in the resource column), while my local output does not - that doesn't feel significant to me but wanted to mention it here regardless.I also was curious about the
spec.background=false
bit in the error message, so searched for that and found the Background Scans documentation. Following that, I setbackground: false
in the policy:metadata: name: disallow-latest-tag spec: + background: false validationFailureAction: Audit rules: - name: require-image-tag
And this also allows the
kyverno test .
command to pass (even if theclusterRoles
property is present).Expected behavior
I expect that when running the same commands on the same files provided in the documentation (using the same CLI version), that I get the same output.
Slack discussion
n/a
The text was updated successfully, but these errors were encountered: