我正在尝试在 OpenShift 中部署 mongodb pod(1 个主要和 2 个辅助),它们已部署但进入“错误”状态并出现以下错误,
exception in initAndListen: IllegalOperation: Attempted to create a lock file on a read-only directory: /data/db, terminating
发布以下 adm 策略后,mongo pod 已成功启动并运行,
oc adm policy add-scc-to-group anyuid system:authenticated
现在我正在尝试部署一个连接到 mongodb 的 springboot 应用程序,但由于以下错误,pod 正在多次重启,
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
springboot app pod通过openshift部署时无法连接mongodb pod,所以我用k8s创建了一个dummy pod并尝试连接mongodb pod,连接成功,
mongo mongo-node-1.database.svc (successful)
我可以通过 NodePort 从 OpenShift 集群外部、使用 dns (mongo-node-1.database.svc) 的集群内部以及通过 k8s 创建的 pod 连接到 mongodb,但不能通过 OpenShift 部署。
我怀疑这个问题可能是因为 OpenShift 阻止 springboot pod 与 mongodb pod 连接的某些策略。
请有任何建议。