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, 2019 in Kubernetes by Namik
• 1,230 points
890 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, 2019 by Sirajul
• 59,230 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, 2019 in Kubernetes by Sirajul
• 59,230 points
3,496 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, 2019 in Kubernetes by Sirajul
• 59,230 points
770 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, 2019 in Kubernetes by Sirajul
• 59,230 points
1,326 views
+1 vote
1 answer
0 votes
3 answers

Error while joining cluster with node

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

answered Jan 17, 2019 in Others by anonymous
14,495 views
+4 votes
1 answer

Installing Web UI (Dashboard):kubernetes-dashboard on main Ubuntu 16.04.6 LTS (Xenial Xerus) server

Follow these steps: $ kubeadm reset $ kubeadm init ...READ MORE

answered Apr 12, 2019 in Kubernetes by Kalgi
• 52,360 points

reshown Apr 12, 2019 by Kalgi 5,958 views
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, 2019 in Kubernetes by Sirajul
• 59,230 points
4,282 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP