app.xml would be copied as path#app.xml to /usr/local/tomcat/conf/Catalina/localhost of target pod

app.xml
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<Context docBase="${catalina.base}/webapps/app" debug="0" reloadable="false" useHttpOnly="true"
clearReferencesHttpClientKeepAliveThread="true"
clearReferencesStopThreads="true" clearReferencesStopTimerThreads="true">
</Context>
lets create configmap from above app.xml
D:\practices\kubernetes\demo>kubectl create configmap app-config --from-file=app.xml
configmap "app-config" created
app.yml
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: tomcat
namespace: default
spec:
replicas: 1
selector:
matchLabels:
run: tomcat
template:
metadata:
labels:
run: tomcat
spec:
containers:
- image: tomcat:8.5
name: tomcat
volumeMounts:
- name: my-config
mountPath: /usr/local/tomcat/conf/Catalina/localhost/path#app.xml
subPath: app.xml
volumes:
- name: my-config
configMap:
name: app-config
Lets apply the above deployment
D:\practices\kubernetes\demo>kubectl apply -f app.yml
deployment.extensions "tomcat" created
pods created
D:\practices\kubernetes\demo>kubectl get pods
NAME READY STATUS RESTARTS AGE
tomcat-65886c9fd5-l2zjq 1/1 Running 0 32s
lets see if the file is copied correctly
D:\practices\kubernetes\demo>kubectl exec -it tomcat-65886c9fd5-l2zjq bash
root@tomcat-65886c9fd5-l2zjq:/usr/local/tomcat# cd conf/Catalina/localhost/
root@tomcat-65886c9fd5-l2zjq:/usr/local/tomcat/conf/Catalina/localhost# ls
path#app.xml
root@tomcat-65886c9fd5-l2zjq:/usr/local/tomcat/conf/Catalina/localhost# cat path#app.xml
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<Context docBase="${catalina.base}/webapps/app" debug="0" reloadable="false" useHttpOnly="true"
clearReferencesHttpClientKeepAliveThread="true"
clearReferencesStopThreads="true" clearReferencesStopTimerThreads="true">
</Context>
root@tomcat-65886c9fd5-l2zjq:/usr/local/tomcat/conf/Catalina/localhost# exit
