hostPath Volume - 天天5分鐘玩轉 Docker 容器技術(148)

hostPath Volume 的做用是將 Docker Host 文件系統中已經存在的目錄 mount 給 Pod 的容器。大部分應用都不會使用 hostPath Volume,由於這實際上增長了 Pod 與節點的耦合,限制了 Pod 的使用。不過那些須要訪問 Kubernetes 或 Docker 內部數據(配置文件和二進制庫)的應用則須要使用 hostPath。html

好比 kube-apiserver 和 kube-controller-manager 就是這樣的應用,經過api

kubectl edit --namespace=kube-system pod kube-apiserver-k8s-master

查看 kube-apiserver Pod 的配置,下面是 Volume 的相關部分:學習

這裏定義了三個 hostPath volume k8scerts 和 pki,分別對應 Host 目錄 /etc/kubernetes/etc/ssl/certs 和 /etc/pkispa

若是 Pod 被銷燬了,hostPath 對應的目錄也還會被保留,從這點看,hostPath 的持久性比 emptyDir 強。不過一旦 Host 崩潰,hostPath 也就無法訪問了。code

下一節咱們將學習具有真正持久性的 Volume。server

書籍:htm

1.《天天5分鐘玩轉Kubernetes》
https://item.jd.com/26225745440.htmlblog

2.《天天5分鐘玩轉Docker容器技術》
https://item.jd.com/16936307278.htmlssl

3.《天天5分鐘玩轉OpenStack》
https://item.jd.com/12086376.htmlget

相關文章
相關標籤/搜索