![](/img/trans.png)
[英]Kubernetes: Replicaset with multi-container pod not provisioning all containers
[英]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.