<p>I've been using K8S ConfigMap and Secret to manage our properties. My design is pretty simple, that keeps properties files in a git repo and use build server such as Thoughtworks GO to automatically deploy them to be ConfigMaps or Secrets (on choice condition) to my k8s cluster.</p>
<p>Currently, I found it's not really efficient that I have to always delete the existing ConfigMap and Secret and create the new one to update as below:</p>
<ol>
<li><p><code>kubectl delete configmap foo</code></p>
</li>
<li><p><code>kubectl create configmap foo --from-file foo.properties</code></p>
</li>
</ol>
<p>Is there a nice and simple way to make above one step and more efficient than deleting current? potentially what I'm doing now may compromise the container that uses these configmaps if it tries to mount while the old configmap is deleted and the new one hasn't been created.</p>

<p>You can get YAML from the <code>kubectl create configmap</code> command and pipe it to <code>kubectl apply</code>, like this:</p>
<pre><code>kubectl create configmap foo --from-file foo.properties -o yaml --dry-run=client | kubectl apply -f -
</code></pre>
