
有人能幫我指出解釋以下現象的文檔嗎?
當我們運行時kubectl run --rm --stdin --tty --image hello-world hello-pod
,Kubernetes 會自動重新啟動它。為什麼 Kubernetes 忘記刪除它?
同時,如果我們運行kubectl run --rm --stdin --tty --image busybox busy-pod
,它會被自動刪除(這似乎是相當合法的)。
任何建議表示讚賞。謝謝。
答案1
第一個 Pod 重新啟動的原因是那裡可能存在錯誤,並且 Kubernetes 不斷重新啟動它,「希望」它最終能夠解決問題。當你運行它時,你會得到一個“CrashLoopBack”,但 Kubernetes 最終會刪除它,但只是在一段時間之後:
kubectl run --rm --stdin --tty --image hello-world hello-pod
pod "hello-pod" deleted
error: timed out waiting for the condition
當您退出 tty (ctrl + D) 時,Kubernetes 也會刪除第二個 pod。原因是進程結束並且您添加了“--rm”選項,該選項正是這樣做的 - 當進程終止時它會自動刪除 pod,在這種情況下意味著只需退出終端/bash/shell 等。