<p>After following <a href="https://stackoverflow.com/questions/57297817/how-to-use-the-kubernetes-go-client-to-get-the-same-pod-status-info-that-kubectl">this</a> and <a href="https://stackoverflow.com/questions/52567334/watch-kubernetes-pod-status-to-be-completed-in-client-go">this</a>, how do I watch containers status (If a container crashed, completed etc) in a Pod and trigger events when a container status changes in a Pod?</p>
<p>Let's say I have a Pod with 2 containers:</p>
<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: busybox
  labels:
    app: busybox
spec:
  containers:
  - image: busybox
    name: busybox5
    command:
      - sleep
      - &quot;5&quot;
    imagePullPolicy: IfNotPresent
  - image: busybox
    name: busybox50
    command:
      - sleep
      - &quot;50&quot;
    imagePullPolicy: IfNotPresent
  restartPolicy: Never

</code></pre>
<p>I want to get notified when the <code>busybox5</code> container finishes executions not about <code>busybox50</code>. I have done something like below using informers:</p>
<pre><code>        UpdateFunc: func(oldObj, obj interface{}) {
            mObj := obj.(v1.Object)
            log.Printf(&quot;%s: Updated&quot;, mObj.GetName())
        },
</code></pre>
<p>This is simple. But how it works in a multi container Pod? What if I want to handle events about <code>busybox5</code> container only in the Pod. How can I achieve this in Go?</p>

Janshair Khan
<p>I think you need the <em>client-go informers</em>. Here's a good tutorial about them: <a href="https://firehydrant.io/blog/stay-informed-with-kubernetes-informers/" rel="nofollow noreferrer">https://firehydrant.io/blog/stay-informed-with-kubernetes-informers/</a></p>
<p>You can create an asynchronous event listener for the Pod in which your containers are running and then when one of a container status is change then the pod status is change also (updated, so you should listen to update events).
So you got the update event from your pod, after all you need get the Pod cointainers.</p>
<p>I hope you looking for this :)</p>
