我正在尝试根据我的kompose文件创建一个部署,但是只要我尝试:
kompose convert -f docker-compose.yaml
我得到了错误:
Volume mount on the host "[file directory]" isn't supported - ignoring path on the host
我已经尝试了几种不同的解决方案,首先尝试将hostPath
添加到我的kompose convert
中,并使用持久卷,但是这两种方法都不起作用。
我的kompose文件如下:
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
annotations:
kompose.cmd: kompose convert -f docker-compose.yaml --volumes emptyDir
kompose.version: 1.7.0 (HEAD)
creationTimestamp: null
labels:
io.kompose.service: es01
name: es01
spec:
replicas: 1
strategy:
type: Recreate
template:
metadata:
creationTimestamp: null
labels:
io.kompose.service: es01
spec:
containers:
- env:
- name: COMPOSE_CONVERT_WINDOWS_PATHS
value: "1"
- name: COMPOSE_PROJECT_NAME
value: elastic_search_container
- name: ES_JAVA_OPTS
value: -Xms7g -Xmx7g
- name: discovery.type
value: single-node
- name: node.name
value: es01
image: docker.elastic.co/elasticsearch/elasticsearch:7.2.1
name: es01
ports:
- containerPort: 9200
resources: {}
volumeMounts:
- mountPath: /usr/share/elasticsearch/data
name: es01-empty0
restartPolicy: Always
volumes:
- emptyDir: {}
name: es01-empty0
status: {}
我正在使用kompose版本1.7.0
我的Docker Compose版本:
version: '3'
services:
es01:
image: docker.elastic.co/elasticsearch/elasticsearch:7.2.1
container_name: es01
environment:
- node.name=es01
- COMPOSE_PROJECT_NAME=elastic_search_container
- discovery.type=single-node
- "ES_JAVA_OPTS=-Xms7g -Xmx7g"
- COMPOSE_CONVERT_WINDOWS_PATHS=1
ulimits:
nproc: 3000
nofile: 65536
memlock: -1
volumes:
- /home/centos/Sprint0Demo/Servers/elasticsearch:/usr/share/elasticsearch/data
ports:
- 9200:9200
networks:
- kafka_demo
答案 0 :(得分:1)
您需要查看警告信息:
Volume mount on the host "[file directory]" isn't supported - ignoring path on the host
在docker-compose.yaml
中的卷配置了直接路径时会发生。
以下示例:
version: '3'
services:
web:
build: .
ports:
- "5000:5000"
volumes:
- "./storage1:/test1"
- "./storage2:/test2"
redis:
image: "redis:alpine"
volumes:
storage1:
storage2:
看看以下链接:Conversion matrix。
它描述了kompose
如何将Docker的卷转换为Kubernetes的卷。
不使用参数--volumes
执行转换命令:
$ kompose convert -f docker-compose.yml
使用kompose
1.19输出将产生:
WARN Volume mount on the host "SOME_PATH" isn't supported - ignoring path on the host
WARN Volume mount on the host "SOME_PATH" isn't supported - ignoring path on the host
INFO Kubernetes file "web-service.yaml" created
INFO Kubernetes file "redis-deployment.yaml" created
INFO Kubernetes file "web-deployment.yaml" created
INFO Kubernetes file "web-claim0-persistentvolumeclaim.yaml" created
INFO Kubernetes file "web-claim1-persistentvolumeclaim.yaml" created
警告消息表示您正在明确告诉docker-compose
创建具有直接路径的卷。默认情况下,kompose
会将Docker的卷转换为Persistent Volume Claim。
使用--volumes emptyDir
参数执行转换命令:
$ kompose convert -f docker-compose.yml --volumes emptyDir
将产生屈服效果:
WARN Volume mount on the host "SOME_PATH" isn't supported - ignoring path on the host
WARN Volume mount on the host "SOME_PATH" isn't supported - ignoring path on the host
INFO Kubernetes file "web-service.yaml" created
INFO Kubernetes file "redis-deployment.yaml" created
INFO Kubernetes file "web-deployment.yaml" created
kompose
将在web-deployment.yaml中创建emptyDir声明,而不是像默认情况那样创建单独的PVC定义。
使用--volumes hostPath
参数执行转换命令:
$ kompose convert -f docker-compose.yml --volumes hostPath
将产生屈服效果:
INFO Kubernetes file "web-service.yaml" created
INFO Kubernetes file "redis-deployment.yaml" created
INFO Kubernetes file "web-deployment.yaml" created
如您所见,没有关于不支持的路径的警告。没有警告,因为它使用您自己提供的docker-compose.yml
路径显式创建了hostPath。
看看web-deployment.yaml
卷部分:
volumes:
- hostPath:
path: /LOCAL_PATH-/POD_PATH/storage1
name: web-hostpath0
- hostPath:
path: /LOCAL_PATH-/POD_PATH/storage2
name: web-hostpath1