Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/307.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 使用kubernetes将tomcat conf文件发送到容器_Java_Docker_Tomcat7_Kubernetes_Docker Container - Fatal编程技术网

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

Java 使用kubernetes将tomcat conf文件发送到容器,java,docker,tomcat7,kubernetes,docker-container,Java,Docker,Tomcat7,Kubernetes,Docker Container,我是docker和Kubernetes的新手,我正在尝试创建一个包含tomcat7/Java7的容器,以便将我的WebApp部署到其中。我唯一关心的是tomcat/conf配置文件,其中包含数据库连接、线程池、Java内存等的详细信息 我想要的是将这些文件从Kubernetes服务器复制到docker容器中,并在启动容器时将它们放置在正确的位置 注:我不想通过环境变量来实现这一点,因为如果我在配置文件中的每个条目都保留一个变量,那么它们的数量将是巨大的。您可以从tomcat配置文件或整个目录在K

我是docker和Kubernetes的新手,我正在尝试创建一个包含tomcat7/Java7的容器,以便将我的WebApp部署到其中。我唯一关心的是tomcat/conf配置文件,其中包含数据库连接、线程池、Java内存等的详细信息

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


注:我不想通过环境变量来实现这一点,因为如果我在配置文件中的每个条目都保留一个变量,那么它们的数量将是巨大的。

您可以从tomcat配置文件或整个目录在Kubernetes中添加一个配置映射

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

您可以从tomcat配置文件或整个目录在Kubernetes中添加ConfigMap

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