title: Persistence of Configmap in kubernetes
body: <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>