Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Sample] Mutating Configmaps #1230

Open
2 tasks done
priyanshur-curefit opened this issue Feb 7, 2025 · 0 comments
Open
2 tasks done

[Sample] Mutating Configmaps #1230

priyanshur-curefit opened this issue Feb 7, 2025 · 0 comments
Labels
sample Sample policy

Comments

@priyanshur-curefit
Copy link

Problem Statement

i want to create a config map mutating policy which replaces any occurance of ap-south-1 to ap-south-2 in the data field of config map. Please help me create a valid policy which does this task

Solution Description

Using the following policy, which is not working

apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
  name: replace-ap-south-1-with-ap-south-2
spec:
  rules:
    - name: replace-region-in-configmap
      match:
        resources:
          kinds:
            - ConfigMap
      mutate:
        foreach:
          - list: "request.object.data | keys(@)"
            patchStrategicMerge:
              data:
                "{{ element }}": "{{ request.object.data[element] | replace('ap-south-1', 'ap-south-2') }}"

Example "Good" Resource

Example "Bad" Resource

Other Comments

No response

Slack discussion

No response

Troubleshooting

@priyanshur-curefit priyanshur-curefit added the sample Sample policy label Feb 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sample Sample policy
Projects
None yet
Development

No branches or pull requests

1 participant