支持的 type
空字符串
向后兼容,挂载之前不会执行检查
DirectoryOrCreate
给定的目录不存在,就创建一个
Directory
给定的目录必须存在
FileOrCreate
给定的文件不存在,就创建一个
File
给定的文件必须存在
Socket
CharDevice
BlockDevice

示例

locatime

  1. apiVersion: v1
  2. kind: Pod
  3. metadata:
  4. name: pod-hostpath
  5. spec:
  6. volumes:
  7. - name: date-file
  8. hostPath:
  9. path: /etc/localtime
  10. type: File
  11. containers:
  12. - name: pod-hostpath-c1
  13. image: busybox
  14. command: ["/bin/sh","-c","sleep 600"]
  15. volumeMounts:
  16. - name: date-file
  17. mountPath: /etc/localtime