send tomcat conf files to container using kubernetes

风流意气都作罢 提交于 2019-12-13 17:27:29

问题


I am new to docker and Kubernetes, I am trying to create a container having tomcat7/Java7 so that I could deploy my webapps into it. The only concern I have are the tomcat/conf config files, which have details of database connections, threadpool, Java Memory etc.

What I want is to copy these files from Kubernetes server to docker-container and place them at right places, while starting the container.

P.S: I don't want to do it via enviroment variables, as they are going to be huge in numbers if I keep a variable for every entry in config files.


回答1:


You could add a ConfigMap in your Kubernetes, from your tomcat config (files or a whole dir)

kubectl -n staging create configmap special-config --from-file={path-to-tomcat-conf}/server.xml

And then mount it on your pod (kubectl create -f path/to/the/pod.yaml)

apiVersion: v1
kind: Pod
metadata:
 name: tomcat-test-pod
spec:
 containers:
 - name: test-container
   image: tomcat:7.0
   command: [ "catalina.sh", "run" ]
   volumeMounts:
   - name: config-volume
     mountPath: /usr/local/tomcat/conf/server.xml
 volumes:
 - name: config-volume
   configMap:
    # Provide the name of the ConfigMap containing the files you want
    # to add to the container
    name: special-config

Kubernetes docs



来源:https://stackoverflow.com/questions/45751832/send-tomcat-conf-files-to-container-using-kubernetes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!