policies icon indicating copy to clipboard operation
policies copied to clipboard

make periodSeconds optional

Open monotek opened this issue 2 years ago • 1 comments

Signed-off-by: André Bauer [email protected]

Related Issue(s)

https://github.com/kyverno/kyverno/issues/4983

Description

Make periodSeconds optional so the check works also on the CLI if periodSeconds is not set. In the cluster periodSeconds has a default of 10 secdonds so the policy would work.

Checklist

  • [] I have read the policy contribution guidelines.
  • [] I have added test manifests and resources covering both positive and negative tests that prove this policy works as intended.

monotek avatar Oct 15 '22 10:10 monotek

Yes, the tests in the same directory still work:

kyverno apply require_probes.yaml --resource resource.yaml 

Applying 1 policy rule to 5 resources...

policy require-pod-probes -> resource default/Pod/badpod01 failed: 
1. validate-livenessProbe-readinessProbe: validation error: Liveness and readiness probes are required. rule validate-livenessProbe-readinessProbe failed at path /spec/containers/0/livenessProbe/ 

policy require-pod-probes -> resource default/Pod/badpod02 failed: 
1. validate-livenessProbe-readinessProbe: validation error: Liveness and readiness probes are required. rule validate-livenessProbe-readinessProbe failed at path /spec/containers/0/livenessProbe/ 

policy require-pod-probes -> resource default/Pod/badpod03 failed: 
1. validate-livenessProbe-readinessProbe: validation error: Liveness and readiness probes are required. rule validate-livenessProbe-readinessProbe failed at path /spec/containers/0/livenessProbe/ 

pass: 2, fail: 3, warn: 0, error: 0, skip: 5 

Same output if you remove "periodSeconds" from goodpod01 & goodpod02 :)

monotek avatar Oct 16 '22 11:10 monotek