func (d *Deployment) listenForPodEvents(stopCh <-chan struct{}) {
	getPod := func(obj interface{}) (*v1.Pod, bool) {
		pod, ok := obj.(*v1.Pod)
		if !ok {
			tombstone, ok := obj.(cache.DeletedFinalStateUnknown)
			if !ok {
				return nil, false
			}
			pod, ok = tombstone.Obj.(*v1.Pod)
			return pod, ok
		}
		return pod, true
	}
	rw := k8sutil.NewResourceWatcher(
		d.deps.Log,
		d.deps.KubeCli.CoreV1().RESTClient(),
		"pods",
		d.apiObject.GetNamespace(),
		&v1.Pod{},
		cache.ResourceEventHandlerFuncs{
			AddFunc: func(obj interface{}) {
				if p, ok := getPod(obj); ok && d.isOwnerOf(p) {
					d.triggerInspection()
				}
			},
			UpdateFunc: func(oldObj, newObj interface{}) {
				if p, ok := getPod(newObj); ok && d.isOwnerOf(p) {
					d.triggerInspection()
				}
			},
			DeleteFunc: func(obj interface{}) {
				if p, ok := getPod(obj); ok && d.isOwnerOf(p) {
					d.triggerInspection()
				}
			},
		})
	rw.Run(stopCh)
}
listenForPodEvents keep listening for changes in pod until the given channel is closed.
package deployment
import (
	v1 "k8s.io/api/core/v1"
	crdv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
	"k8s.io/client-go/tools/cache"
	"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
)