Skip to content

feat(velero-vpol): add validate-cron-schedule ValidatingPolicy - #1752

Open
saksham869 wants to merge 1 commit into
kyverno:mainfrom
saksham869:velero-vpol-validate-cron-schedule
Open

saksham869 wants to merge 1 commit into
kyverno:mainfrom
saksham869:velero-vpol-validate-cron-schedule

Conversation

@saksham869

Copy link
Copy Markdown

Related Issue(s)

Part of #1543, #1696

Description

Adds velero-vpol/validate-cron-schedule, the policies.kyverno.io/v1 replacement for the removed velero/ and velero-cel/ samples.

  • Matches velero.io/v1 schedules on CREATE and UPDATE.
  • Copies the velero-cel/ regular expression unchanged.
  • validationActions: [Audit] and background scanning on, as in legacy. The Chainsaw test patches to [Deny].
  • Adds aggregated read ClusterRoles for schedules in .chainsaw-test/rbac.yaml.
  • velero-vpol is a new group, so this adds its job to .github/workflows/test.yml and lists it in both e2e-required aggregates.

Tests

  • CLI: goodschedule01 (0 7 * * *) and goodschedule02 (*/15 0-6 1,15 * 1-5) pass. badschedule01 (0 7 * * * *), badschedule02 (0 7 * */ *) and badschedule03 (0 24 * * *) fail.
  • Chainsaw creates both good Schedules and rejects all three bad ones.
$ kubectl-kyverno test velero-vpol
Test Summary: 5 tests passed and 0 tests failed

$ chainsaw test velero-vpol --config .chainsaw.yaml
--- PASS: chainsaw/velero-vpol/validate-cron-schedule/.chainsaw-test[validate-cron-schedule] (14.83s)

Note: the regex is unchanged, as the issue asks. It rejects Velero's documented @every 6h form, so such a Schedule would be reported. Happy to send a follow-up if you'd like that allowed.

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.
  • I have added the artifacthub-pkg.yml file and have verified it is complete and correct.

AI-assisted (Claude). I reviewed every file and ran both tests locally.

Add the policies.kyverno.io/v1 replacement for the removed velero/ and velero-cel/ validate-cron-schedule samples. The cron regular expression is copied unchanged from velero-cel/, with Audit and background scanning as in legacy.

velero-vpol is a new policy group, so add its job to the E2E workflow and list it in both e2e-required aggregates.

Part of kyverno#1543, kyverno#1696

Signed-off-by: saksham869 <mishrasatyam3456@gmail.com>
Assisted-by: Claude:claude-opus-5.5
Copilot AI lite review requested due to automatic review settings November 21, 2026 09:42
@github-actions github-actions Bot added workflow-approval-required Workflows are waiting for a maintainer to approve running them github_actions Pull requests that update GitHub Actions code type_cel Uses CEL-based Kyverno policy types validating-policy ValidatingPolicy samples tests Policy test manifests and shared test tooling and removed workflow-approval-required Workflows are waiting for a maintainer to approve running them labels Nov 21, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The policy covers CREATE and UPDATE, but the test suite exercises only creation, leaving invalid updates to existing Schedules unverified.

1 open issue
What changed in this PR

Adds the velero-vpol/validate-cron-schedule policies.kyverno.io/v1 ValidatingPolicy for Velero Schedule cron expressions, replacing the legacy samples and integrating the new policy group into CI.

Changes:

  • Adds CREATE and UPDATE validation with Audit mode and background scanning.
  • Adds CLI and Chainsaw fixtures, readiness checks, CRD assertions, and aggregated RBAC.
  • Publishes Artifact Hub metadata and registers the velero-vpol test group in required CI jobs.
File Description
velero-vpol/​validate-cron-schedule/​validate-cron-schedule.yaml Defines the Velero Schedule cron-expression ValidatingPolicy for CREATE and UPDATE operations.
velero-vpol/​validate-cron-schedule/​artifacthub-pkg.yml Provides Artifact Hub package metadata and installation instructions.
velero-vpol/​validate-cron-schedule/​.kyverno-test/​kyverno-test.yaml Defines CLI positive and negative policy test cases.
velero-vpol/​validate-cron-schedule/​.chainsaw-test/​rbac.yaml Grants the required controllers read access to Velero Schedules during Chainsaw tests.
velero-vpol/​validate-cron-schedule/​.chainsaw-test/​policy-ready.yaml Asserts that the policy reaches the expected ready state.
velero-vpol/​validate-cron-schedule/​.chainsaw-test/​good-schedule.yaml Provides valid Velero Schedule fixtures for integration testing.
velero-vpol/​validate-cron-schedule/​.chainsaw-test/​crd-assert.yaml Verifies that the Velero Schedule CRD is available.
velero-vpol/​validate-cron-schedule/​.chainsaw-test/​chainsaw-test.yaml Configures the end-to-end policy installation and Schedule validation test.
velero-vpol/​validate-cron-schedule/​.chainsaw-test/​bad-schedule.yaml Provides invalid Velero Schedule fixtures for rejection testing.
.github/​workflows/​test.yml Adds the velero-vpol test job and required CI aggregate dependencies.

Review effort: Lite

resourceRules:
- apiGroups: ["velero.io"]
apiVersions: [v1]
operations: [CREATE, UPDATE]
@github-actions github-actions Bot added workflow-approval-required Workflows are waiting for a maintainer to approve running them needs-author-action Failing DCO or CI, merge conflicts, or review threads awaiting the author labels Nov 21, 2026
@github-actions

Copy link
Copy Markdown

@saksham869 this PR needs a bit more before it can be reviewed:

  • resolve review threads, or reply if you need help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

github_actions Pull requests that update GitHub Actions code needs-author-action Failing DCO or CI, merge conflicts, or review threads awaiting the author tests Policy test manifests and shared test tooling type_cel Uses CEL-based Kyverno policy types validating-policy ValidatingPolicy samples workflow-approval-required Workflows are waiting for a maintainer to approve running them

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants