<p>I have a tool working on K8s that uses four configuration files:</p>

<pre><code>falco-config/falco.yaml             
falco-config/falco_rules.local.yaml 
falco-config/falco_rules.yaml       
falco-config/k8s_audit_rules.yaml
</code></pre>

<p>At deployment time I create the config map for this tool using the command:</p>

<pre><code>kubectl create configmap falco-config --from-file=..../falco-config/
</code></pre>

<p>It creates a ConfigMap with these four files. Now suppose I only want to update the <code>falco_rules.yaml</code> but I don't have (for different reasons) the other files. Which kubectl command can help me to do that? I searched for a solution on K8s doc and Stackoverflow with no luck.</p>

<p>Another question is, is there an example out there to do the same via K8s API in Javascript?</p>

<p><strong>NOTE:</strong>
I have read this question:
<a href="https://stackoverflow.com/questions/49989943">Kubectl update configMap</a>
but it doesn't address the modify via API and the fact that I need to only update one file while the whole configuration is composed by 4 files.</p>

Salvatore D'angelo
<p>Unfortunately there is no way to update specific fields of the ConfigMap in one go. Assuming that the ConfigMap resource has been already created, you could work around this as follows:</p>

<ol>
<li>Fetch the ConfigMap resource: <code>kubectl get configmap &lt;name&gt; --export -o yaml &gt; config.yaml</code> to fetch the ConfigMap resource locally</li>
<li>Update the fields in <code>config.yaml</code> so that the values of <code>falco_rules.yaml</code> are properly injected. This can be done programmatically.</li>
<li><code>kubectl apply -f config.yaml</code> to reconfigure the existing ConfigMap resource</li>
</ol>
