0

We are listening to multiple mailboxes on a single pod but if this pod goes down due to some reason need the other pod that is up to listen to these mailboxes. In order to keep recieving emails.

I would like to know if it is possible to find if a pod goes down like an event and trigger a script to perform above action on the go?

Jonas
  • 121,568
  • 97
  • 310
  • 388

1 Answers1

0

Approach 1:

kubernetes life cycle handler hook

apiVersion: v1
kind: Pod
metadata:
  name: lifecycle-demo
spec:
  containers:
  - name: lifecycle-demo-container
    image: nginx
    lifecycle:
      postStart:
        exec:
          command: ["/bin/sh", "-c", "echo Hello from the postStart handler > /usr/share/message"]
      preStop:
        exec:
          command: ["/bin/sh","-c","nginx -s quit; while killall -0 nginx; do sleep 1; done"]

https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/

Approach2:

Write a script which monitors the health of for every say x seconds, when 3 consecutive health checks fail kubernetes deletes the pod. so in your script, if 3 consecutive rest call fails for health then the pod is deleted. you can trigger your event.

Approach3:

maintain 2 replicas => problem could be two pods processing same mail. you can avoid this if you use kafka.

Manikanta P
  • 2,777
  • 2
  • 19
  • 22