apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
  name: k10-policy-minimum-retention
  annotations:
    policies.kyverno.io/title: Minimum Backup Retention
    policies.kyverno.io/category: Kasten K10
    kyverno.io/kyverno-version: 1.6.2
    policies.kyverno.io/minversion: 1.6.2
    kyverno.io/kubernetes-version: "1.21-1.22"
    policies.kyverno.io/subject: Policy
    policies.kyverno.io/description: >-
      K10 Policy resources can be validated to adhere to common compliance retention standards. 
      Uncomment the regulation/compliance standards you want to enforce for according to GFS retention.
      This policy deletes the retention value in the backup operation and replaces it with the specified retention.
      Note: K10 Policy uses the GFS retention scheme and export operations default to use the retention of the backup operation.
      To use different 
      This policy can also be used go reduce retentions lengths to enforce cost optimization.
spec:
  rules:
  - name: k10-policy-minimum-retention
    match:
      any:
      - resources:
          kinds:
          - config.kio.kasten.io/v1alpha1/Policy
    mutate: 
      # Cost Optimization (Maximum Retention: 3 Months)
      patchesJson6902: |-
        - path: "/spec/retention"
          op: replace
          value: {"hourly":24,"daily":30,"weekly":4,"monthly":3}