![image](https://habrastorage.org/getpro/habr/post_images/756/381/101/7563811010ba5a50e8106ea56c5577c1.png)
ArrĂȘt correct du conteneur dans Kubernetes
(. . â ) Kubernetes-. , drain . , : podâ.
podâ
kubectl drain
podâ . , :
drain
podâ control plane. kubelet
, podâ.kubelet
podâ preStop
preStop
, kubelet
TERM
podâ.kubelet
( podâ, ; 30 ) , ( SIGKILL
). preStop
.
, preStop
, â â . , , , TERM
, , , , . , , TERM
(, - ), preStop
API, .
Nginx TERM
, . preStop
. resource lifecycle
. lifecycle
:
lifecycle:
preStop:
exec:
command: [
# Gracefully shutdown nginx
"/usr/sbin/nginx", "-s", "quit"
]
, , SIGTERM
Nginx /usr/sbin/nginx -s quit
. , , Nginx pod, TERM
noop ( â .).
Nginx. , Deployment
:
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx
spec:
replicas: 2
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.15
ports:
- containerPort: 80
lifecycle:
preStop:
exec:
command: [
# Gracefully shutdown nginx
"/usr/sbin/nginx", "-s", "quit"
]
podâ
podâ Nginx , . , , , Nginx , .
, deployment. , , . . podâ.
![image](https://habrastorage.org/getpro/habr/post_images/246/28c/61c/24628c61cd1ecbd753494266e1bb3206.png)
, Node 1. kubectl drain node-1
, kubelet
preStop
, Nginx:
![image](https://habrastorage.org/getpro/habr/post_images/e7d/9f1/fcb/e7d9f1fcb365b23407f7d4525098b4be.png)
nginx , . , nginx , , .
, . pod, . , , nginx :
![image](https://habrastorage.org/getpro/habr/post_images/833/8d8/2d5/8338d82d59548c68a4be36313f706fa6.png)
, nginx , podâ drain
:
![image](https://habrastorage.org/getpro/habr/post_images/79b/d03/4cc/79bd034cc7c41f175de82eaffe4a17fb.png)
![image](https://habrastorage.org/getpro/habr/post_images/d1f/07f/648/d1f07f6483efa36300f788c47bbfd963.png)
, , podâ , . , , .
? , , ? , podâ , preStop
, Service
.
Kubernetes AWS , Gruntwork.io.
: