Docker 如何使用emptyDir在kubernetes上装载卷
我正在尝试使用kompose文件创建展开,但无论何时尝试:Docker 如何使用emptyDir在kubernetes上装载卷,docker,kubernetes,docker-volume,Docker,Kubernetes,Docker Volume,我正在尝试使用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文件如下所示:
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撰写版本:
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
您需要查看您收到的警告:
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:
持续性批量索赔
请查看此链接:。
它描述了kompose
如何将Docker的卷转换为Kubernetes卷
执行转换命令时不带--卷
参数:
$kompose convert-f docker compose.yml
使用kompose
1.19输出将产生:
警告主机上的卷装载“某些路径”不受支持-忽略主机上的路径
警告主机上的卷装载“某些路径”不受支持-忽略主机上的路径
创建了INFO Kubernetes文件“webservice.yaml”
创建了INFO Kubernetes文件“redis deployment.yaml”
创建了INFO Kubernetes文件“webdeployment.yaml”
创建了INFO Kubernetes文件“web-claim0-persistentvolumeclaim.yaml”
创建了INFO Kubernetes文件“web-claim1-persistentvolumeclaim.yaml”
警告消息意味着您明确告知docker compose使用直接路径创建卷。默认情况下,kompose
将Docker的音量转换为
空的
使用--volumes emptyDir
参数执行转换命令:
$kompose convert-f docker-compose.yml--卷清空dir
将产生以下效果:
INFO Kubernetes file "web-service.yaml" created
INFO Kubernetes file "redis-deployment.yaml" created
INFO Kubernetes file "web-deployment.yaml" created
警告主机上的卷装载“某些路径”不受支持-忽略主机上的路径
警告主机上的卷装载“某些路径”不受支持-忽略主机上的路径
创建了INFO Kubernetes文件“webservice.yaml”
创建了INFO Kubernetes文件“redis deployment.yaml”
创建了INFO Kubernetes文件“webdeployment.yaml”
kompose
将在web-deployment.yaml中创建声明,而不是像默认情况下那样创建单独的PVC定义
主机路径
使用--volumes hostPath
参数执行转换命令:
$kompose convert-f docker-compose.yml--卷主机路径
将产生以下效果:
INFO Kubernetes file "web-service.yaml" created
INFO Kubernetes file "redis-deployment.yaml" created
INFO Kubernetes file "web-deployment.yaml" created
正如您所看到的,没有关于不受支持路径的警告。没有警告,因为它是使用您自己提供的路径从docker compose.yml
显式创建的
查看web部署.yaml
卷部分:
volumes:
- hostPath:
path: /LOCAL_PATH-/POD_PATH/storage1
name: web-hostpath0
- hostPath:
path: /LOCAL_PATH-/POD_PATH/storage2
name: web-hostpath1
您需要查看您收到的警告:
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:
持续性批量索赔
请查看此链接:。
它描述了kompose
如何将Docker的卷转换为Kubernetes卷
执行转换命令时不带--卷
参数:
$kompose convert-f docker compose.yml
使用kompose
1.19输出将产生:
警告主机上的卷装载“某些路径”不受支持-忽略主机上的路径
警告主机上的卷装载“某些路径”不受支持-忽略主机上的路径
创建了INFO Kubernetes文件“webservice.yaml”
创建了INFO Kubernetes文件“redis deployment.yaml”
创建了INFO Kubernetes文件“webdeployment.yaml”
创建了INFO Kubernetes文件“web-claim0-persistentvolumeclaim.yaml”
创建了INFO Kubernetes文件“web-claim1-persistentvolumeclaim.yaml”
警告消息意味着您明确告知docker compose使用直接路径创建卷。默认情况下,kompose
将Docker的音量转换为
空的
使用--volumes emptyDir
参数执行转换命令:
$kompose convert-f docker-compose.yml--卷清空dir
将产生以下效果:
INFO Kubernetes file "web-service.yaml" created
INFO Kubernetes file "redis-deployment.yaml" created
INFO Kubernetes file "web-deployment.yaml" created
警告主机上的卷装载“某些路径”不受支持-忽略主机上的路径
警告主机上的卷装载“某些路径”不受支持-忽略主机上的路径
创建了INFO Kubernetes文件“webservice.yaml”
创建了INFO Kubernetes文件“redis deployment.yaml”
创建了INFO Kubernetes文件“webdeployment.yaml”
kompose
将在web-deployment.yaml中创建声明,而不是像默认情况下那样创建单独的PVC定义
主机路径
使用--volumes hostPath
参数执行转换命令:
$kompose convert-f docker-compose.yml--卷主机路径
将产生以下效果:
INFO Kubernetes file "web-service.yaml" created
INFO Kubernetes file "redis-deployment.yaml" created
INFO Kubernetes file "web-deployment.yaml" created
正如您所看到的,没有关于不受支持路径的警告。没有警告,因为它是使用您自己提供的路径从docker compose.yml
显式创建的
查看web部署.yaml
卷部分:
volumes:
- hostPath:
path: /LOCAL_PATH-/POD_PATH/storage1
name: web-hostpath0
- hostPath:
path: /LOCAL_PATH-/POD_PATH/storage2
name: web-hostpath1
您发布的是转换后的样子,那么在您尝试创建部署对象并旋转pod之前呢?实际上,从卷装载的角度来看,它可能会工作,因为配置似乎还可以。根据互联网上的一些帖子(如果你可以信任他们),可以安全地忽略来自kompose的消息。你使用的是什么版本的kompose?我使用的是kompose版本1.7.0。你可以提供docker-compose.yaml的卷部分吗?你发布的是转换后的样子,那么在您尝试创建部署对象并旋转吊舱之前呢?实际上,从卷装载的角度来看,它可能会工作,因为配置似乎还可以。根据互联网上的一些帖子(如果你可以信任他们的话),来自kompose的信息可以被安全地屏蔽