This documentation is for a release that is no longer maintained
See documentation for the latest supported version 3 or the latest supported version 4.3.4.4. 声明作为卷
pod 通过将声明作为卷来访问存储。使用声明时,声明必须存在于与 pod 相同的命名空间中。集群在 pod 的命名空间中找到声明,并使用它来使用这个声明后台的PersistentVolume
。卷被挂载到主机和 pod 中,例如:
挂载卷到主机和 pod 示例
kind: Pod apiVersion: v1 metadata: name: mypod spec: containers: - name: myfrontend image: dockerfile/nginx volumeMounts: - mountPath: "/var/www/html" name: mypd volumes: - name: mypd persistentVolumeClaim: claimName: myclaim
kind: Pod
apiVersion: v1
metadata:
name: mypod
spec:
containers:
- name: myfrontend
image: dockerfile/nginx
volumeMounts:
- mountPath: "/var/www/html"
name: mypd
volumes:
- name: mypd
persistentVolumeClaim:
claimName: myclaim