pod 应该不关心主机的文件系统, 但是系统级的 pod 需要.

6.3.1 介绍 hostPath 卷

hostPath 卷指向节点文件系统上的特定文件或目录.

image.png

删除 pod 后主机上的文件保留.

注意数据库 pod 使用卷的方式.

6.3.2 检查使用 hostPath 卷的系统 pod

  1. 列出 pod
  1. $ kubectl get pods --namespace kube-system
  2. NAME READY STATUS RESTARTS AGE
  3. coredns-74ff55c5b-hxsrg 1/1 Running 5 4d22h
  4. etcd-minikube 0/1 Running 5 4d22h
  5. ingress-nginx-admission-create-g7vtb 0/1 Completed 0 46h
  6. ingress-nginx-admission-patch-65rxm 0/1 Completed 0 46h
  7. ingress-nginx-controller-65cf89dc4f-7mnlz 0/1 ImagePullBackOff 0 46h
  8. kube-apiserver-minikube 1/1 Running 5 4d22h
  9. kube-controller-manager-minikube 0/1 Running 5 4d22h
  10. kube-proxy-zctp7 1/1 Running 5 4d22h
  11. kube-scheduler-minikube 0/1 Running 5 4d22h
  12. metrics-server-56c4f8c9d6-mxtqq 0/1 ImagePullBackOff 0 4d
  13. storage-provisioner 1/1 Running 10 4d22h

有错误?

image.png

  1. 查看使用的卷

image.png

  1. $ kubectl describe po etcd-minikube --namespace kube-system
  2. ...
  3. Volumes:
  4. etcd-certs:
  5. Type: HostPath (bare host directory volume)
  6. Path: /var/lib/minikube/certs/etcd
  7. HostPathType: DirectoryOrCreate
  8. etcd-data:
  9. Type: HostPath (bare host directory volume)
  10. Path: /var/lib/minikube/etcd
  11. HostPathType: DirectoryOrCreate
  12. ....