K8s: why is there no easy way to get notifications if a pod becomes unhealthy and is restarted?
If a pod/container crashes for some reason Kubernetes is supposed to provide that reliability/availability that it will start somewhere else in the cluster. Having said that you probably want warnings and alerts (if you the pod goes into a Crashloopbackoff
.
Although you can write your own tool you can watch for specific events in your cluster and then you alert/warn on those using some of these tools:
- kubewatch
- kube-slack (Slack tool).
- The most popular K8s monitoring tool: prometheus.
- A paid tool like Sysdig.
Think of Pods as ephemeral entities - they can live in different nodes, they can crash, they can start again...
Kubernetes is responsible to handle the lifecycle of a pod. Your job is to tell it where to run (affinity rules) and how to tell if a pod if healthy.
There are many ways of monitoring pod crashes. For example - prometheus has a great integation with Kubernetes.