簡體   English   中英

Kube.netes PreStop 掛鈎是阻止 pod 中的所有容器停止,還是只阻止它所在的容器?

[英]Do Kubernetes PreStop hooks prevent ALL containers in a pod from stopping, or only the container it's set on?

關於PreStop掛鈎的 Kube.netes 文檔聲明如下:

PreStop 掛鈎不會從停止容器的信號異步執行; 在發送 TERM 信號之前,鈎子必須完成它的執行。

但是,它沒有說明 pod 中的其他容器。 假設terminationGracePeriodSeconds還沒有過去。

在每個容器的PreStop掛鈎完成之前,是否保護 Pod 中的所有容器免於終止? 還是每個 PreStop 掛鈎只保護自己的容器?

我相信preStop鈎子只保護為其聲明的容器。

例如,在以下設置中:

apiVersion: v1
kind: Pod
metadata:
  name: lifecycle-demo
spec:
  containers:
  - name: lifecycle-demo-container
    image: nginx
    lifecycle:
      preStop:
        exec:
          command: ["/bin/sh","-c","sleep 15"]
  - name: other-container
    image: mysql
    env:
    - name: MYSQL_ALLOW_EMPTY_PASSWORD
      value: "true"

如果我終止 pod,mysql 會收到 SIGTERM 並立即關閉,而 nginx 容器由於其preStop鈎子會額外存活 15 秒

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM