An example of kubernetes controller watching pods.
Start demo cluster with kind, kubeconfig should be available for the controller:
kind create cluster
Start our demo pod controller:
go run .
You should see that some system pods were already catched by the controller:
Pod added: kube-system/etcd-kind-control-plane
...
Let's add another pod:
kubectl apply -f pod.yaml
We should see that controller has handled the event:
Pod added: default/echo
Pod updated: default/echo
...
There is also a bunch of update events caused by the system.
Lets delete the pod:
kubectl delete pod echo
After a couple of updates the pod gets deleted:
...
Pod updated: default/echo
Pod updated: default/echo
Pod deleted: default/echo