apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
  name: validate-yaml
spec:
  validationFailureAction: enforce
  background: false
  webhookTimeoutSeconds: 30
  failurePolicy: Fail  
  rules:
    - name: validate-yaml
      match:
        any:
        - resources:
            kinds:
            - Service
            name: test*
      validate:
        manifests:
          attestors:
          # at least one signature required
          - count: 1
            entries:
            - keys:
                # pub
                publicKeys: |-
                    -----BEGIN PUBLIC KEY-----
                    MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEyQfmL5YwHbn9xrrgG3vgbU0KJxMY
                    BibYLJ5L4VSMvGxeMLnBGdM48w5IE//6idUPj3rscigFdHs7GDMH4LLAng==
                    -----END PUBLIC KEY-----
            - keys:
                # pub1
                publicKeys: |-
                    -----BEGIN PUBLIC KEY-----
                    MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEE8uGVnyDWPPlB7M5KOHRzxzPHtAy
                    FdGxexVrR4YqO1pRViKxmD9oMu4I7K/4sM51nbH65ycB2uRiDfIdRoV/+A==
                    -----END PUBLIC KEY-----
    - name: validate-yaml-multi-sig
      match:
        any:
        - resources:
            kinds:
            - Service
            name: test*
      validate:
        manifests:
          attestors:
          # all signatures required
          - entries:
            - keys:
                # pub
                publicKeys: |-
                    -----BEGIN PUBLIC KEY-----
                    MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEyQfmL5YwHbn9xrrgG3vgbU0KJxMY
                    BibYLJ5L4VSMvGxeMLnBGdM48w5IE//6idUPj3rscigFdHs7GDMH4LLAng==
                    -----END PUBLIC KEY-----
            - keys:
                # pub1
                publicKeys: |-
                    -----BEGIN PUBLIC KEY-----
                    MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEE8uGVnyDWPPlB7M5KOHRzxzPHtAy
                    FdGxexVrR4YqO1pRViKxmD9oMu4I7K/4sM51nbH65ycB2uRiDfIdRoV/+A==
                    -----END PUBLIC KEY-----