Skip to content

Feature: Patch for ConfigMap values when structured #5109

Description

@ant31

Eschewed features

  • This issue is not requesting templating, unstuctured edits, build-time side-effects from args or env vars, or any other eschewed feature.

What would you like to have added?

Hi,

I would like to include a way to quickly patch files included in configmap that are in a structured format.
Many softwares are configured via config files, like "config.yaml", kustomize provides an easy way to include this files inside a configmap via configMapGenerator, however kustomize is lacking options to edit those configuration in overlays.
In example this configmap:

kind: ConfigMap
data:
  config.yaml: |-
     log: 
       level: "debug"
     many: 
        other:
           fields: [ ]
     to: configure
     the: app           

If an overlay wants to change only the log.level to "info", it requires to copy all config.yaml.
In short it's impossible to create a patch with the current set of features.

The goal is to be able to do something like (or close to):

patch: |-
   - op: replace
     path: /data/config.yaml/log/level
     value:   "info"   

This should be limited to structured configuration or configuration that are in yaml format and that could be converted to. yaml.

A potential solution to iterate would be to add a new input format in the configmapGenerator:

configMapGenerator:
 - structureFiles: 
      - format: yaml
         path: config.yaml
    name: myconf
 
patches:
 patch: |-
   - op: replace
     path: /data/config.yaml/log/level
     value:   "info" 
 target:
     kind: ConfigMap
     name: myconf    

That way kustomize would know how to serialize config.yaml and apply changes to it. This only and implementation suggestion, but I think it would aligned with Kustomize's direction.

Why is this needed?

Patching configuration files in ConfigMap is not possible.
If an overlay change a single value, it requires to copy all config.yaml.
It's impossible to create a patches.

Templated system don't have this issue as they can template directly in the configmap the value to edit. I would like to raise kustomize on this capability.

Can you accomplish the motivating task without this feature, and if so, how?

We can get the desired output by copying the whole configuration files in the overlays.
It's error-prone over time; some configuration can be very long and requires constant synchronization between the base layer and overlays. Moreover, often, overlays only need to tweak a few fields of those configurations.

Templating system (like helm) doesn't have this issue if the "most" changed fields are templated.

Being able to patch configuration files would be a great addition to kustomize and align with the "no-templating" strategy.

What other solutions have you considered?

As described, the current solution is to copy/paste configuration files in all overlays.

Anything else we should know?

No response

Feature ownership

  • I am interested in contributing this feature myself! 🎉

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/featureCategorizes issue or PR as related to a new feature.triage/duplicateIndicates an issue is a duplicate of other open issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions