我正在尝试将应用程序部署到kubernetes集群,我想将数据存储在Persistent Volume中.但是,我对设置中的两个参数非常困惑.有人可以解释之间有什么不同volumes.hostPath和volumeMounts.mountPath?我在网上阅读了一些文件,但这对我没有帮助.
volumeMounts:
- mountPath: /var/lib/mysql
volumes:
hostPath:
path: /k8s
Run Code Online (Sandbox Code Playgroud)
如果我的设置如上,是否将安装卷/k8s/var/lib/mysql?
装载路径始终是装入卷的Pod内的目标.
我认为文档非常清楚hostPath的作用:
hostPath卷将文件或目录从主机节点的文件系统安装到Pod中.这不是大多数Pod需要的东西,但它为某些应用程序提供了强大的逃生舱.
例如,hostPath的一些用途是:
Run Code Online (Sandbox Code Playgroud)- running a Container that needs access to Docker internals; use a hostPath of /var/lib/docker - running cAdvisor in a Container; use a hostPath of /sys - allowing a Pod to specify whether a given hostPath should exist prior to the Pod running, whether it should be created, and what it should exist as
所以你的例子并不是你的想法.它会将节点的/k8s目录挂载到Pod中/var/lib/mysql.
只有在您完全理解其含义时才应该这样做!
| 归档时间: |
|
| 查看次数: |
3944 次 |
| 最近记录: |