Jobs can be created directly and indirectly via a CronJob controller. In some cases, users may want to only allow Jobs if they are created via a CronJob. This policy restricts Jobs so they may only be created by a CronJob.
apiVersion: kyverno.io/v1kind: ClusterPolicymetadata:name: restrict-jobsannotations:policies.kyverno.io/title: Restrict Jobspolicies.kyverno.io/category: Otherpolicies.kyverno.io/severity: mediumpolicies.kyverno.io/subject: Jobkyverno.io/kyverno-version: 1.10.0kyverno.io/kubernetes-version: "1.26"policies.kyverno.io/description: Jobs can be created directly and indirectly via a CronJob controller. In some cases, users may want to only allow Jobs if they are created via a CronJob. This policy restricts Jobs so they may only be created by a CronJob.spec:validationFailureAction: Enforcerules:- name: restrict-job-from-cronjobmatch:any:- resources:kinds:- Jobpreconditions:any:- key: "{{ request.object.metadata.ownerReferences[0].kind || '' }}"operator: NotEqualsvalue: CronJobvalidate:message: Jobs are only allowed if spawned from CronJobs.deny: {}
This policy performs some best practices validation on Application fields. Path or chart must be specified but never both. And destination.name or destination.server must be specified but never both.
This policy prevents the use of the default project in an Application.
This policy prevents updates to the project field after an Application is created.