Skip to content

Mutate policy on existing resource not working only for k8s tls secret #1051

Answered by chipzoller
hiteshp39 asked this question in Q&A
Discussion options

You must be logged in to vote

Not a bug, converted to discussion.

You aren't using the target variable as explained in the docs.

apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
  name: label-existing-tls-secrets
spec:
  mutateExistingOnPolicyUpdate: true
  rules:
  - name: label-existing-tls-secrets-rule
    match:
      any:
      - resources:
          kinds:
          - Secret
    preconditions:
      all:
      - key: "{{ request.object.type }}"
        operator: Equals
        value: kubernetes.io/tls
    mutate:
      targets:
        - apiVersion: v1
          kind: Secret
          preconditions:
            all:
            - key: "{{ target.type }}"
              operator: Equals
              value: k…

Replies: 4 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@JimBugwadia
Comment options

Answer selected by chipzoller
Comment options

You must be logged in to vote
1 reply
@chipzoller
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #1050 on June 15, 2024 11:30.