[ad_1]

based on Kubernetes documentation when using preStop hook to delay pod termination, Kubernetes marks the Pod state as “Terminating” and stops sending traffic to the Pod, but what if there are some of these “Terminating” pods need to communicate with each other to complete the their tasks , in this case will not be able to communicate .

to explain the situation more , imagine that I have two pods A & B as showing below

  ---------       ---------       --------       -------- 
 | SRV A   | --> | Pod A 1 | --> | SRV B1 | --> | Pod B1 |
  ---------       ---------       --------       -------- 

As you can see , “Pod A1” depends on “Pod B1” , and they are communicating using “SRV B1”.

the preStop hook has been adjusted for both pods as the following

lifecycle:
  preStop:
    exec:
      command: ["/bin/bash", "-c", "sleep 30"] 

when updating the release to version 2 , the communication between “Pod A1” and “Pod B1” will be lost, since “SRV B1” will not be able to send any traffic to a Terminating pod(B1)

  ---------        ---------       --------        -------- 
 |         |  -X->| Pod A 1 | --> | SRV B1 | -X-> | Pod B1 |
 | SRV A   |       ---------       --------        --------   
 |         |       ---------       --------       -------- 
 |         |  --> | Pod A 2 | --> | SRV B2 | --> | Pod B2 |
  ---------        ---------       --------       --------  

so is there are any workaround I can apply to keep the communication with Terminating pods

[ad_2]