How to terminate a pod when a specific event occurs?

0 votes
In Kubernetes, I have a pod which is running 2 containers. When one container stops, another container is still running, On this event i want to terminate the pod. How can i do this? Somebody Please help!
Jul 19 in Kubernetes by Namik
• 1,210 points
40 views

1 answer to this question.

0 votes
  • You need to add a liveness and readiness probe to query each container,  if the probe fails, the entire pod will be restarted .

  • Add liveness object that calls any API that returns 200 to you from another container and both liveness and readiness probes run in infinite loops.

  • For example, If X depended to Y So add liveness  in X that check the health of Y.

  • Both readiness/liveness probes always have to run after the container has been started .

  • kubelet component performs the liveness/readiness checks and set initialDelaySeconds and it can be anything from a few seconds to a few minutes depending on app start time. 

  • Below is the configuration spec

livenessProbe spec:
livenessProbe:
httpGet:
path: /path/test/
port: 10000
initialDelaySeconds: 30
timeoutSeconds: 5
readinessProbe spec:
readinessProbe:
httpGet:
path: /path/test/
port: 10000
initialDelaySeconds: 30
timeoutSeconds: 5
answered Jul 19 by Sirajul
• 40,980 points

Related Questions In Kubernetes

0 votes
1 answer

how to debug a pending pod?

Pending pod cannot be scheduled onto a ...READ MORE

answered Jul 15 in Kubernetes by Sirajul
• 40,980 points
47 views
0 votes
1 answer

Is it possible to force the pod to run on a specific node?

By default, anti-affinity is not attempted by ...READ MORE

answered Jul 15 in Kubernetes by Sirajul
• 40,980 points
64 views
0 votes
1 answer

How do i tie a service to a pod or a set of pods?

By declaring pods with the label(s) and ...READ MORE

answered Jul 16 in Kubernetes by Sirajul
• 40,980 points
43 views
0 votes
1 answer
0 votes
3 answers

Error while joining cluster with node

Hi Kalgi after following above steps it ...READ MORE

answered Jan 17 in Others by anonymous
3,391 views
+3 votes
1 answer
0 votes
2 answers

How do I force a pod to run on a specific node?

By default, anti-affinity is not attempted by Kubernetes as ...READ MORE

answered Aug 6 in Kubernetes by Sirajul
• 40,980 points
52 views