1. 程式人生 > >使用describe命令進行Kubernetes pod錯誤排查

使用describe命令進行Kubernetes pod錯誤排查

我有一個pod名叫another,用kubectl create建立後發現過了29分鐘,狀態還是處於ContainerCreating階段。

使用kubectl describe命令檢查:

從錯誤訊息發現是因為這個pod attach volume失敗:

FailedAttachVolume 2m1s (x22 over 31m) attachdetach-controller AttachVolume.Attach failed for volume “pvc-c4d41f5c-e7ed-11e8-8726-fe6d42bf075f” : googleapi: Error 400: RESOURCE_IN_USE_BY_ANOTHER_RESOURCE - The disk resource ‘projects/sap-pi-coo-acdc-dev/zones/europe-west1-b/disks/shoot–k8s-train–shac-pvc-c4d41f5c-e7ed-11e8-8726-fe6d42bf075f’ is already being used by ‘projects/sap-pi-coo-acdc-dev/zones/europe-west1-b/instances/shoot–k8s-train–shacw46-worker-prvfv-z1-7844dc6744-ghd5m’

Warning FailedMount 31s (x14 over 29m) kubelet, shoot–k8s-train–shacw46-worker-prvfv-z1-7844dc6744-hhrmd Unable to mount volumes for pod “another_part-0110(13f15fa4-e819-11e8-8726-fe6d42bf075f)”: timeout expired waiting for volumes to attach or mount for pod “part-0110”/“another”. list of unmounted volumes=[content-storage]. list of unattached volumes=[content-storage default-token-6z5sk]

檢視這個pod的yaml檔案,果然發現有一個persistent volume的claim:

用命令kubectl get pv, 發現當前所有的persistent volume都被佔用了(BOUND狀態):

解決方案有很多種,處於測試目的,我只是簡單地將另一個同樣聲明瞭nginx-pvc作為PersistentVolumeClaim的pod刪除,然後這個名為another的pod狀態就很快變成Running了:

從describe命令生成的日誌裡也能清楚的觀察到這個成功mount volume的事件:

Normal SuccessfulAttachVolume 84s attachdetach-controller AttachVolume.Attach succeeded for volume “pvc-c4d41f5c-e7ed-11e8-8726-fe6d42bf075f”

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