<p>I want to update the existing file <code>settings.ini</code> in container at the time of helm deployment without harming existing data in container.</p>
<p>Here are my helm files -</p>
<p><code>config.yaml</code></p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ .Values.metadata.name }}-config
data:
  settings.ini: |
    [server]
    hostname = &quot;localhost&quot;
    hot_deployment = false
    # offset  = 10

    [user_store]
    type = &quot;read_only_ldap&quot;
</code></pre>
<p>deployment part from <code>Deployment.yaml</code></p>
<pre class="lang-yaml prettyprint-override"><code>containers:
  - name: {{ .Chart.Name }}
    securityContext:
      {{- toYaml .Values.securityContext | nindent 12 }}
    image: &quot;{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}&quot;
    imagePullPolicy: {{ .Values.image.pullPolicy }}
    ports:
      - name: http
        containerPort: 80
        protocol: TCP
    volumeMounts:
    - name: config-volume
      mountPath: /home/bin/conf/
      subPath: settings.ini
volumes:
  - name: config-volume
    configMap:
      name: {{ .Values.metadata.name }}-config
</code></pre>
<p>I can see it creating config map successfully but when I check logs in the cluster it complains about missing files</p>
<p>How can I resolve this issue?</p>
<p>Also is there any efficient way to achieve this, if I just want to update some of the configurations for my <code>settings.ini</code> file with different values in different env?</p>

megha
<p>If you are on older version of Kubernetes changing the configmap &amp; secret won't restart your container.</p>
<p>You can manually update the configmap using the YAML apply or using the CLI edit.</p>
<p>Once configmap is updated you can simply apply the helm command to roll out the update and change/udpate the new container. In this case old container wont get affected and changes simply get rollout.</p>
<p>If you are looking for way to automate it, you can use the : <a href="https://github.com/stakater/Reloader" rel="nofollow noreferrer">https://github.com/stakater/Reloader</a></p>
<p>Reloader can watch changes in ConfigMap and Secret and do rolling upgrades on Pods with their associated DeploymentConfigs, Deployments, Daemonsets Statefulsets and Rollouts.</p>
<p>Here is one nice example : <a href="https://github.com/stakater/Reloader/issues/46#issuecomment-457131306" rel="nofollow noreferrer">https://github.com/stakater/Reloader/issues/46#issuecomment-457131306</a></p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx
  annotations:
    configmap.reloader.stakater.com/reload: &quot;nginx-configmap&quot;
  spec:
    selector:
      matchLabels:
      app: nginx
    replicas: 3
    template:
      metadata:
        labels:
          app: nginx
        spec:
          containers:
            name: nginx
            image: nginx
            ports:
              containerPort: 80
            volumeMounts:
              name: nginx-config1
              mountPath: /etc/nginx/conf.d/default.conf
              subPath: default.conf
    volumes:
      name: nginx-config1
      configMap:
        name: nginx-configmap
</code></pre>
