<p>We have application with huge configuration (this is just a part):</p>
<pre><code>apiVersion: v1
kind: ConfigMap
metadata:
  name: my-app
data:
  application.yaml: |-
    config:
      app: MY-APP
      my-custom-map:
        KEY1: value1
        KEY2: value2
        KEY3: value3
        KEY4: value4
      something1: true
      something2: 123
      something3: string123
      something4: null
      subclass:
        anotherMap:
          &quot;[AAA:0.0.1,BBB:CCC]&quot;: &quot;DDD:EEEE&quot;
      subclass2:
        something4: AAAA
        anotherMap2:
          0.0.3: 0.0.3
</code></pre>
<p>I follow <a href="https://github.com/fabric8io/spring-cloud-kubernetes/tree/master/spring-cloud-kubernetes-examples/kubernetes-reload-example" rel="noreferrer">this</a> example to bind configmap with spring boot configuration but there is still some problem for example how to solve null in yaml which spring yaml postprocessor resolve as empty string: <a href="https://github.com/spring-projects/spring-framework/issues/19986" rel="noreferrer">issue</a></p>
<p>second problem is how to handle this configmap. I know I can edit and then use apply but this can lead to some error. Is there some tool which I can use to edit this yaml and make some bash script for editing ? like: ./my-script.sh -function addMyCustomMapValue -args &quot;KEY5:value5&quot; . I tried to explore <a href="https://github.com/mikefarah/yq" rel="noreferrer">yq</a> but I think there is some limitation and it is hard to use for some use-case and then <a href="https://kustomize.io/" rel="noreferrer">kustomize</a> which I think is good for creating configmap but not for editing existing one.</p>
<p>Is there already some good example for this use-case ?</p>

hudi
<p><strong>Option : 1</strong></p>
<p>You can Use the Lens : <a href="https://k8slens.dev/kubernetes.html" rel="nofollow noreferrer">https://k8slens.dev/kubernetes.html</a></p>
<p>It's UI for monitoring and Managing K8s clusters. Using this you can also edit the configmap.</p>
<p><strong>Option : 2</strong></p>
<p>You can manage all the Key value into single YAML file and create configmap from file :</p>
<pre><code>kubectl create configmap some-config \
  --from-file=some-key=some-config.yaml \
  -n some-namespace \
  -o yaml \
  --dry-run | kubectl apply -f - 
</code></pre>
<p><strong>Option : 3</strong></p>
<p>Use <code>helm</code> and <code>values.yaml</code> template to create and your chart and apply it further.</p>
<p><strong>Configmap</strong> using <strong>YAML</strong> helm</p>
<pre><code>apiVersion: v1
kind: ConfigMap
metadata:
  name: jksconfig
data:
  config.json: |-
    {{ .Files.Get &quot;config.json&quot; | indent 4 }}
</code></pre>
<p><strong>Option : 4</strong></p>
<p>If you are using the configmap as Environment or injecting it to file path you can use the Hashi corp vault also : <a href="https://www.vaultproject.io/" rel="nofollow noreferrer">https://www.vaultproject.io/</a></p>
<p><strong>Option : 5</strong></p>
<p>As you suggested you can create one <strong>Bash</strong> script which will export the existing running <strong>Configmap</strong> to a new <strong>YAML</strong> file one you are done with editing YAML manually. You can apply the changes to <strong>K8s</strong> cluster.</p>
<pre><code>#bin/bash
kubectl get configmap &lt;configmap-name&gt;  -o yaml &gt; cofig.yaml
</code></pre>
<p>You can also check the : <a href="https://github.com/Gallore/yaml_cli" rel="nofollow noreferrer">https://github.com/Gallore/yaml_cli</a> might be helpful.</p>
