我正在尝试使用代码中的连接字符串将在 AKS 集群上运行的 python Flask 应用程序连接到我的 Cosmos DB 实例。我的 cosmos db 设置配置为对所有网络开放且不受限制,但不知何故我收到超时错误。
我正在使用 Cosmos DB Mongo API ,并且 url 连接字符串如下:
"url": mongodb://dbname:[pass][email protected]:port/?ssl=true&retrywrites=false&replicaSet=globaldb&maxIdleTimeMS=120000&appName=@appname@
client = MongoClient(cfg.db['url'])
client_string = cfg.db['url']
我查看了容器日志并收到以下错误
'''
引发服务器选择超时错误(
pymongo.errors.ServerSelectionTimeoutError:
chatbotmongodb.mongo.cosmos.azure.com:10255: [Errno -3] 临时
名称解析失败,超时:30 秒,拓扑描述:]>;
'''
我在本地运行了映像并且它运行正常,它在 kubernetes 集群中存在问题,我认为这是由于 NSG 规则造成的,我添加了规则以允许 cosmos db 访问我的 vnet,但它不是在职的。
任何对此的见解都将受到赞赏。
I am trying to connect my python flask application running on AKS cluster to my Cosmos DB instance using the connection string within the code. My cosmos db setting are configured to be open for all networks and not restricted but somehow I am getting a time out error.
I am using Cosmos DB Mongo API , and the url connection string is as follows:
"url": mongodb://dbname:[pass][email protected]:port/?ssl=true&retrywrites=false&replicaSet=globaldb&maxIdleTimeMS=120000&appName=@appname@
client = MongoClient(cfg.db['url'])
client_string = cfg.db['url']
I looked at the container logs and am getting the following error
'''
raise ServerSelectionTimeoutError(
pymongo.errors.ServerSelectionTimeoutError:
chatbotmongodb.mongo.cosmos.azure.com:10255: [Errno -3] Temporary
failure in name resolution, Timeout: 30s, Topology Description: <TopologyDescription id: 621a9db116a435c37e59500c, topology_type: ReplicaSetNoPrimary, servers: [<ServerDescription ('chatbotmongodb.mongo.cosmos.azure.com', 10255) server_type: Unknown, rtt: None, error=AutoReconnect('chatbotmongodb.mongo.cosmos.azure.com:10255: [Errno -3] Temporary failure in name resolution')>]>
'''
I ran the Image locally and its runs properly ,its within the kubernetes cluster that there is a problem, I think its because of the NSG rules, I added rules to allow cosmos db access to my vnet as well, but its not working.
Any insight on this is appreciated.
发布评论
评论(1)
上述问题已解决,似乎与 NSG 相关的问题阻碍了 pod 交互,一旦修改规则,它们就开始工作
The above was resolved, it seemed NSG related issue which was blocking the pod interaction , once the rules were modified they started working