Skip to content

Support patching nested fields inside ConfigMap YAML/JSON string values using resourceModifierRules #8867

Open
@ashish-gupta-2

Description

@ashish-gupta-2

According to the Velero documentation: https://velero.io/docs/main/restore-resource-modifiers/

The current implementation of resourceModifierRules only supports patching structured fields in Kubernetes resource objects (e.g., metadata.labels, spec.replicas, spec.containers). However, it does not support modifying values inside YAML-encoded strings, which are commonly found in ConfigMap keys.

Example

apiVersion: v1
kind: ConfigMap
metadata:
  name: data-extensions-config
  namespace: my-namespace
data:
  data-extensions.yaml: |
    extensions:
      - name: custom-logging
        enabled: true
        config:
          level: debug

If I want to modify config.level from debug to info, there is currently no way to do that using either mergePatches or strategicPatches.
This makes it difficult to dynamically update or transform embedded config values during a restore process.

Describe the solution you'd like

It would be helpful if Velero's resourceModifierRules could support modifying specific fields inside YAML or JSON strings embedded within resource fields — for example, using a jsonPath or a more powerful mechanism to patch values nested inside ConfigMap.data["some-key"].

Possible enhancements:
Built-in parsing of ConfigMap.data values as YAML/JSON
Ability to specify a nested jsonPath or jq-like selector to reach into string-encoded structures
An alternative patch type that supports such transformations (e.g., stringPatches)

Anything else you would like to add

This feature would greatly improve the flexibility of Velero's restore process for applications that store deeply nested configuration inside ConfigMaps (which is a common pattern).

Currently, the only workaround is to overwrite the entire string, which is error-prone and hard to manage in larger systems or dynamic environments.

Environment:

Velero version: v1.14.0
Kubernetes version:

                                     Client Version: v1.28.3
                                    Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3
                                   Server Version: v1.27.16+03a907c

Kubernetes installer & version: (e.g. OpenShift 4.14.50)
Cloud provider or hardware configuration: (e.g. OCP cluster)

Vote on this issue!

This is an invitation to the Velero community to vote on issues.
You can see the project's top voted issues listed here.
Use the "reaction smiley face" at the top right of this comment to vote.

👍 for "The project would be better with this feature added"

👎 for "This feature will not enhance the project in a meaningful wa

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions