Git Product home page Git Product logo

Comments (6)

chipzoller avatar chipzoller commented on August 14, 2024

How are you seeing this fails and on what version? I tested the policy myself manually and it works. We also test this regularly in CI. You're also missing the name field in your Pod above.

from policies.

Kellen275 avatar Kellen275 commented on August 14, 2024
$ kyverno version
Version: 1.10.0
Time: 2023-05-30T10:01:31Z
Git commit ID: da6f5c18132f773af15d0e09cbf2e16a36725232

$ kyverno test .

Executing ...
applying 1 policy to 1 resource...

│───│────────────────────────│────────────────────────│──────────────────│────────│
│ # │ POLICY                 │ RULE                   │ RESOURCE         │ RESULT │
│───│────────────────────────│────────────────────────│──────────────────│────────│
│ 1 │ imagepullpolicy-always │ imagepullpolicy-always │ default/Pod/test │ Fail   │
│───│────────────────────────│────────────────────────│──────────────────│────────│

Test Summary: 0 tests passed and 1 tests failed

Aggregated Failed Test Cases :
│───│────────────────────────│────────────────────────│──────────────────│────────│
│ # │ POLICY                 │ RULE                   │ RESOURCE         │ RESULT │
│───│────────────────────────│────────────────────────│──────────────────│────────│
│ 1 │ imagepullpolicy-always │ imagepullpolicy-always │ default/Pod/test │ Fail   │
│───│────────────────────────│────────────────────────│──────────────────│────────│

$ cat .kyverno-test/resource.yaml 
apiVersion: v1
kind: Pod
metadata:
  name: test
spec:
  containers:
    - name: test
      image: busybox:1.0.0
      imagePullPolicy: IfNotPresent

$ cat .kyverno-test/kyverno-test.yaml 
apiVersion: cli.kyverno.io/v1alpha1
kind: Test
metadata:
  name: imagepullpolicy-always
policies:
- ../imagepullpolicy-always.yaml
resources:
- resource.yaml
results:
- kind: Pod
  policy: imagepullpolicy-always
  resources:
  - test
  result: pass
  rule: imagepullpolicy-always

from policies.

chipzoller avatar chipzoller commented on August 14, 2024

Ok, you didn't mention the Kyverno CLI until now. Please test this on the latest version of the CLI (1.11.4).

from policies.

Kellen275 avatar Kellen275 commented on August 14, 2024

Apologies for assuming CLI usage! I've downloaded 1.11.4 via curl -LO https://github.com/kyverno/kyverno/releases/download/v1.11.4/kyverno-cli_v1.11.4_linux_x86_64.tar.gz

$ kyverno version
Version: 1.11.4
Time: ---
Git commit ID: ---

$ kyverno test .
Loading test  ( .kyverno-test/kyverno-test.yaml ) ...
  Loading values/variables ...
  Loading policies ...
  Loading resources ...
  Applying 1 policy to 1 resource ...
  Checking results ...

│────│────────────────────────│────────────────────────│──────────│────────│─────────────────────│
│ ID │ POLICY                 │ RULE                   │ RESOURCE │ RESULT │ REASON              │
│────│────────────────────────│────────────────────────│──────────│────────│─────────────────────│
│ 1  │ imagepullpolicy-always │ imagepullpolicy-always │ Pod/test │ Fail   │ Want pass, got skip │
│────│────────────────────────│────────────────────────│──────────│────────│─────────────────────│


Test Summary: 0 tests passed and 1 tests failed

Aggregated Failed Test Cases :
│────│────────────────────────│────────────────────────│──────────│────────│─────────────────────│
│ ID │ POLICY                 │ RULE                   │ RESOURCE │ RESULT │ REASON              │
│────│────────────────────────│────────────────────────│──────────│────────│─────────────────────│
│ 1  │ imagepullpolicy-always │ imagepullpolicy-always │ Pod/test │ Fail   │ Want pass, got skip │
│────│────────────────────────│────────────────────────│──────────│────────│─────────────────────│
Error: 1 tests failed

Does this imply I should change my kyverno-test.yaml to use result: skip for this test, since the image: spec doesn't match the policy check?

from policies.

chipzoller avatar chipzoller commented on August 14, 2024

Does this imply I should change my kyverno-test.yaml to use result: skip for this test, since the image: spec doesn't match the policy check?

Yes, exactly.

from policies.

Kellen275 avatar Kellen275 commented on August 14, 2024

Makes sense, thank you for quick responses!

from policies.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.