Midson
Midson

Reputation: 1028

Restart a POD on an Event

I have 2 pods - P1 & P2.

Due to some issue, the application stop responding to the requests redirected from P1.

But locally K8s probes are working fine in P2.
In this condition, Is it possible to restart the P2 based on the Error count seen in P1? (No service mash used in this setup).

Upvotes: 0

Views: 1319

Answers (1)

CodeWizard
CodeWizard

Reputation: 142532

In this condition, Is it possible to restart the P2 based on the Error count seen in P1? (No service mash used in this setup).

You have several ways to accomplish that but they are a bit of "hack"

CronJob

Add CronJob which checks if the pod is responding and if not restart it

kubectl get events

Write your custom "Event Handler" to grab the stop events from the K8S events kubectl get events. you can fine-tune the events with --field-selector for example.

enter image description here

Upvotes: 1

Related Questions