[英]mountPath property in the Volume Kubernetes
I am learning about Volumes in the Kubernetes
.我正在学习
Kubernetes
中的Kubernetes
。
I understood the concept of Volume and types of volume.我理解了 Volume 的概念和 Volume 的类型。
But, I am confused about the mouthPath
property.但是,我对
mouthPath
属性感到困惑。 Following my YAML
file:按照我的
YAML
文件:
apiVersion: v1
kind: Pod
metadata:
name: nginx-alpine-volume
spec:
containers:
- name: nginx
image: nginx:alpine
volumeMounts:
- name: html
mountPath: /usr/share/nginx/html
readOnly: true
resources:
- name: html-updater
image: alpine
command: ["/bin/sh", "-c"]
args:
- while true; do date >> /mohit/index.html;sleep 10; done
resources:
volumeMounts:
- name: html
mountPath: /mohit
volumes:
- name: html
emptyDir: {}
Question: What is the use of the mountPath
property.问题:
mountPath
属性有什么用。 Here, I am using one pod with two containers.在这里,我使用一个带有两个容器的吊舱。 Both containers have different
mounPath
values.两个容器都有不同的
mounPath
值。
Consider the mount path as the directory where you are attaching or mounting the files or system将挂载路径视为您附加或挂载文件或系统的目录
While your actual volume is emptyDir虽然您的实际音量为emptyDir
What basically the idea is there to both container have different mount path两个容器具有不同的安装路径的基本想法是什么
as both containers need to use different folders因为两个容器都需要使用不同的文件夹
While as your volume is single name html so locally from volume both container pointing or using the different folders由于您的卷是单一名称 html,因此从卷本地指向或使用不同的文件夹
both containers manage the different files at their mounting point (or folder)两个容器在它们的安装点(或文件夹)管理不同的文件
so mount path is a point or directly where your container will be managing files.所以挂载路径是你的容器将管理文件的一个点或直接点。
Empty dir : https://kubernetes.io/docs/concepts/storage/volumes/#emptydir空目录: https : //kubernetes.io/docs/concepts/storage/volumes/#emptydir
Read more at : https://kubernetes.io/docs/tasks/access-application-cluster/communicate-containers-same-pod-shared-volume/阅读更多内容: https : //kubernetes.io/docs/tasks/access-application-cluster/communicate-containers-same-pod-shared-volume/
if you see this example: https://github.com/harsh4870/Kubernetes-wordpress-php-fpm-nginx/blob/master/wordpress-deployment.yaml如果你看到这个例子: https : //github.com/harsh4870/Kubernetes-wordpress-php-fpm-nginx/blob/master/wordpress-deployment.yaml
it has the same two containers with mount path and emptydir volume它具有相同的两个容器,带有挂载路径和emptydir卷
what i am doing is attaching the Nginx configuration file, to the container so Nginx will use that configuration file which i am mounting from outside to the container.我正在做的是将 Nginx 配置文件附加到容器,以便 Nginx 将使用我从外部安装到容器的配置文件。
My config file stored inside configmap or secret .我的配置文件存储在configmap或secret 中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.