天天看點

使用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”

繼續閱讀