hostpath 类型是在每个节点坐在的主机上都创建了相应的目录,具体查看 kubectl explain pods.spec.volumes.hostPath

apiVersion: v1
kind: Pod
metadata: 
  name: pod-vol-hostpath
  namespace: default
spec:
  containers:
  - name: myapp
    image: nginx:latest
    imagePullPolicy: IfNotPresent
    volumeMounts:
    - name: html
      mountPath: /usr/share/nginx/html/ # Pod中的目录
    ports:
    - name: http
      containerPort: 80
  volumes:
  - name: html
    hostPath: 
      path: /data/html # 节点上的目录
      type: DirectoryOrCreate # 没有该目录则创建该目录