[英]Expose folder from a container as a volume in a Kubernetes Pod
I have a pod which contains two containers.我有一个包含两个容器的 pod。 One container is a web application and another store some static data for this web application.
一个容器是 web 应用程序,另一个容器存储此 web 应用程序的一些 static 数据。
The data here is a set of files which are stored in the folder of this container with name /data
and that's only function of the container to store this data and expose them to the web application.此处的数据是一组文件,它们存储在此容器的文件夹中,名称为
/data
,并且仅容器的 function 用于存储此数据并将它们公开给 web 应用程序。
I'm looking for the way to share the content of this folder with web application container in this pod.我正在寻找与此 pod 中的 web 应用程序容器共享此文件夹内容的方法。
If I'm using the YAML spec below the folder in both containers is empty.如果我使用 YAML 规范,则两个容器中的文件夹下方都是空的。 Is there a way to share the data from container folder without cleaning it up?
有没有办法在不清理容器文件夹的情况下共享数据?
apiVersion: v1
kind: Pod
metadata:
name: my-pod
labels:
app: my-app
version: 1.2.3
spec:
volumes:
- name: my-app-data-volume
containers:
- name: my-app-server
image: my-app-server-container-name
volumeMounts:
- name: my-app-data-volume
mountPath: /data
ports:
- containerPort: 8080
- name: my-app-data
image: my-app-data-container-name
volumeMounts:
- name: my-app-data-volume
mountPath: /data
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.