<p>I have created a configmap and a pod yaml file .</p>

<p>I have tried multiple solutions but none worked for me .</p>

<pre><code>kubectl describe cm cf3
Name:         cf3
Namespace:    default
Labels:       &lt;none&gt;
Annotations:  &lt;none&gt;

Data
====
index.html:
----
hii im marimmo

Events:  &lt;none
</code></pre>

<blockquote>
  <p>pod yaml file</p>
</blockquote>

<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: dapi-test-pod
spec:
  containers:
  - name: test-container
    image: manya97/manya_tomcat:0.1

  volumeMounts:
  - name: config-volume
    mountPath: /apache-tomcat-8.0.32/webapps/SampleWebApp/index.html
    subPath: index.html
volumes:
- name: config-volume
  configMap:
          name: cf3

restartPolicy: Never
</code></pre>

<p>this was supposed to replace existing index.html file but somehow it removes all the content of SampleWebApp and places only index.html.
I dont know if have done it in correct way , I want to replace only content of index.html. Might be possible that mounting works this way I do not know .</p>

shubham_asati
<p>Mounts are always directory-based. So having a mount in your yaml file tells k8s to mount the contents of the configMap (which could be one or more files) into the directory.</p>

<p>Whatever has been inside of the directory before the mount is gone then.</p>

<p>See the official documentation here: <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/" rel="nofollow noreferrer">https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/</a></p>

<p>There is a hint saying <strong>"Caution: If there are some files in the mount directory, they will be deleted."</strong></p>
