HostPath

HostPath数据卷允许将容器宿主机上的文件系统挂载到Pod中。如果Pod需要使用宿主机上的某些文件,可以使用HostPath数据卷。

清单文件

apiVersion: v1
kind: Pod
metadata:
  name: myapp-vol-hp
  namespace: default
spec:
  containers:
  - name: myapp
    image: ikubernetes/myapp:v1
    volumeMounts:
    - name: html-vol
      mountPath: /usr/share/nginx/html/
  volumes:
  - name: html-vol
    hostPath:
      path: /data/pod/html-vol
      # 支持多种类型,见下面补充说明
      type: DirectoryOrCreate

补充说明

volumes.hostPath.type

|类型|描述| |DirectoryOrCreate|If nothing exists at the given path, an empty directory will be created there as needed with permission set to 0755, having the same group and ownership with Kubelet.| |Directory|A directory must exist at the given path| |FileOrCreate|If nothing exists at the given path, an empty file will be created there as needed with permission set to 0644, having the same group and ownership with Kubelet.| |File|A file must exist at the given path| |Socket|A UNIX socket must exist at the given path| |CharDevice|A character device must exist at the given path| |BlockDevice|A block device must exist at the given path|

results matching ""

    No results matching ""