情況
執行一個長連接訪問的方法,執行到一半後 沒有日誌輸出了。初步判斷爲pod已經被重啓了。
原因
使用命令排查如下:
[zzq@localhost zzq]$ kubectl get pods |grep report-api
report-api-6b4cdf5f6d-cn2vg 1/1 Running 0 2d18h
report-api-6b4cdf5f6d-gtms8 1/1 Running 0 59m
report-api-6b4cdf5f6d-k5dqf 1/1 Running 0 3h1m
report-api-6b4cdf5f6d-mjpnf 1/1 Running 2 12s
report-api-6b4cdf5f6d-rqssb 1/1 Running 0 2d18h
report-api-6b4cdf5f6d-tqmxm 1/1 Running 0 82m
發現report-api-6b4cdf5f6d-mjpnf的 pod有重啓過2次,繼續定位 重啓原因。
使用event命令定位重啓的原因
event命令記錄了k8s重要的集羣事件
kubectl get event
或者
kubectl get event |grep report-api
輸出如下: