經過describe命令學習Kubernetes的pod屬性詳解

咱們能夠首先使用kubectl get pods命令獲得pod列表,好比咱們想研究pod nginx-storage-pod的明細:html

使用命令kubectl describe pod nginx-storage-pod > nginx-storage-pod.yaml, 將describe命令的輸出重定向到一個yaml文件裏。用vi打開這個yaml文件:node

pod的全部屬性能夠從這個yaml文件裏學習:nginx

node:shoot--k8s-train--shacw46-worker-prvfv-z1-7844dc6744-ghd5m/10.250.0.6docker

代表pod所在的node,這個node必定是命令kubectl get node返回的結果之一:oop

image

Image:表明該pod是基於哪個docker image建立的。學習

Mount:該pod使用的persistent volume對應的物理文件目錄,個人例子是.usr/share/nginx/htmlrest

這個路徑從哪裏來的呢?就是個人pod文件的yaml文件裏的定義:htm

describe命令除了本文介紹的能夠用來深刻學習pod的屬性外,還能夠用於pod不能正常啓動時的錯誤排查。blog

好比我有一個pod名爲another3,狀態一直處於CrashLoopBackOff, RESTART次數爲12:get

使用kubectl describe pod another3就能夠看到這個容器啓動的明細:Back-off restarting failed container

仔細檢查pod的yaml文件,發現緣由是由於我定義了volume的name爲content-storage,可是沒有指定persistentvolumeclaim。當我把volumes: - name: content-storage刪除以後,

下圖是修改後的yaml文件:

從新建立名爲another3的pod,很快就建立成功而且狀態處於running了:

要獲取更多Jerry的原創文章,請關注公衆號"汪子熙":

相關文章
相關標籤/搜索