<p>Hi I am using a config map which is created from the files in a directory.
The config map is mounted to the volume in the pods container. sometimes i need to update my config map . Any idea how can i do it ?. currently i am deleting the config map and recreating it and then restarting the pods. not sure if it is the best way because, here we delete and create a config map.</p>
<p>here is the shell script code</p>
<pre><code>kubectl create ns k6
kubectl create configmap k6-scripts-configmap -n k6 --from-file /test/scripts/k6/
kubectl apply  -f /test/config/k6/k6-deployment.yaml 
</code></pre>
<p>later in the script i need to update the config map as some files in the directory (<code>/test/scripts/k6/</code>) needs to be changed.</p>
<pre><code>kubectl delete configmap k6-scripts-configmap -n k6
kubectl create configmap k6-scripts-configmap -n k6 --from-file /test/scripts/k6/
kubectl rollout restart deployment k6 -n k6
</code></pre>
<p>could you let me know if i am doing it correctly , or is it possible i can update the config map without deleting it ? Also after an update should i restart the deployment ?</p>
<p>thank you</p>

Starbucks Admin
<p>You can split the Deployment and the ConfigMap definition in 2 different files.</p>
<p>Then, update only the configmap:</p>
<pre><code>kubectl create configmap k6-scripts-configmap \
  -n k6 --from-file /test/scripts/k6/ \
  --dry-run -o yaml &gt; configmap.yml
</code></pre>
<p>Apply the changes:</p>
<pre><code>kubectl -n k6 apply -f configmap.yml
</code></pre>
