title: Make Kubernetes wait for Pod termination before removing from Service endpoints
body: <p>According to <a href="https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#pod-termination" rel="nofollow noreferrer">Termination of Pods</a>, step 7 occurs simultaneously with 3. Is there any way I can prevent this from happening and have 7 occur only <em>after</em> the <code>Pod</code>'s graceful termination (or expiration of the grace period)?</p>
  <p>The reason why I need this is that my <code>Pod</code>'s termination routine requires <code>my-service-X.my-namespace.svc.cluster.local</code> to resolve to the <code>Pod</code>'s IP during the whole process, but the corresponding <code>Endpoint</code> gets removed as soon as I run <code>kubectl delete</code> on the <code>Pod</code> / <code>Deployment</code>.</p>
  <p><em>Note:</em> In case it helps making this clear, I'm running a bunch of clustered VerneMQ (Erlang) nodes which, on termination, dump their contents to other nodes on the cluster — hence the need for the nodenames to resolve correctly during the whole termination process. Only then should the corresponding <code>Endpoint</code>s be removed.</p>