apiVersion: kyverno.io/v2beta1
kind: ClusterPolicy
metadata:
  name: cpol-clone-sync-delete-policy
spec:
  rules:
  - name: cpol-clone-sync-delete-policy-secret
    match:
      any:
      - resources:
          kinds:
          - Namespace
    generate:
      apiVersion: v1
      kind: Secret
      name: regcred
      namespace: "{{request.object.metadata.name}}"
      synchronize: true
      clone:
        namespace: default
        name: regcred
---
apiVersion: v1
data:
  foo: YmFy
kind: Secret
metadata:
  name: regcred
  namespace: default
type: Opaque
---
apiVersion: v1
data:
  color: yellow
kind: ConfigMap
metadata:
  namespace: default
  name: mytestcm