<p>I'm trying to get the internal IP of a pod that is being killed. What I do now is to subscribe to events with reason "Killing" that have an "involvedObject" that is of type "Pod". If so I try to retrieve the pod to get its IP. The problem (I think) is that the Pod is already killed by the time I make the request to get it so I cannot its IP this way (this approach works fine when reason is "Created").</p>

<p>Is there a way to get the internal IP of a pod that is being stopped/killed before it's actually removed by Kubernetes?</p>

<p><strong>Update</strong></p>

<p>What I try to do is to implement a Kubernetes service discovery module (A) for <a href="https://github.com/Netflix/Turbine" rel="nofollow">Turbine</a> to detect all of the pods that expose <a href="https://github.com/Netflix/Hystrix/tree/master/hystrix-contrib/hystrix-metrics-event-stream" rel="nofollow">Hystrix streams</a>. I use <a href="https://github.com/fabric8io/fabric8/tree/master/components/kubernetes-api" rel="nofollow">fabric8 k8s library</a> to watch for Kubernetes events. When an event is discovered by A to be a pod running with label "hystrix-stream" I load the pod details (using the fabric8 library) in order to the get internal IP to the pod. This IP is then sent to Turbine so that it subscribes to the hystrix stream. This works great! The problem is that when A discovers that a pod is being killed I cannot load the pod details since by that time the pod has already been removed. Thus I cannot get the IP of the pod and I cannot tell Turbine to unsubscribe from this pod. My workaround is to maintain state in A that maps the pod name to its IP address. So what I'm after is a way to avoid maintaining this state in A and instead ask Kuberentes for the IP address of a pod that is being killed.</p>

<p>Johan-</p>

<p>You can watch the pods resource to get add/update/remove events for them. <a href="http://kubernetes.io/v1.1/docs/api-reference/v1/operations.html" rel="nofollow">http://kubernetes.io/v1.1/docs/api-reference/v1/operations.html</a>, search for 'list or watch objects of kind Pod'.  Hope that helps.</p>

<p>Note, events above does not refer to the Event API resource, but rather watch events.</p>
