Mutually exclude 2 pods

8/2/2018

I have two pods pod-a and pod-b and they belong to different applications inside an Openshift project.

Both pods expose a health check http url which I can use to check if a given pod is up and running.

I don't want both pods to be up together at any given time.

If pod-a is up, pod-b should not start and vice-versa.

How can I achieve this in Openshift?

-- Mandark
kubernetes
kubernetes-health-check
openshift

2 Answers

8/2/2018

I think you could add InitContainers to each with a check that the other service is not available. InitContainers are more commonly used to check that another service is available but you could them it to check that a service is not available provided you know the service name (which you presumably do).

-- Ryan Dawson
Source: StackOverflow

8/3/2018

Unfortunately that is not possible in the Kubernetes (Openshift). Kubernetes features nodeAffinity or nodeSelector are used for dividing pods between the nodes so in your case with one node they will not work. In your situation and for your needs there is no technical possibility to do that by k8s native tools.

-- aurelius
Source: StackOverflow