Skip to content

Add interval field to BackgroundConfiguration for per-policy background scan interval#91

Open
VarshaUN wants to merge 1 commit into
kyverno:mainfrom
VarshaUN:feat/per-policy-background-scan-interval
Open

Add interval field to BackgroundConfiguration for per-policy background scan interval#91
VarshaUN wants to merge 1 commit into
kyverno:mainfrom
VarshaUN:feat/per-policy-background-scan-interval

Conversation

@VarshaUN
Copy link
Copy Markdown

Explanation

This PR adds an interval field to the BackgroundConfiguration struct in the Kyverno API. Currently, background scanning in Kyverno runs on a single global interval configured at the controller level, meaning all policies are scanned at the same frequency regardless of their individual needs. This addition allows users to override the global background scan interval on a per-policy basis by setting spec.evaluation.background.interval on ValidatingPolicy, MutatingPolicy, and other CEL-based policy types. This is an addition of new API behavior.

Related issue

Part of kyverno/KDP#89 , Per-Policy Background Scan Interval proposal, discussed and approved by maintainers.

Proposed Changes

After this change, users can configure per-policy background scan intervals like:

apiVersion: policies.kyverno.io/v1
kind: ValidatingPolicy
metadata:
  name: require-pod-labels
spec:
  evaluation:
    background:
      enabled: true
      interval: 15m   # this policy scans every 15 minutes

If interval is not set, the policy falls back to the global background scan interval as before , fully backward compatible.

Checklist

  • I have read the contributing guidelines.
  • I have read the PR documentation guide and followed the process including adding proof manifests to this PR.
  • This is a bug fix and I have added unit tests that prove my fix is effective.

Further Comments

This PR covers only the API type change. A follow-up PR in kyverno/kyverno will implement the actual background controller behavior reading spec.evaluation.background.interval per policy and scheduling scans accordingly, along with annotation support for Kubernetes-native ValidatingAdmissionPolicy and MutatingAdmissionPolicy types as agreed in the KDP discussion.

Signed-off-by:Varsha U N varshaun58@gmail.com

cc: @aerosouund @JimBugwadia @realshuting

…ckground scan interval

Signed-off-by: Varsha U N <varshaun58@gmail.com>
@VarshaUN VarshaUN changed the title feat: add interval field to B Add interval field to BackgroundConfiguration for per-policy background scan interval May 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant