<p>I am trying to deploy mongodb pods (1 Primary &amp; 2 Secondary) in OpenShift, they got deployed but went to "Error" state with the following error,</p>

<pre><code>exception in initAndListen: IllegalOperation: Attempted to create a lock file on a read-only directory: /data/db, terminating
</code></pre>

<p>The mongo pods are up and running successfully after the issue of following adm policy,</p>

<pre><code>oc adm policy add-scc-to-group anyuid system:authenticated
</code></pre>

<p>Now I am trying to deploy a springboot application that connects to mongodb but the pod is restarting multiple times because of the following error,</p>

<pre><code> INFO Exception in monitor thread while connecting to server mongo-node-2.database:27017
com.mongodb.MongoSocketOpenException: Exception opening socket
Caused by: java.net.SocketTimeoutException: connect timed out
                        INFO Exception in monitor thread while connecting to server mongo-node-3.database:27017
com.mongodb.MongoSocketOpenException: Exception opening socket
Caused by: java.net.SocketTimeoutException: connect timed out
                        INFO Exception in monitor thread while connecting to server mongo-node-1.database:27017
com.mongodb.MongoSocketOpenException: Exception opening socket
Caused by: java.net.SocketTimeoutException: connect timed out
                        WARN Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Failed to start bean 'org.springframework.kafka.config.internalKafkaListenerEndpointRegistry'; nested exception is org.apache.kafka.common.errors.TimeoutException: Timeout expired while fetching topic metadata
org.springframework.context.ApplicationContextException: Failed to start bean 'org.springframework.kafka.config.internalKafkaListenerEndpointRegistry'; nested exceptio  is org.apache.kafka.common.errors.TimeoutException: Timeout expired while fetching topic metadata
Caused by: org.apache.kafka.common.errors.TimeoutException: Timeout expired while fetching topic metadata
</code></pre>

<p>The springboot app pod is uanble to connect to mongodb pod when deployed through openshift, so I have created a dummy pod using k8s and tried to connect mongodb pod and the connection is successful,</p>

<pre><code>mongo mongo-node-1.database.svc (successful)
</code></pre>

<p>I am able to connect to mongodb from outside the OpenShift cluster through NodePort, from within the cluster using dns (mongo-node-1.database.svc) and from a pod created though k8s but not from the OpenShift deployment.</p>

<p>I suspect that the issue might be because of some policy that OpenShift is blocking the springboot pod to connect with the mongodb pod.</p>

<p>Any suggestions please.</p>

<p>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.</p>

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

<pre><code>$ oc adm pod-network join-projects --to=&lt;project1&gt; &lt;project2&gt; &lt;project3&gt;
</code></pre>

<p>Reference link - <a href="https://docs.openshift.com/container-platform/3.11/admin_guide/managing_networking.html" rel="nofollow noreferrer">https://docs.openshift.com/container-platform/3.11/admin_guide/managing_networking.html</a></p>
