
تأخير إغلاق قرنة Kubernetes
(. . — ) Kubernetes-. , - pod’ , lifecycle hooks. , , pod , . , pod, . , , pod’ . , , .
“Kubernetes in Action”. . , , Kubernetes, .
pod’
lifecycle pod’. , — pod’, , pod’ . , , pod endpoint Service .
pod’ Service? , pod’ .
pod API, — . pod’ , :
- kubelet, .
- kube-proxyIP pod’- iptables.
- Endpoints controller pod endpoints, pod Service
. , , . , pod preStop TERM , pod . pod , .
, , pod , . , - Kuberenetes. , ? ? , online? , ? ?
, , 0. , , 99% . sleep preStop, . .
, preStop. “Kubernetes in Action”, Lukša 5-10 , 5 :
lifecycle:
 preStop:
   exec:
     command: [
       "sh", "-c",
       # Introduce a delay to the shutdown sequence to wait for the
       # pod eviction event to propagate. Then, gracefully shutdown
       # nginx.
       "sleep 5 && /usr/sbin/nginx -s quit",
     ]
. , kubectl drain, pod’ . event, pod’ kubelet Endpoint Controller ( Service endpoints) . , , preStop pod.

Drain node pod, event
preStop , . Endpoint Controller pod:

Pod ,
, pod , , . , - pod’, , pod. , , event , .
, , preStop sleep pod Nginx, pod :


Node 1, . , , .
pod’
, , pod’, . pod’, , pod’? Deployment .
Deployment controller, . resource config, pod’ . Deployment pod’, pod’. :
template:
   metadata:
     labels:
       app: nginx
   spec:
     containers:
     - name: nginx
       image: nginx:1.15
       ports:
       - containerPort: 80
, pod’ Deployment app: nginx pod’ nginx:1.15, 80 .
pod’, spec Deployment, , :
spec:
 replicas: 2
, 2 pod’ . , pod’ , , pod. , , pod’ drain, Deployment .
, preStop , pod’ . Deployment pod’. ?
drain , , pod’. , stateful-, , , pod’ , .
drain , pod’, . , pod’ , , drain, pod’.
, Kubernetes PodDisruptionBudgets, pod, . , drain, drain .
Kubernetes AWS , Gruntwork.io.
: