<p>When using a ConfigMap as a mounted volume, all the existing files and folders inside the mounted location of the pod are deleted.</p>

<p>The ConfigMap is created using the command :</p>

<pre><code>$ kubectl create configmap tomcat-configmap --from-file=./config/tomcat-config.xml
</code></pre>

<p>The deployement yaml file : </p>

<pre><code>kind: Service
apiVersion: v1
metadata:
  name: tomcat-svc
spec:
  selector:
    app: tomcat-container
  ports:
  - protocol: TCP
    port: 83
    targetPort: 8080
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: tomcat-deployment
spec:
  selector:
    matchLabels:
      app: tomcat-container
  replicas: 1
  template:
    metadata:
      labels:
        app: tomcat-container
    spec:
      containers:
      - name: tomcat
        image: bitnami/tomcat:latest
        ports:
        - containerPort: 8080
        volumeMounts:
        - name: tomcat-configmap-volume
          mountPath: /usr/local/tomcat/webapps/examples/WEB-INF/classes/com/test/app-conf.xml
          subPath: app-conf.xml
      volumes:
        - name: tomcat-configmap-volume
          configMap:
            name: tomcat-configmap
</code></pre>

<p>I tried different config but without success :(</p>

<p>Any suggestion would be very helpful</p>

<p>I am using kubernetes provided with docker for windows :</p>

<pre><code>Client Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.3", GitCommit:"2bba0127d85d5a46ab4b778548be28623b32d0b0", GitTreeState:"clean", BuildDate:"2018-05-21T09:17:39Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"windows/amd64"}

Server Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.3", GitCommit:"2bba0127d85d5a46ab4b778548be28623b32d0b0", GitTreeState:"clean", BuildDate:"2018-05-21T09:05:37Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"linux/amd64"}
</code></pre>

<pre><code>kind: Service
apiVersion: v1
metadata:
  name: tomcat-svc
spec:
  selector:
  app: tomcat-container
  ports:
  - protocol: TCP
    port: 8080
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: tomcat-deployment
spec:
  selector:
    matchLabels:
      app: tomcat-container
  replicas: 1
  template:
    metadata:
      labels:
        app: tomcat-container
    spec:
  containers:
  - name: tomcat
    image: bitnami/tomcat:latest
    ports:
    - containerPort: 8080
    volumeMounts:
    - name: tomcat-configmap-volume
      mountPath: /usr/local/tomcat/webapps/examples/WEB-INF/classes/com/test
      #subPath: app-conf.xml
  volumes:
    - name: tomcat-configmap-volume
      configMap:
        name: tomcat-configmap
</code></pre>

<p>The answer provided above by Rico should work, anyways I am providing the implementation result below :</p>

<p>Comment out the subpath, subpath is really useful when you want to override an existing config file. Also, your tomcat path is /opt/bitnami/tomcat in the image that you are using, and you are mounting a file in a custom dynamically created location in /usr/local/tomcat/ , not sure what you mean by it is overriding the contents </p>

<p><a href="https://i.stack.imgur.com/vtOfA.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vtOfA.jpg" alt="Screenshot"></a></p>
