当使用 ConfigMap 作为挂载卷时,pod 挂载位置内的所有现有文件和文件夹都将被删除。
ConfigMap 是使用以下命令创建的:
$ kubectl create configmap tomcat-configmap --from-file=./config/tomcat-config.xml
部署 yaml 文件:
kind: Service
apiVersion: v1
metadata:
name: tomcat-svc
spec:
selector:
app: tomcat-container
ports:
- protocol: TCP
port: 83
targetPort: 8080
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: tomcat-deployment
spec:
selector:
matchLabels:
app: tomcat-container
replicas: 1
template:
metadata:
labels:
app: tomcat-container
spec:
containers:
- name: tomcat
image: bitnami/tomcat:latest
ports:
- containerPort: 8080
volumeMounts:
- name: tomcat-configmap-volume
mountPath: /usr/local/tomcat/webapps/examples/WEB-INF/classes/com/test/app-conf.xml
subPath: app-conf.xml
volumes:
- name: tomcat-configmap-volume
configMap:
name: tomcat-configmap
我尝试了不同的配置但没有成功:(
任何建议都会非常有帮助
我正在使用随 docker for windows 提供的 kubernetes:
Client Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.3", GitCommit:"2bba0127d85d5a46ab4b778548be28623b32d0b0", GitTreeState:"clean", BuildDate:"2018-05-21T09:17:39Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"windows/amd64"}
Server Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.3", GitCommit:"2bba0127d85d5a46ab4b778548be28623b32d0b0", GitTreeState:"clean", BuildDate:"2018-05-21T09:05:37Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"linux/amd64"}