We have a bunch of pods that use RabbitMQ. If the pods are shut down by K8S with SIGTERM, we have found that our RMQ client (Python Pika) has no time to close the connection to RMQ Server causing it to think those clients are still alive until 2 heartbeats are missed.
Our investigation has turned up that on SIGTERM, K8S kills all in- and most importantly OUTbound TCP connections, among other things (removing endpoints, etc.) Tried to see if any connections were still possible during preStop hooks, but preStop seems very internally focused and no traffic got out.
Has anybody else experienced this issue and solved it? All we need to do is be able to get a message out the door before kubelet slams the door. Our pods are not K8S "Services" so some suggestions didn't help.
Steps to reproduce:
- add preStop hook sleep 30s to Sender pod
- tail logs of Receiver pod to see inbound requests
- enter Sender container's shell & loop curl Receiver - requests appear in the logs
k delete podto start termination of Sender pod- curl requests immediately begin to hang in Sender, nothing in the Receiver logs