After following this and this, 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?
Let's say I have a Pod with 2 containers:
apiVersion: v1
kind: Pod
metadata:
name: busybox
labels:
app: busybox
spec:
containers:
- image: busybox
name: busybox5
command:
- sleep
- "5"
imagePullPolicy: IfNotPresent
- image: busybox
name: busybox50
command:
- sleep
- "50"
imagePullPolicy: IfNotPresent
restartPolicy: Never
I want to get notified when the busybox5
container finishes executions not about busybox50
. I have done something like below using informers:
UpdateFunc: func(oldObj, obj interface{}) {
mObj := obj.(v1.Object)
log.Printf("%s: Updated", mObj.GetName())
},
This is simple. But how it works in a multi container Pod? What if I want to handle events about busybox5
container only in the Pod. How can I achieve this in Go?