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.
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