<p>I have a Kubernetes pod (let's call it <strong>POD-A</strong>) and I want it to use a certain config file to perform some actions using k8s API. The config file will be a YAML or JSON which will be parsed by the application inside the pod.</p>

<p>The config file is hosted by an application server on cloud and the latest version of it can be pulled based on a trigger. The config file contains configuration details of all the deployments in the k8s cluster and will be used to update deployments using k8s API in <strong>POD-A</strong>.</p>

<p>Now what I am thinking is to save this config file in a config-map and every time a new config file is pulled a new config-map is created by the pod which is using the k8s API.</p>

<p>What I want to do is to update the previous config map with a certain flag (a key and a value) which will basically help the application to know which is the current version of deployment. So let's say I have a running k8s cluster with multiple pods in it, a config-map is there which has all the configuration details against those pods (image version, namespace, etc.) and a flag notifying that this the current deployment and the application inside <strong>POD-A</strong> will know that by loading the config-map. Now when a new config-file is pulled a new config-map is created and the flag for current deployment is set to false for the previous config map and is set to true for the latest created config map. Then that config map is used to update all the pods in the cluster.</p>

<p>I know there are a lot of details but I had to explain them to ask the following questions:</p>

<p>1) Can <code>configmaps</code> be used for this purpose?</p>

<p>2) Can I update <code>configmaps</code> or do I have to rewrite them completely? I am thinking of writing a file in the <code>configmap</code> because that would be much simpler.</p>

<p>3) I know <code>configmaps</code> are stored in etcd but are they persisted on disk or are kept in memory?</p>

<p>4) Let's say <strong>POD-A</strong> goes down will it have any effect on the <code>configmaps</code>? Are they in any way associated with the life cycle of a pod?</p>

<p>5) If the k8s cluster itself goes down what happens to the `configmaps? Since they are in <strong>etcd</strong> and if they are persisted then will they be available again?</p>

<p>Note: There is also a <a href="https://github.com/kubernetes/kubernetes/issues/19781#issuecomment-172553264" rel="nofollow noreferrer">limit on the size of configmaps</a> so I have to keep that in mind. Although I am guessing 1MB is a fair enough size to save a config file since it would usually be in a few bytes.</p>

<blockquote>
  <p>1) I think you should not use it in this way.</p>
  
  <p>2) ConfigMaps are kubernetes resources. You can update them.</p>
  
  <p>3) If etcd backups to disk are enabled.</p>
  
  <p>4) No. A pod's lifecycle should not affect configmaps, unless pod mutates(deletes) the configmap. </p>
  
  <p>5) If the cluster itself goes down. Assuming etcd is also running on the same cluster, etcd will not be available till the cluster comes back up again. ETCD has an option to persist backups to disk. If this is enabled, when the etcd comes back up, it will have restored the values that were on the backup. So it should be available once the cluster &amp; etcd is up.</p>
</blockquote>

<p>There are multiple ways to mount configMap in a pod like env variables, file etc.
If you change a config map, Values won't be updated on configMaps as files. Only values for configMaps as env variables are update dynamically. And now the process running in the pod should detect env variable has been updated and take some action.</p>

<p>So I think the system will be too complex. </p>

<p>Instead trigger a deployment that kills the old pods and brings up a new pod which uses the updated configMaps.</p>
