<p>I have a folder in my project, which contains 1 properties file and 1 jar file(db-driver) file.</p>
<p>I need to copy both of these files to /usr/local/tomcat/lib directory on my pod. I am not sure how to achieve this in kubernetes yaml file. Below is my yaml file where I am trying to achieve this using configMap, but pod creation fails with error &quot;configmap references non-existent config key: app.properties&quot;</p>
<p>Target <code>/usr/local/tomcat/lib</code> already has other jar files so I am trying to use configMap to not override entire directory and just add 2 files which are specific to my application.</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: tomcatdeployment
  labels:
    app:  tomcat
spec:
  replicas: 1
  selector:
    matchLabels:
      app:  tomcat
  template:
    metadata:
      labels:
        app:  tomcat
    spec:
      containers:
        - name: tomcat
          image: tomcat:latest
          imagePullPolicy: IfNotPresent
          volumeMounts:
          - name: appvolume
            mountPath: /usr/local/data
          - name: config
            mountPath: /usr/local/tomcat/lib
            subPath: ./configuration
          ports:
            - name: http
              containerPort: 8080
              protocol: TCP
      volumes:
        - name: appvolume
        - name: config
          configMap:
            name: config-map
            items:
              - key: app.properties
                path: app.properties
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: config-map
data:
  key:  app.properties

</code></pre>
<p>Current Directory structure...</p>
<pre><code>.
├── configuration
│   ├── app.properties
│   └── mysql-connector-java-5.1.21.jar
├── deployment.yaml
└── service.yaml

</code></pre>
<p>Please share your valuable feedback on how to achieve this.</p>
<p>Regards.</p>

user3552454
<p>Please try this:</p>

<p><strong>kubectl create configmap config-map --from-file=app.properties --from-file=mysql-connector-java-5.1.21.jar</strong></p>

<pre><code>    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: tomcatdeployment
      labels:
        app:  tomcat
    spec:
      replicas: 1
      selector:
        matchLabels:
          app:  tomcat
      template:
        metadata:
          labels:
            app:  tomcat
        spec:
          containers:
            - name: tomcat
              image: tomcat:latest
              imagePullPolicy: IfNotPresent
              volumeMounts:
              - name: config
                mountPath: /usr/local/tomcat/lib/conf
              ports:
                - name: http
                  containerPort: 8080
                  protocol: TCP
          volumes:
            - name: config
              configMap:
                name: config-map
</code></pre>

<p>or</p>

<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: tomcatdeployment
  labels:
    app:  tomcat
spec:
  replicas: 1
  selector:
    matchLabels:
      app:  tomcat
  template:
    metadata:
      labels:
        app:  tomcat
    spec:
      containers:
        - name: tomcat3
          image: tomcat:latest
          imagePullPolicy: IfNotPresent
          volumeMounts:
          - name: config
            mountPath: /usr/local/tomcat/lib/app.properties
            subPath: app.properties
          - name: config
            mountPath: /usr/local/tomcat/lib/mysql-connector-java-5.1.21.jar
            subPath: mysql-connector-java-5.1.21.jar
          ports:
            - name: http
              containerPort: 8080
              protocol: TCP
      volumes:
        - name: config
          configMap:
            name: config-map
            items:
            - key: app.properties
              path: app.properties 
            - key: mysql-connector-java-5.1.21.jar
              path: mysql-connector-java-5.1.21.jar
</code></pre>
