<p>I have a ConfigMap as following:</p>
<pre><code>kind: ConfigMap
apiVersion: v1
metadata:
  name: health-ip
data:
  ip.json: |-
    [
      1.1.1.1,
      2.2.2.2
    ]
</code></pre>
<p>I want to modify/append or patch a small piece of this configuration by adding ip <code>3.3.3.3</code> to the ConfigMap so that it becomes:</p>
<pre><code>kind: ConfigMap
apiVersion: v1
metadata:
  name: health-ip
data:
  ip.json: |-
    [
      1.1.1.1,
      2.2.2.2,
      3.3.3.3
    ]
</code></pre>
<p>How can it do this using <code>kubectl patch</code> or equivalent?</p>

maopuppets
<p>There is no way to add without replace. As mentioned in comment by <strong>zerkms</strong>, <code>configmaps</code> does not undestand structure data.</p>
<p>You have a couple of options to achive what you want:</p>
<ol>
<li>Keep a &quot;template&quot; file of your configmap, update and apply when you need;</li>
<li>Automate the first task with a script that reads the configmap value and append the new value.</li>
<li>Use the <code>kubectl path</code> passing the whole ip list.</li>
</ol>
