使用kubernetes将tomcat conf文件发送到容器

我是docker工人和Kubernetes的新手,我正在尝试创build一个具有tomcat7/Java7的容器,以便我可以将我的webapps部署到其中。 我唯一担心的是tomcat/confconfiguration文件,它有database connectionsthreadpoolJava Memory等细节。

我想要的是将这些文件从Kubernetes服务器复制到docker-container,并将它们放在正确的位置,同时启动容器。

PS:我不想通过环境variables来实现,因为如果我在configuration文件中为每个条目保留一个variables,它们的数量将会非常庞大​​。

你可以在你的Kubernetes中添加一个ConfigMap,从你的tomcatconfiguration(文件或整个目录)

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

然后将其挂载到您的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文档