Openshift pods are unable to connect to mongodb pods

1/7/2020

I have deployed 3 mongo pods (1 Primary Pod & 2 secondary Pods) in openshift using a mongo template.

Initially the deployment failed due to "unable to create lock file in read-only directory". I resolved this by the issue of "oc adm policy add-scc-to-group anyuid system:authenticated" command.

oc adm policy add-scc-to-group anyuid system:authenticated

I think this will deploy the pods with root permissions.

Later I have deployed other pods which needs to communicate with mongodb pods, but the deployment fails with "Unable to connect to mongo-node-1.database:27017" error.

So I think the issue might be because of permissions. So, please let me know how to resolve this issue.

Note: The deployment of pods here is always done through the OpenShift GUI

-- Bhavani Prasad
kubernetes
openshift

2 Answers

1/22/2020

The issue is due to the pods and services in one project (namespace) are unable to access the pods and services in another project (namespace) in OpenShift.

All the pods and services in and can now access any pods and services in and vice versa using the following command.

$ oc adm pod-network join-projects --to=<project1> <project2> <project3>

Reference link - https://docs.openshift.com/container-platform/3.11/admin_guide/managing_networking.html

-- Bhavani Prasad
Source: StackOverflow

1/10/2020

The issue is in hostname or pod status. OpenShift service 'mongo-node-1' have to be in 'database' project and pod 'mongo-node-1...' have to be up in the same project

-- Oligzeev
Source: StackOverflow